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: Enable manual quiz evaluation for course quizzes #8837

Merged
merged 9 commits into from
Jun 21, 2024

Conversation

Hialus
Copy link
Member

@Hialus Hialus commented Jun 21, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

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 added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

There was a bug in production that caused the automatic quiz evaluation to fail. Therefore we need a method to evaluate the quiz manually, which is a feature that could be useful as a backup in general.

Description

This PR fixes the bug and also adds a button to the quiz detail page to evaluate the quiz. This is different from the re-evaluation, as the evaluation keeps old results and only creates new results for submissions that do not have one yet.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • Local DB access
  • If you have a quiz exercise with already existing submissions and results you can skip straight to point 5
  1. Log in to Artemis
  2. Create a quiz
  3. Participate in the quiz
  4. Wait for the quiz to end
  5. Go to the instructor detail page of the quiz
  6. Go to your DB and find your result in the results table. Note it's ID
    Go to the participants_score table and delete the entry where the last_result_id is the id of your result
    Then delete the entry of your result in the results table
  7. Click the "Participations" button
  8. Click on your submissions
  9. You will see no result
  10. Go back to the detail page
  11. Press the new evaluate quiz button
  12. Now see you submission again and you have a result again.

Exam Mode Testing

Prerequisites:

  • 1 Instructor
  • 1 Students
  • 1 Exam with a Quiz Exercise
  • If you have an exam with unevaluated quiz exercises you can skip to point 4
  1. Log in to Artemis
  2. Participate in the exam as a student
  3. Wait for the exam to end
  4. Go to the assessment page of the exam
  5. Click the "Evaluate quizzes" button
  6. If you look into the scores the students have results now

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

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

Test Coverage

TODO

Screenshots

image

Summary by CodeRabbit

  • New Features

    • Added a new button to evaluate quiz exercises in the quiz management UI.
    • Introduced a new QuizResultService for efficient quiz evaluation and statistics management.
  • Bug Fixes

    • Improved handling of null values in UserRoleDTO.
  • Refactor

    • Refactored quiz evaluation logic to accept QuizExercise as a parameter for accurate score calculation.
  • Documentation

    • Updated German and English translations for the new quiz evaluation functionality.
  • Tests

    • Added integration tests to ensure correct evaluation and result management of quiz exercises.

@Hialus Hialus requested a review from a team as a code owner June 21, 2024 11:36
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) labels Jun 21, 2024
Copy link

coderabbitai bot commented Jun 21, 2024

Walkthrough

The changes involve refactoring quiz evaluation processes in an educational platform. The Result class method evaluateQuizSubmission now accepts a QuizExercise parameter to improve score calculation accuracy. A new QuizResultService class centralizes quiz evaluation logic and updates statistics. Various classes, such as ExamService and UI components, have been updated to integrate with this new service. Additionally, new methods and fields ensure proper handling and evaluation of quiz exercises.

Changes

Files/Paths Change Summaries
.../domain/Result.java evaluateQuizSubmission method now accepts a QuizExercise parameter.
.../service/dto/UserRoleDTO.java Constructor modified to handle a nullable role parameter with conditional assignment.
.../service/exam/ExamQuizService.java Removed evaluateQuizAndUpdateStatistics and evaluateSubmissions methods. Removed resultService field.
.../service/exam/ExamService.java Added QuizResultService to the constructor and removed ExamQuizService dependency.
.../service/quiz/QuizExerciseService.java Modified evaluateQuizSubmission to accept a quizExercise parameter.
.../service/quiz/QuizResultService.java New file for handling quiz evaluations and updating statistics.
.../service/quiz/QuizSubmissionService.java Updated evaluateQuizSubmission to accept a QuizExercise parameter.
.../web/rest/QuizExerciseResource.java Added QuizResultService dependency and new method evaluateQuizExercise.
.../quiz/quiz-exercise-manage-buttons.component.html Added new button for evaluating quiz exercises.
.../quiz/quiz-exercise-manage-buttons.component.ts Imported necessary icons and added a method evaluateQuizExercise().
.../shared/exercise/exercise.service.ts Added a new method evaluateQuizExercise for evaluating quizzes.
.../i18n/de/quizExercise.json Added translations related to evaluating quiz exercises.
.../i18n/en/quizExercise.json Added translations related to evaluating quiz exercises.
.../exercise/quiz/QuizExerciseIntegrationTest.java Added new tests for evaluating quiz results.

