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

Quiz exercises: Fix an issue with the multiple choice visual mode #9284

Merged
merged 9 commits into from
Sep 11, 2024

Conversation

pzdr7
Copy link
Contributor

@pzdr7 pzdr7 commented Sep 4, 2024

Checklist

General

Client

Motivation and Context

Closes #9281.

When using the multiple choice visual mode, it was possible for the changes to be discarded when saving the quiz. This happened because the component retrieved the text from the wrong source (the outdated markdown editor, rather than the visual component)

Description

When preparing to save while the editor is in visual mode, retrieves the text from the visual editor and stores it in the markdown editor. This triggers an update of the question and stores all changes.

Also, added a small e2e Test that checks if the Visual editor works as intended.

Steps for testing

Prerequisites:

  • 1 Instructor
  • 1 Quiz exercise with a MC question
  1. Navigate to the quiz and edit it.
  2. Go to the MC question and switch to the Visual tab.
  3. Modify the question. Make sure your changes are saved when you click save at the bottom (without having to switch to a different editor tab).

Testserver States

Note

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







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

  • New Features

    • Enhanced editing experience for multiple-choice questions with improved markdown handling.
    • Introduced a visual mode for creating and editing multiple-choice questions.
    • Added unique identifiers for answer options and buttons to improve accessibility.
  • Bug Fixes

    • Improved logic for saving markdown content based on editing mode.
  • Tests

    • Expanded test coverage for multiple-choice question creation and editing in both visual and markdown modes.

@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Sep 4, 2024
@pzdr7 pzdr7 linked an issue Sep 4, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Sep 6, 2024

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test1.artemis.cit.tum.de" is already in use by PR #9283.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Sep 6, 2024
@pzdr7 pzdr7 added deploy:artemis-test2 and removed deployment-error Added by deployment workflows if an error occured labels Sep 6, 2024
@pzdr7 pzdr7 temporarily deployed to artemis-test2.artemis.cit.tum.de September 6, 2024 14:49 — with GitHub Actions Inactive
@pzdr7 pzdr7 marked this pull request as ready for review September 6, 2024 15:51
@pzdr7 pzdr7 requested a review from a team as a code owner September 6, 2024 15:51
Copy link

coderabbitai bot commented Sep 6, 2024

Walkthrough

The changes involve modifications to the MultipleChoiceQuestionEditComponent and related files to improve the handling of markdown content and enhance the visual editing experience for multiple-choice questions. Key updates include the removal of unnecessary dependencies, adjustments to the save logic based on editing mode, and enhancements to the HTML structure for better accessibility. Additionally, new test cases have been added to ensure the functionality works as intended.

Changes

Files Change Summary
src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.ts Removed ArtemisMarkdownService dependency, modified prepareForSave logic for markdown handling.
src/main/webapp/app/exercises/quiz/shared/questions/multiple-choice-question/multiple-choice-visual-question.component.html Added unique id attributes to answer options and modified button identifiers for clarity.
src/main/webapp/app/exercises/quiz/shared/questions/multiple-choice-question/multiple-choice-visual-question.component.ts Removed faSquare icon from properties to simplify the component's visual representation.
src/test/javascript/spec/component/multiple-choice-question/multiple-choice-question-edit.component.spec.ts Added tests for prepareForSave method to verify markdown parsing in different modes.
src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseManagement.spec.ts Introduced a test case for creating a multiple-choice quiz in visual mode.
src/test/playwright/support/pageobjects/exercises/quiz/QuizExerciseCreationPage.ts Added DEFAULT_MULTIPLE_CHOICE_ANSWER_COUNT constant and method for creating/editing questions in visual mode.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MultipleChoiceQuestionEditComponent
    participant MarkdownEditor
    participant VisualChild

    User->>MultipleChoiceQuestionEditComponent: Save Question
    MultipleChoiceQuestionEditComponent->>MultipleChoiceQuestionEditComponent: Check Editing Mode
    alt Visual Mode
        MultipleChoiceQuestionEditComponent->>VisualChild: Parse Question
        VisualChild-->>MultipleChoiceQuestionEditComponent: Return Parsed Content
        MultipleChoiceQuestionEditComponent->>MarkdownEditor: Update Markdown Content
    else Markdown Mode
        MultipleChoiceQuestionEditComponent->>MarkdownEditor: Parse Markdown
    end
    MultipleChoiceQuestionEditComponent-->>User: Confirm Save
Loading

Assessment against linked issues

Objective Addressed Explanation
Should save the changes (Issue #9281)
Verify that the question does not show the last changes The issue description indicates a failure to save.

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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Code

Copy link
Contributor

@edkaya edkaya 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 TS4, works as expected

Copy link
Contributor

@az108 az108 left a comment

Choose a reason for hiding this comment

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

Code 👍

Copy link
Contributor

@dmytropolityka dmytropolityka 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 ts3, works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) playwright ready for review tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Quiz: the visual edition option does not save changes
6 participants