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

Assessment: Keep long feedback after saving an assessment #10090

Merged
merged 8 commits into from
Jan 5, 2025

Conversation

chrisknedl
Copy link
Contributor

@chrisknedl chrisknedl commented Jan 1, 2025

Big thanks to @az108 for helping me with the issue!

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 documented the Java code using JavaDoc style.

Motivation and Context

When starting an assessment, a new semi-automatic result is created with copies of all the feedbacks from the automatic one. At first, these feedbacks are connected to their long feedback texts if they exist. After saving an assessment, those connections are removed, and after a page reload which clears the cached variables in the client, the long feedback texts are gone.

Description

Long feedback texts are now connected to their associated feedbacks when the latter are saved.

Steps for Testing

Prerequisites:

  • 1 Tutor
  • 1 programming exercise with manual assessment enabled and at least with one long feedback text
    Easy way to get a long feedback text: Create a Java programming exercise, and inside the test repository, go to the 'SortingExampleBehaviorTest' class. Replace line 48 with
fail("abc".repeat(5000));

If you now create an assignment repository, this should produce a long feedback text in the corresponding test case.

  1. After having created an assignment repo, make sure the due date of the exercise has passed.
  2. Go to the assessment dashboard and start an assessment of the assignment repo you just created.
  3. View the latest build result (Click on 0%, 0 of 13 passed, 0 points (*some time* ago) on the top right of the assessment view). One feedback should start with > (See more). Click on that, it should show the whole feedback text.
  4. Create a new feedback, either inline or unreferenced, so that you can save.
  5. Save the assessment and reload the page.
  6. Check the feedbacks again on the top right. The long feedback should still be expandable and contain the whole text.

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

Test Coverage

Screenshots

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced long feedback text handling in assessment services.
    • Added a method for deleting feedback entries in the feedback repository.
  • Tests

    • Introduced parameterized tests for verifying long feedback management.
    • Added new test methods to improve coverage of assessment feedback scenarios.
  • Refactor

    • Streamlined feedback persistence logic in assessment services.
    • Removed unnecessary code related to long feedback text handling.

@chrisknedl chrisknedl self-assigned this Jan 1, 2025
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) assessment Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module labels Jan 1, 2025
@b-fein b-fein added the bugfix label Jan 2, 2025
@b-fein b-fein self-requested a review January 2, 2025 09:58
@chrisknedl chrisknedl marked this pull request as ready for review January 2, 2025 13:19
@chrisknedl chrisknedl requested a review from a team as a code owner January 2, 2025 13:19
Copy link

coderabbitai bot commented Jan 2, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 pmd (7.8.0)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java

The following rules are missing or misspelled in your ruleset file category/vm/bestpractices.xml: BooleanInstantiation, DontImportJavaLang, DuplicateImports, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveMethodLength, ImportFromSamePackage, MissingBreakInSwitch, SimplifyBooleanAssertion. Please check your ruleset configuration.

Walkthrough

The pull request introduces modifications to the handling of long feedback texts in the Artemis assessment system. Changes are primarily focused on the ResultService and ProgrammingAssessmentService classes, with corresponding updates to integration tests. The modifications improve the management of long feedback during assessment persistence, ensuring proper connection and deletion of existing long feedback to prevent duplicate entries and maintain data integrity.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java Modified handleFeedbackPersistence method to improve long feedback text handling, ensuring proper connection and deletion of existing long feedback.
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java Removed line that deleted long feedback text in saveAndSubmitManualAssessment method, allowing retention of long feedback.
src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationIndependentTest.java Added LongFeedbackTextRepository as an autowired field.
src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.java Added two new parameterized test methods for long feedback handling:
- shouldKeepExistingLongFeedbackWhenSavingAnAssessment
- shouldUpdateUnreferencedLongFeedbackWhenSavingAnAssessment.
src/main/java/de/tum/cit/aet/artemis/assessment/repository/LongFeedbackTextRepository.java Added new method deleteByFeedbackId(final Long feedbackId) for deleting feedback entries.

Possibly related PRs

Suggested Labels

ready to merge