Sequence Diagram(s)

sequenceDiagram
    participant UI as User Interface
    participant QERC as QuizExerciseResource
    participant QRS as QuizResultService
    participant QR as QuizExerciseRepository
    participant SPR as StudentParticipationRepository
    participant SR as SubmissionRepository
    participant RR as ResultRepository

    UI->>QERC: Evaluate Quiz Exercise
    QERC->>QRS: evaluateQuizAndUpdateStatistics(quizExerciseId)
    QRS->>QR: find(quizExerciseId)
    QR-->>QRS: QuizExercise
    QRS->>SPR: findByExerciseId(quizExerciseId)
    SPR-->>QRS: StudentParticipations
    QRS->>SR: findByExerciseId(quizExerciseId)
    SR-->>QRS: Submissions
    QRS->>RR: findResults(quizExerciseId)
    RR-->>QRS: Results
    QRS->>QERC: Calculation Complete
    QERC-->>UI: Quiz Exercise Evaluated
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between c61fd49 and f6af6d3.

Files selected for processing (2)
  • src/main/java/de/tum/in/www1/artemis/service/quiz/QuizResultService.java (1 hunks)
  • src/main/java/de/tum/in/www1/artemis/web/rest/QuizExerciseResource.java (5 hunks)
Files not reviewed due to errors (1)
  • src/main/java/de/tum/in/www1/artemis/web/rest/QuizExerciseResource.java (no review received)
Additional context used
Path-based instructions (2)
src/main/java/de/tum/in/www1/artemis/service/quiz/QuizResultService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/in/www1/artemis/web/rest/QuizExerciseResource.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

Learnings (1)
src/main/java/de/tum/in/www1/artemis/web/rest/QuizExerciseResource.java (1)
User: Hialus
PR: ls1intum/Artemis#8607
File: src/main/java/de/tum/in/www1/artemis/web/rest/programming/ProgrammingExerciseResource.java:64-64
Timestamp: 2024-06-15T20:04:18.637Z
Learning: For the Artemis project, import statements are automatically managed by formatters and should not be commented on.
Additional comments not posted (1)
src/main/java/de/tum/in/www1/artemis/service/quiz/QuizResultService.java (1)

53-63: Constructor review for dependency injection.

The constructor is well-designed, following the dependency injection pattern, which is crucial for managing dependencies cleanly and making the class easier to test. All necessary components are injected, ensuring that the class does not create or look up dependencies, adhering to the DI principles.


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.

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: 7

Outside diff range comments (1)
src/main/java/de/tum/in/www1/artemis/web/rest/QuizExerciseResource.java (1)

Line range hint 156-178: Constructor injection of QuizResultService.

The addition of QuizResultService in the constructor promotes good dependency injection practices. However, the constructor is quite large, which might indicate that this class is handling too many responsibilities. Consider breaking down this class or using a factory pattern to manage dependencies better.

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

⚠️ Unable to deploy to test servers ⚠️

The docker build needs to run through before deploying.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Jun 21, 2024
@pzdr7 pzdr7 added deploy:artemis-test1 and removed deployment-error Added by deployment workflows if an error occured labels Jun 21, 2024
@pzdr7 pzdr7 temporarily deployed to artemis-test1.artemis.cit.tum.de June 21, 2024 12:14 — with GitHub Actions Inactive
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 TS1.

I'm stuck on step 8 - deleting my latest result. The dialog doesn't seem to do anything (no error / rest calls are sent).

image

Is there another way to delete the result somehow?

@Hialus Hialus dismissed stale reviews from Jan-Thurner and JohannesStoehr June 21, 2024 16:42

Unrelated issue

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

@krusche krusche merged commit 62f8c9d into develop Jun 21, 2024
22 of 26 checks passed
@krusche krusche deleted the bugfix/fix-quiz-evaluation branch June 21, 2024 18:20
@krusche krusche changed the title Quiz exercises: Enable manual quiz evaluation for non-exam exercises Quiz exercises: Enable manual quiz evaluation for course quizzes Jun 21, 2024
@krusche krusche added this to the 7.2.3 milestone Jun 21, 2024
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!) component:Quiz ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants