Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code changes in comment editor #1174

Closed
torgeirl opened this issue Apr 6, 2021 · 3 comments
Closed

Code changes in comment editor #1174

torgeirl opened this issue Apr 6, 2021 · 3 comments
Assignees
Milestone

Comments

@torgeirl
Copy link
Collaborator

torgeirl commented Apr 6, 2021

As user suggestion for the improved comment editor (#1040): enabling code change snippets in the comment editor to allow examiners to write code changes in their feedback to the student.

Ie..:

#!/usr/bin/env python3

-from jon import dumps as json_dumps
+from json import dumps as json_dumps

where the - line is highlighted red and the + line is highlighted green, similar to how Github allow users to comment inline on pull requests.

@torgeirl
Copy link
Collaborator Author

torgeirl commented Feb 8, 2022

This could hopefully be added as custom markdown tags when the ACE editor gets replaced (#1217).

@torgeirl torgeirl added this to the Devilry 5.5 milestone Feb 8, 2022
@espenak espenak self-assigned this May 23, 2022
espenak added a commit that referenced this issue May 25, 2022
@espenak
Copy link
Member

espenak commented May 25, 2022

Should be usable now I think @torgeirl... This markdown code:

##<##
def Hello(self, x):
    print(f'Hello')
    print('World')
##>##
def hello(self, x):
    print(f'Hello {x}')
    print('World')
##<##

Results in:
image

image

image

Docs

Here is the docs (just screenshot from the builtin docs for the supported markdown):
image

Why multiple diff "styles"?

This is because the different styles are better/worst for different amounts of changes/code lines. "Side by side" and "simple" is very nice for short examples, while compact is much better for larger snippets with lots of changes. The compact style is very similar (or perhaps the same) as the one the git diff command uses by default. Adding all three was simple since they are supported by the builtin python difflib module.

@espenak espenak closed this as completed May 25, 2022
@espenak
Copy link
Member

espenak commented May 25, 2022

Here is an a bit more realistic code example with a bit of common code left between the two snippets:

image

### Simple diff
##<##
def Hello(self, x):
    print(f'Hello')
    print('World')

class HelloWorld(object):
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return self.x
##>##
def hello(self, x):
    print(f'Hello {x}')
    print('World')


class HelloWorld:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return f'Hello {self.x} world'
##<##


### Compact diff
##<## compact
def Hello(self, x):
    print(f'Hello')
    print('World')

class HelloWorld(object):
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return self.x
##>##
def hello(self, x):
    print(f'Hello {x}')
    print('World')


class HelloWorld:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return f'Hello {self.x} world'
##<##




### Side by side diff
##<## sidebyside
def Hello(self, x):
    print(f'Hello')
    print('World')

class HelloWorld(object):
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return self.x
##>##
def hello(self, x):
    print(f'Hello {x}')
    print('World')


class HelloWorld:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return f'Hello {self.x} world'
##<##

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants