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: Improve efficiency for deleting long manual feedback #9652

Merged
merged 4 commits into from
Nov 3, 2024

Conversation

az108
Copy link
Contributor

@az108 az108 commented Nov 2, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all 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.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and Jenkins.

Motivation and Context

Follow up #9562
While going through more refactor possibilities, I noticed a slightly more efficient implementation.

Description

I changed the flag for automatic assesements to true, allowing the updateFeedback method to skip all automatic tests instead of iterating over them aswell.

Note: The saving of manual assesements for programming exercise needs further refactoring but this is not part of this PR!

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Student
  • 1 Programming Exercise
  1. Log in to Artemis as Instructor
  2. Create a Programming Exercise
  3. Log in as Student and participate in the Programming Exercise
  4. Log in as Instructor and set the Due Date to now and set Manual Assesement
  5. Navigate to the Programming Exercise and press the View button in the TutorActions tab
  6. Press the Assesement Dashboard button
  7. Assess the Student Sumbission by creating a new Feedback with over 1000 characters
  8. Save this and reload the page
  9. Verify that the feedback box now displays the whole long feedback and no shortend version
  10. Try to edit the long feedback and save again
  11. Verify that the long feedback was changed
  12. Do this for Modelling and Quiz and Text Exercises aswell

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 even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1

Manual Tests

  • Test 1

Performance Tests

  • Test 1

Screenshots

Before:
image
After:
image

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced feedback management process for improved storage and association with results.
    • Clarified handling of feedback visibility based on assessment types and due dates.
    • Introduced new test cases for assessment and feedback mechanisms, improving coverage and accuracy, including plagiarism checks.
  • Bug Fixes

    • Resolved potential issues with feedback persistence and Hibernate exceptions.
    • Improved error handling and status code checks in assessment scenarios.
  • Refactor

    • Updated internal logic for feedback handling methods to ensure correct functionality.

@az108 az108 added the bugfix label Nov 2, 2024
@az108 az108 self-assigned this Nov 2, 2024
@az108 az108 requested a review from a team as a code owner November 2, 2024 09:32
@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) assessment Pull requests that affect the corresponding module labels Nov 2, 2024
Copy link

coderabbitai bot commented Nov 2, 2024

Walkthrough

The ResultService class has been modified to enhance feedback management processes. Key changes include updating the deleteLongFeedback method to alter the behavior of feedback updates, implementing a Hibernate workaround in storeFeedbackInResult for saving feedback, and ensuring correct addition of feedback in addFeedbackToResult. The filtering of sensitive information remains intact, with clarified handling based on assessment types and due dates. Additionally, the ModelingAssessmentIntegrationTest class has been updated with new test cases and modifications to existing tests to improve coverage of assessment and feedback scenarios.

Changes

File Path Change Summary
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java - Updated deleteLongFeedback to change updateAllFeedbackItems behavior from false to true.
- Retained logic in createNewManualResult, storeFeedbackInResult, and addFeedbackToResult while ensuring Hibernate persistence.
- Clarified handling of feedback visibility in filterSensitiveInformationIfNecessary.
src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java - Added new test methods: testOverrideAutomaticAssessment, testOverrideSubmittedManualAssessment_noConflict, testCheckPlagiarismIdenticalLongModels.
- Refined assessment logic and feedback handling in existing tests.
- Updated tests to check for appropriate HTTP status codes.

Possibly related PRs

Suggested labels

programming

Suggested reviewers

  • krusche
  • b-fein
  • JohannesStoehr
  • EneaGore
  • Malekos74

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 50510ce and cbafc5b.

📒 Files selected for processing (1)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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: 0

🧹 Outside diff range and nitpick comments (1)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1)

Line range hint 634-656: Consider optimizing the feedback list handling.

The method creates a new ArrayList unnecessarily since the list is only used once and immediately passed to updateAllFeedbackItems. Consider passing the feedbackList directly if immutability isn't required.

 public void deleteLongFeedback(List<Feedback> feedbackList, Result result) {
     if (feedbackList == null) {
         return;
     }

     List<Long> feedbackIdsWithLongText = feedbackList.stream()
         .filter(feedback -> feedback.getHasLongFeedbackText() && feedback.getId() != null)
         .map(Feedback::getId)
         .toList();
     longFeedbackTextRepository.deleteByFeedbackIds(feedbackIdsWithLongText);
-    List<Feedback> feedbacks = new ArrayList<>(feedbackList);
-    result.updateAllFeedbackItems(feedbacks, true);
+    result.updateAllFeedbackItems(feedbackList, true);
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4954074 and 9b0263f.

📒 Files selected for processing (1)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.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

🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1)

655-655: Verify the impact of enabling automatic assessment.

The change to pass true to updateAllFeedbackItems indicates that feedback updates will be treated as automatic assessments. While this may improve efficiency by bypassing test validations, ensure this doesn't bypass important validation checks or affect the feedback quality.

✅ Verification successful

Looking at the output, I can now see the implementation of updateAllFeedbackItems in Result.java and its usage across the codebase. I can generate the final response as we have enough context to understand the impact of the skipAutomaticResults parameter (previously named incorrectly as automatic in my search).

Setting skipAutomaticResults=true is correct for feedback deletion

The implementation in Result.java shows that skipAutomaticResults=true causes the method to skip processing automatic feedback items (feedback.getType() == FeedbackType.AUTOMATIC). This is the correct behavior for the deleteLongFeedback method since:

  1. It's only meant to handle manual feedback deletion
  2. Other services appropriately use false when they need to process all feedback types
  3. The change aligns with the PR's goal of making manual feedback deletion more efficient
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential validation bypasses in updateAllFeedbackItems
# Look for validation logic in the method that might be skipped

ast-grep --pattern 'updateAllFeedbackItems($_, $automatic) {
  $$$
  if (!$automatic) {
    $$$
  }
  $$$
}'

Length of output: 234


Script:

#!/bin/bash
# Let's try to find the Result class and check the updateAllFeedbackItems method implementation
rg -l "class Result" --type java

# Then let's examine the updateAllFeedbackItems method
rg "updateAllFeedbackItems" --type java -A 10

Length of output: 5329

coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 2, 2024
@github-actions github-actions bot added tests modeling Pull requests that affect the corresponding module labels Nov 2, 2024
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: 0

🧹 Outside diff range and nitpick comments (1)
src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java (1)

Line range hint 1674-1676: Avoid direct database access in tests; use service methods or mocks instead.

In the test method testdeleteResult, direct access to submissionRepository is used. According to the coding guidelines (avoid_db_access: true), tests should avoid direct database access and utilize service methods or mocks.

Consider modifying the code as follows:

- submission = submissionRepository.findOneWithEagerResultAndFeedbackAndAssessmentNote(submission.getId());
+ submission = submissionService.findOneWithEagerResultAndFeedbackAndAssessmentNote(submission.getId());

Ensure that you use the appropriate service method to interact with the submission data.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9b0263f and 50510ce.

📒 Files selected for processing (2)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java
🧰 Additional context used
📓 Path-based instructions (1)
src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

🔇 Additional comments (3)
src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java (3)

Line range hint 1017-1050: Test method testOverrideAutomaticAssessment follows coding guidelines and correctly tests the override functionality.


Line range hint 1176-1210: Test method testOverrideSubmittedManualAssessment_noConflict is well-structured and adheres to guidelines.


Line range hint 1654-1666: Test method testCheckPlagiarismIdenticalLongModels effectively tests plagiarism detection with identical models.

coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 2, 2024
JohannesWt
JohannesWt previously approved these changes Nov 2, 2024
Copy link
Contributor

@JohannesWt JohannesWt left a comment

Choose a reason for hiding this comment

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

Code 👍

