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

Exam mode: Fix problems with highlighting of the differences in the problem statement #8461

Merged
merged 25 commits into from
Jun 30, 2024

Conversation

coolchock
Copy link
Contributor

@coolchock coolchock commented Apr 22, 2024

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.

Motivation and Context

Currently there is an issue that differences in a problem statement are not properly highlighted when a change occurs inside of code tag (single backtick operator) or in the task that gets injected into the markdown.
This pull requests resolves this issue and ensures that differences are rendered correctly, regardless of their location in the markdown.

Description

Previously, differences between two problem statements were calculated at the markdown level and then markdown with highlighted differences was rendered. This occasionally led to errors, especially when changes occurred within special syntax such as code blocks or URLs. With the new approach, the problem statement markdowns are first converted into HTML. Then, differences between rendered problem statements are calculated using an HTML diff library.

The logic to remove tasks and inject them back into the document was moved to ProgrammingExerciseInstructionComponent to enable calculating tasks from the markdown with differences.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Student
  • 1 Exam with a programming exercise

There is already an exam called 'problem-statement-updates' in 'Test Course Michal Kawka' on ts2. Test users 1-7 are registered for the exam.

  1. Log in to Artemis as a student in one browser
  2. Log in to Artemis as an instructor in the second browser or incognito tab
  3. Navigate to the exam as a student and open the programming exercise
  4. As instructor, make some changes to the problem statement inside inside of special syntax (triple backtip, single backtick, <>, etc.)
  5. As student, verify that the differences are highlighted correctly
  6. As instructor, make some changes to the problem statement in one of the tasks. Task looks as follows (this is not highlighting, just an explanation what is meant by task):
image
  1. As student, verify that the differences are highlighted correctly
  2. Please also make some changes in the other places, for example headers, bold and italic parts of the markdown and ensure that everything works as expected.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked






Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Screenshots

Differences inside single backticks
Before:
image
After:
image

Differences in the tasks
Before:
image
After:
image

Summary by CodeRabbit

  • New Features

    • Enhanced problem statement highlighting in exam exercises using HTML for better visual differentiation.
    • Improved markdown to HTML conversion for more accurate problem statement displays.
  • Updates

    • All exam submission components now display problem statements using an HTML variable for consistency and clarity.
    • Problem statement update methods now accept HTML inputs for uniform handling across different exam exercise types.

@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Apr 22, 2024
@coolchock coolchock temporarily deployed to artemis-test2.artemis.cit.tum.de April 23, 2024 21:38 — with GitHub Actions Inactive
@coolchock coolchock marked this pull request as ready for review April 23, 2024 21:55
@coolchock coolchock requested a review from a team as a code owner April 23, 2024 21:55
Copy link

coderabbitai bot commented Apr 23, 2024

Walkthrough

The recent updates primarily focus on enhancing the way problem statements are processed and displayed across various exam exercise components. The significant change involves using the htmlForMarkdown utility to convert markdown to HTML and employing html-diff-ts for highlighting differences in updated problem statements. These changes streamline problem statement handling by using a unified HTML representation, improving clarity and consistency.

Changes

Files Change Summary
.../exam-exercise-update-highlighter/exam-exercise-update-highlighter.component.ts Updated to handle problem statement differences with html-diff-ts and htmlForMarkdown. Added and modified class properties to support these changes.
.../exercises/file-upload/file-upload-exam-submission.component.ts
.../exercises/modeling/modeling-exam-submission.component.ts
.../exercises/text/text-exam-submission.component.ts
Imported htmlForMarkdown and updated problem statement handling by introducing problemStatementHtml. Adjusted method signatures for updating problem statements.
.../exercises/file-upload/file-upload-exam-submission.component.html
.../exercises/modeling/modeling-exam-submission.component.html
.../exercises/text/text-exam-submission.component.html
Updated the HTML templates to use problemStatementHtml for displaying problem statements instead of directly accessing exercise.problemStatement.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between edae665 and 9231c0e.

