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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ public long getMaxCountForExercise(long exerciseId) {
* overridden or updated. The deletion is performed only for feedback items with a non-null ID and an associated long feedback text.
* <p>
* This approach reduces the need for individual deletion calls and performs batch deletion in a single database operation.
* <p>
* **Note:** This method should only be used for manually assessed submissions, not for fully automatic assessments, due to its dependency on the
* {@link Result#updateAllFeedbackItems} method, which is designed for manual feedback management. Using this method with automatic assessments could
* lead to unintended behavior or data inconsistencies.
*
* @param feedbackList The list of {@link Feedback} objects for which the long feedback texts are to be deleted. Only feedback items that have long feedback texts and a
* non-null ID will be processed.
Expand All @@ -648,12 +652,9 @@ 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, false);
result.updateAllFeedbackItems(feedbacks, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ void testOverrideAutomaticAssessment() throws Exception {
});
assertThat(storedResult.getAssessmentType()).as("type of result is SEMI_AUTOMATIC").isEqualTo(AssessmentType.SEMI_AUTOMATIC);
assertThat(manualFeedback).as("number of manual feedback elements is correct").hasSameSizeAs(newFeedback);
assertThat(automaticFeedback).as("number of automatic feedback elements is correct").hasSize(existingFeedback.size() - 2);
assertThat(adaptedFeedback).as("number of adapted feedback elements is correct").hasSize(2);
assertThat(automaticFeedback).as("number of automatic feedback elements is correct").hasSize(existingFeedback.size());
assertThat(adaptedFeedback).as("number of adapted feedback elements is correct").isEmpty();
assertThat(manualUnreferencedFeedback).as("number of manual unreferenced feedback elements is correct").isEmpty();
}

Expand Down
Loading