From 9b0263f77511fccc865e3f2a3417cc996a911093 Mon Sep 17 00:00:00 2001 From: aniruddhzaveri Date: Sat, 2 Nov 2024 10:27:36 +0100 Subject: [PATCH 1/4] efficient --- .../tum/cit/aet/artemis/assessment/service/ResultService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java index 14b4b02c259b..520cf8ee20e8 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java @@ -650,10 +650,8 @@ public void deleteLongFeedback(List feedbackList, Result result) { } List feedbackIdsWithLongText = feedbackList.stream().filter(feedback -> feedback.getHasLongFeedbackText() && feedback.getId() != null).map(Feedback::getId).toList(); - longFeedbackTextRepository.deleteByFeedbackIds(feedbackIdsWithLongText); - List feedbacks = new ArrayList<>(feedbackList); - result.updateAllFeedbackItems(feedbacks, false); + result.updateAllFeedbackItems(feedbacks, true); } } From c6633472afd76fadebc5e2d2c45f5d11d49019c1 Mon Sep 17 00:00:00 2001 From: aniruddhzaveri Date: Sat, 2 Nov 2024 10:32:51 +0100 Subject: [PATCH 2/4] efficient --- .../de/tum/cit/aet/artemis/assessment/service/ResultService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java index 520cf8ee20e8..8eb9936cb5de 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java @@ -648,7 +648,6 @@ public void deleteLongFeedback(List feedbackList, Result result) { if (feedbackList == null) { return; } - List feedbackIdsWithLongText = feedbackList.stream().filter(feedback -> feedback.getHasLongFeedbackText() && feedback.getId() != null).map(Feedback::getId).toList(); longFeedbackTextRepository.deleteByFeedbackIds(feedbackIdsWithLongText); List feedbacks = new ArrayList<>(feedbackList); From 50510ce7936db6879e15754108e70d21d8d80a51 Mon Sep 17 00:00:00 2001 From: aniruddhzaveri Date: Sat, 2 Nov 2024 10:49:28 +0100 Subject: [PATCH 3/4] server tests --- .../artemis/modeling/ModelingAssessmentIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java index 24b48fb8761e..75891a12ea59 100644 --- a/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java @@ -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(); } From cbafc5bd8ae548afc17f0f846b1408b8fde105a1 Mon Sep 17 00:00:00 2001 From: aniruddhzaveri Date: Sun, 3 Nov 2024 09:49:20 +0100 Subject: [PATCH 4/4] inline comment added from b.fein review --- .../tum/cit/aet/artemis/assessment/service/ResultService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java index 8eb9936cb5de..21cfc87c6c31 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java @@ -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. *

* This approach reduces the need for individual deletion calls and performs batch deletion in a single database operation. + *

+ * **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.