Files selected for processing (3)
  • src/main/webapp/app/exam/participate/exercises/file-upload/file-upload-exam-submission.component.html (1 hunks)
  • src/main/webapp/app/exam/participate/exercises/modeling/modeling-exam-submission.component.html (1 hunks)
  • src/main/webapp/app/exam/participate/exercises/text/text-exam-submission.component.html (1 hunks)
Additional context used
Path-based instructions (3)
src/main/webapp/app/exam/participate/exercises/modeling/modeling-exam-submission.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exam/participate/exercises/text/text-exam-submission.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exam/participate/exercises/file-upload/file-upload-exam-submission.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

Additional comments not posted (6)
src/main/webapp/app/exam/participate/exercises/modeling/modeling-exam-submission.component.html (2)

48-48: Use problemStatementHtml instead of exercise.problemStatement.

The updated code correctly uses problemStatementHtml for the problem statement.


50-50: Use problemStatementHtml instead of exercise.problemStatement.

The updated code correctly uses problemStatementHtml for the problem statement.

src/main/webapp/app/exam/participate/exercises/text/text-exam-submission.component.html (2)

54-54: Use problemStatementHtml instead of exercise.problemStatement.

The updated code correctly uses problemStatementHtml for the problem statement.


56-56: Use problemStatementHtml instead of exercise.problemStatement.

The updated code correctly uses problemStatementHtml for the problem statement.

src/main/webapp/app/exam/participate/exercises/file-upload/file-upload-exam-submission.component.html (2)

77-77: Use problemStatementHtml instead of exercise.problemStatement.

The updated code correctly uses problemStatementHtml for the problem statement.


79-79: Use problemStatementHtml instead of exercise.problemStatement.

The updated code correctly uses problemStatementHtml for the problem statement.


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are always opted into early access features.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 23, 2024
Copy link
Contributor

@pzdr7 pzdr7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS2 - can you double check the code block (```) functionality?

@@ -59,4 +68,19 @@ export class ArtemisMarkdownService {
convertedString = convertedString.slice(0, paragraphPosition) + convertedString.slice(paragraphPosition).replace('<p>', '<p class="inline-paragraph">');
return this.sanitizer.bypassSecurityTrustHtml(convertedString);
}

/**
* Unescapes html tags that are placed inside <code> tags (single backtick operator).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <code> tag is also used for code blocks (triple backtick):

Source code:

image

Problem statement:

image

If I make a change, e.g.

image

The problem statement (with changes enabled) displays this:

image

Can we do something about this?

@pzdr7
Copy link
Contributor

pzdr7 commented Apr 24, 2024

It could be out of scope for this PR, but URLs have a similar problem:

I changed

[url](https://github.com/ls1intum/Artemis/pull/8461)

to

[url](https://github.com/ls1intum/Artemis/pull/8462)

and got

image

@krusche
Copy link
Member

krusche commented Apr 27, 2024

I'm not sure if escaping is a good solution here. There will always be difficulties for special syntax. Would it not make more sense to use some kind of html diff?

Copy link

github-actions bot commented May 4, 2024

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@coolchock coolchock force-pushed the bugfix/exam-mode/highlighting-of-differences branch from 85d4409 to 6f7fadb Compare May 9, 2024 13:19
@github-actions github-actions bot added the server Pull requests that update Java code. (Added Automatically!) label May 9, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes May 9, 2024
@krusche krusche merged commit 6ae0625 into develop Jun 30, 2024
26 of 29 checks passed
@krusche krusche deleted the bugfix/exam-mode/highlighting-of-differences branch June 30, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix client Pull requests that update TypeScript code. (Added Automatically!) server Pull requests that update Java code. (Added Automatically!) tests too-long-open !!! This is an antipattern, we should aim for small PRs that are only open for a short time !!!
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

10 participants