Suggested Reviewers

  • az108
  • dmytropolityka
  • krusche
  • eceeeren
  • florian-glombik

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 822aa48 and 0e90aeb.

📒 Files selected for processing (1)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.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

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (3)
src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1)

525-525: Clarify comment on reattaching old long feedback text.

The comment explains connecting old long feedback text before the entity is saved. Consider adding more context or logging to clarify scenarios in which this logic is triggered, for easier debugging.

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.java (2)

557-575: Coverage for existing long feedback retention.

This new parameterized test effectively checks if the existing long feedback remains intact across submission boundaries. Consider adding a negative test scenario (e.g., feedback with no content) or an edge case test for extremely large feedback text to ensure coverage of boundary conditions.


577-603: Reflection-based approach for rewriting feedback field.

Manually setting detailText via reflection can make the test less robust to internal refactorings. If feasible, prefer a standard setter or a dedicated test utility method to maintain clarity and stability. The rest of the test logic effectively verifies the updated state in the database.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd1813 and bc0851e.

📒 Files selected for processing (4)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java (0 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationIndependentTest.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.java (2 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingAssessmentService.java
🧰 Additional context used
📓 Path-based instructions (3)
src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationIndependentTest.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

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

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.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 (5)
src/test/java/de/tum/cit/aet/artemis/programming/AbstractProgrammingIntegrationIndependentTest.java (2)

6-6: Import addition looks appropriate.

Adding the import for LongFeedbackTextRepository aligns well with the new autowired field usage. Ensure the repository is necessary in this abstract test class and confirm that usage is not duplicated across multiple test classes.


128-129: Check usage of newly-added repository field.

Marking longFeedbackTextRepository as protected in this abstract test is consistent with other repository fields. Verify that all subclasses correctly utilize and mock the repository where necessary, as direct database access in integration tests can slow down the test suite. Consider verifying that it adheres to the project’s "avoid_db_access" principle for certain test types if applicable.

src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (2)

527-536: Ensure robust handling of mismatch scenarios.

If feedback.getHasLongFeedbackText() is true but feedback.getLongFeedback() is empty, the code deletes the old entry when changes are detected or reattaches if empty. Confirm that this does not inadvertently remove still-needed data if the client incorrectly reports an empty or missing text. A short additional verification, such as checking content length or a final check after the repository deletion, may help avoid unintentional data loss.


543-543: Restore association is correct.

Re-establishing feedbackresult references after saving is typical in JPA-based systems to prevent lazy-loading or cascade issues. The approach is consistent.

src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.java (1)

22-23: JUnit5 parameterized imports are good.

Using @ParameterizedTest and @ValueSource can streamline repetitive test logic. Ensure consistent usage across the file to enhance coverage for different inputs.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 2, 2025
@b-fein b-fein requested a review from az108 January 2, 2025 13:24
az108
az108 previously approved these changes Jan 2, 2025
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.

Issue discussed with @chrisknedl. Code LGTM and tested locally, the described bug no longer exists. Thanks a lot for helping out with this issue! 👍 :)

@chrisknedl chrisknedl dismissed stale reviews from az108 and coderabbitai[bot] via 822aa48 January 2, 2025 15:11
@chrisknedl chrisknedl requested review from az108 and b-fein January 2, 2025 15:12
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.

Code looks good.

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

github-actions bot commented Jan 5, 2025

⚠️ 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 Jan 5, 2025
Copy link
Member

@krusche krusche left a comment

Choose a reason for hiding this comment

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

Code looks good 👍

@krusche krusche merged commit ec1f0df into develop Jan 5, 2025
25 of 31 checks passed
@krusche krusche deleted the bugfix/assessment/missing-long-feedback branch January 5, 2025 19:53
@krusche krusche added this to the 7.8.2 milestone Jan 5, 2025
@krusche krusche added ready to merge maintainer-approved The feature maintainer has approved the PR and removed deployment-error Added by deployment workflows if an error occured labels Jan 5, 2025
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 maintainer-approved The feature maintainer has approved the PR programming Pull requests that affect the corresponding module ready for review ready to merge server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

8 participants