@az108 az108 added this to the 7.6.5 milestone Nov 2, 2024
Jan-Thurner
Jan-Thurner previously approved these changes Nov 2, 2024
Copy link
Contributor

@Jan-Thurner Jan-Thurner left a comment

Choose a reason for hiding this comment

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

Code 👍

HawKhiem
HawKhiem previously approved these changes Nov 2, 2024
Copy link

@HawKhiem HawKhiem 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. Works as described

image

florian-glombik
florian-glombik previously approved these changes Nov 2, 2024
Copy link
Contributor

@florian-glombik florian-glombik left a comment

Choose a reason for hiding this comment

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

Approve code, we should not need to execute the automatic tests when changing manual feedback 👍

JohannesStoehr
JohannesStoehr previously approved these changes Nov 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.

Code

Copy link
Contributor

@b-fein b-fein left a comment

Choose a reason for hiding this comment

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

[Question] I want to make sure I understand the changes before this is merged, therefore marked as request changes:

Why does deleteLongFeedback now only update manual results? There can be long feedback from automatic tests. Why does this not break the result score in such cases?

I would consider me quite familiar with how programming exercises and the long feedback work in Artemis. Since the answer is not obvious to me, I would expect it is even less so for someone else in the future. Please add an inline comment in the code why we can ignore automatic results here.

@az108
Copy link
Contributor Author

az108 commented Nov 2, 2024

@b-fein The update is only necessary to reload the feedback from the database when feedback is of type “lazy fetch.” The reason we can ignore automatic results for long feedback is that, based on my analysis, this error only occurred due to incorrectly handled manual submissions. In other words, this fix is required only for manual assessments, not for automatic assessments. The method typically includes a comment stating that it should not be used for fully automatic assessments. Would you like me to add another inline comment?

@b-fein
Copy link
Contributor

b-fein commented Nov 2, 2024

The method typically includes a comment stating that it should not be used for fully automatic assessments. Would you like me to add another inline comment?

Ah, I only now have seen that the Result.updateAllFeedbackItems mentions this precondition in its Javadoc. Do you ensure, though, that deleteLongFeedback is only ever called with non-automatic results? Should there be an IllegalArgumentException in case the updateAllFeedbackItems-method is used for an automatic result to ensure this precondition cannot be violated? Since this could affect the scoring (also in exams) this might be important.

@az108
Copy link
Contributor Author

az108 commented Nov 2, 2024

@b-fein I verified that the current method is used exclusively for manual assessments. If anyone wants to use the deleteLongFeedback method in the future, they would naturally review its content and see that the updateFeedback method already includes an inline comment advising against its use for fully automatic results. However, if you still prefer, I can add another comment. I felt it was unnecessary, which is why I initially left it out.

@b-fein
Copy link
Contributor

b-fein commented Nov 2, 2024

If anyone wants to use the deleteLongFeedback method in the future, they would naturally review its content and see that the updateFeedback method already includes an inline comment advising against its use for fully automatic results.

To be honest, I don’t think they would. I would expect people to read at best the Javadoc. Since neither the method name nor the Javadoc mention any kind of limitation, that is the point where they will decide ‘Sounds good, I’ll use it’. And even if I’m assuming the worst and people look at the code, I think it’s unlikely that they will check every called method, too.

So, yes, I definitely would prefer a clear description of the precondition right after the first sentence of the Javadoc.

@krusche krusche changed the title Programming exercises: Make deleting of long manual feedback more efficient Development: Make deleting of long manual feedback more efficient Nov 3, 2024
@krusche krusche changed the title Development: Make deleting of long manual feedback more efficient Development: Improve efficiency for deleting long manual feedback Nov 3, 2024
@krusche krusche merged commit e37b846 into develop Nov 3, 2024
26 of 33 checks passed
@krusche krusche deleted the bugfix/small-delete-Long-Feedback-Adjustment branch November 3, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assessment Pull requests that affect the corresponding module bugfix modeling Pull requests that affect the corresponding module 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