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

Development: Merge exercise details calls into one DTO #8712

Merged
merged 20 commits into from
Jun 21, 2024

Conversation

julian-christl
Copy link
Member

@julian-christl julian-christl commented Jun 2, 2024

Checklist

General

Server

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.

Motivation and Context

When loading the exercise details, many different calls get executed aside of the main call. We can simplify this in one call and improve the performance.

Description

Because converting the whole call into a full DTO is more complex and we have to make certain decisions beforehand, we decided to use a Wrapper DTO, which functions similarly to the separate calls but without the separate calls.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Course with Iris activated
  1. Create a programming exercise with a submission policy
  2. Create some Exercise hints by clicking on "Hints" in the exercise overview and generating some or creating them manually.
  3. Participate in the exercise with all participants (one student should reach the submission policy threshold)
  4. Exercise Hints should be displayed as expected.
  5. Conduct plagiarism checks (make sure to choose values that create a plagiarism case
  6. Once the student(s) are notified, check the student's exercise view and ensure that everything is displayed as expected: Iris, plagiarism, results.

Feel free to test more, but since I have not yet converted the exercise entity to a DTO, it contains the very same information as before (apart from an additional submission policy).

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

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
IrisSettingsService.java 79.4%
PlagiarismCaseService.java 92.3%
ExerciseResource.java 94.78%
PlagiarismCaseResource.java 94.3%
exercise.service.ts 91.71%
course-exercise-details.component.ts 98.82%

Summary by CodeRabbit

  • New Features

    • Introduced a new data transfer object (DTO) ExerciseDetailsDTO to encapsulate exercise details along with related settings and hints.
    • Added a method to fetch plagiarism case information for a specific exercise and user.
  • Enhancements

    • Improved retrieval of exercise details by integrating submission policies, hints, and plagiarism case information.
    • Simplified logic for displaying minimal settings based on user roles in programming exercises.
  • Bug Fixes

    • Corrected assignment of exercise properties in Angular components to ensure accurate data handling.
  • Refactor

    • Updated various services and components to use ExerciseDetailsDTO for handling exercise details more comprehensively.

@julian-christl julian-christl self-assigned this Jun 2, 2024
@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 2, 2024
Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

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

Some intermediate feedback:

@julian-christl julian-christl force-pushed the chore/exercises/optimize-exercise-details-load branch from 76af83a to 2cb7570 Compare June 4, 2024 19:57
@julian-christl julian-christl changed the title Development: Convert exercise details entity to DTO Development: Merging exercise details calls into one DTO Jun 5, 2024
@julian-christl julian-christl changed the title Development: Merging exercise details calls into one DTO Development: Merge exercise details calls into one DTO Jun 5, 2024
@julian-christl julian-christl marked this pull request as ready for review June 5, 2024 10:04
@julian-christl julian-christl requested a review from a team as a code owner June 5, 2024 10:04
Copy link

coderabbitai bot commented Jun 5, 2024

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

The changes primarily involve enhancing the retrieval of exercise details by introducing a new ExerciseDetailsDTO class, which aggregates exercise information, settings, and hints. This update impacts various components, services, and tests across both backend and frontend, ensuring consistent and comprehensive data handling. Additionally, new methods and dependencies are integrated to support these enhancements, alongside refactoring existing logic for improved clarity and performance.

Changes

File Path Change Summary
src/main/java/de/tum/in/www1/artemis/repository/ExerciseRepository.java Added a left join fetch operation for submissionPolicy in the findByIdWithDetailsForStudent method.
src/main/java/de/tum/in/www1/artemis/service/iris/settings/IrisSettingsService.java Added AuthorizationCheckService dependency and new methods to determine minimal settings display.
src/main/java/de/tum/in/www1/artemis/service/plagiarism/PlagiarismCaseService.java Introduced getPlagiarismCaseInfoForExerciseAndUser method to retrieve plagiarism case info for a student.
src/main/java/de/tum/in/www1/artemis/service/hestia/ExerciseHintService.java Updated getAvailableExerciseHints to retrieve hints once and return empty set if no hints are available.
src/main/java/de/tum/in/www1/artemis/web/rest/ExerciseResource.java Modified constructor and getExerciseDetails method to handle new DTO and related entities.
src/main/java/de/tum/in/www1/artemis/web/rest/iris/IrisSettingsResource.java Simplified logic for determining settings displayed to users using showMinimalSettings method.
src/main/java/de/tum/in/www1/artemis/web/rest/dto/ExerciseDetailsDTO.java Introduced ExerciseDetailsDTO class to encapsulate comprehensive exercise details.
src/main/webapp/app/course/learning-paths/participate/learning-path-container.component.ts Updated assignment of exercise property to use exerciseResponse.body!.exercise.
src/main/webapp/app/exercises/shared/exercise/exercise.service.ts Introduced new types and updated getExerciseDetails method to handle comprehensive exercise details.
src/main/webapp/app/overview/exercise-details/course-exercise-details.component.ts Refactored handling of exercise details, participation services, and plagiarism case information.
src/main/webapp/app/overview/exercise-details/problem-statement/problem-statement.component.ts Modified import statement and response object type in getExerciseDetails method call.
src/test/java/de/tum/in/www1/artemis/exercise/ExerciseIntegrationTest.java Updated to use ExerciseDetailsDTO for retrieving and asserting exercise details.
src/test/java/de/tum/in/www1/artemis/team/TeamIntegrationTest.java Updated exerciseWithDetails type to ExerciseDetailsDTO in testAssignedTeamIdOnExerciseForCurrentUser method.
src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java Updated to use ExerciseDetailsDTO for retrieving and asserting exercise details and student participations.
src/test/javascript/spec/component/exercises/problem-statement.component.spec.ts Modified return value structure in test for ProblemStatementComponent.
src/test/javascript/spec/service/exercise.service.spec.ts Updated ExerciseService test to handle ExerciseDetailsType and adjust exercise details handling.

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

Outside diff range comments (13)
src/main/webapp/app/exercises/shared/feedback/standalone-feedback/standalone-feedback.component.ts (1)

Line range hint 45-45: Replace the == operator with === to avoid potential issues with type coercion, ensuring strict equality checks.

- if (relevantResult.id == resultId) {
+ if (relevantResult.id === resultId) {
Tools
Biome

[error] 2-3: All these imports are only used as types. (lint/style/useImportType)

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.


[error] 4-5: All these imports are only used as types. (lint/style/useImportType)

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.


[error] 5-6: All these imports are only used as types. (lint/style/useImportType)

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.


[error] 6-7: All these imports are only used as types. (lint/style/useImportType)

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.


[error] 7-8: All these imports are only used as types. (lint/style/useImportType)

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.

src/test/playwright/e2e/exam/ExamAssessment.spec.ts (6)

Line range hint 53-53: Avoid using non-null assertions. Consider using optional chaining for safer access.

- studentOneName = (await users.getUserInfo(studentOne.username, page)).name!;
+ studentOneName = (await users.getUserInfo(studentOne.username, page))?.name;

Line range hint 71-71: Avoid using non-null assertions. Consider using optional chaining for safer access.

- await examManagement.verifySubmitted(course.id!, exam.id!, studentOneName);
+ await examManagement.verifySubmitted(course.id?, exam.id?, studentOneName);

Line range hint 105-105: Avoid using non-null assertions. Consider using optional chaining for safer access.

- await login(studentOne, `/courses/${course.id}/exams/${exam.id}`);
+ await login(studentOne, `/courses/${course.id?}/exams/${exam.id?}`);

Line range hint 138-138: Avoid using non-null assertions. Consider using optional chaining for safer access.

- await examManagement.verifySubmitted(course.id!, exam.id!, studentOneName);
+ await examManagement.verifySubmitted(course.id?, exam.id?, studentOneName);

Line range hint 172-172: Avoid using non-null assertions. Consider using optional chaining for safer access.

- await login(studentOne, `/courses/${course.id}/exams/${exam.id}`);
+ await login(studentOne, `/courses/${course.id?}/exams/${exam.id?}`);

Line range hint 179-179: Avoid using non-null assertions. Consider using optional chaining for safer access.

- await examManagement.verifySubmitted(course.id!, exam.id!, studentOneName);
+ await examManagement.verifySubmitted(course.id?, exam.id?, studentOneName);
src/main/webapp/app/exercises/shared/exercise/exercise.service.ts (6)

Line range hint 31-31: Specify a more explicit type instead of any for exampleSolutionUML.

- exampleSolutionUML?: any;
+ exampleSolutionUML?: ExampleSolutionUMLType; // Define ExampleSolutionUMLType based on expected structure

Line range hint 50-50: Avoid using any for type declarations. Specify more explicit types to enhance type safety.

- exampleSolutionUML?: any;
+ exampleSolutionUML?: ExampleSolutionUMLType; // Define ExampleSolutionUMLType based on expected structure

- let exampleSolutionUML = undefined;
+ let exampleSolutionUML: ExampleSolutionUMLType | undefined = undefined;

Also applies to: 52-52


Line range hint 113-115: Consider simplifying the control flow by removing unnecessary else clauses.

- } else {
-     return true;
- }
+ return true;

Also applies to: 121-123, 226-232, 229-232


Line range hint 326-326: Use optional chaining to simplify null checks.

- if (exercise?.exerciseGroup && !exercise?.isAtLeastTutor) {
+ if (exercise?.exerciseGroup?.title && !exercise?.isAtLeastTutor) {

Line range hint 494-494: Specify an explicit type for exampleSolutionPublicationDate to avoid implicit any type.

- let exampleSolutionPublicationDate;
+ let exampleSolutionPublicationDate: dayjs.Dayjs | undefined;

Line range hint 535-535: Encapsulate the variable declaration within a block to restrict its scope to the switch case.

case ExerciseType.TEXT:
case ExerciseType.FILE_UPLOAD:
+ {
    const textOrFileUploadExercise = exercise as TextExercise & FileUploadExercise;
    if (textOrFileUploadExercise.exampleSolution) {
        exampleSolution = artemisMarkdown.safeHtmlForMarkdown(textOrFileUploadExercise.exampleSolution);
    }
+ }
break;

julian-christl and others added 2 commits June 5, 2024 12:25
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

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

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 5, 2024
@krusche krusche added this to the 7.2.3 milestone Jun 21, 2024
@krusche krusche merged commit a9bec3e into develop Jun 21, 2024
15 of 20 checks passed
@krusche krusche deleted the chore/exercises/optimize-exercise-details-load branch June 21, 2024 18:56
@coderabbitai coderabbitai bot mentioned this pull request Oct 22, 2024
20 tasks
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!) ready to merge server Pull requests that update Java code. (Added Automatically!) tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants