From c1bfa2f14fd9e12426995cebef8f00b46a30902c Mon Sep 17 00:00:00 2001 From: Aniruddh Zaveri <92953467+az108@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:22:24 +0100 Subject: [PATCH] Programming exercises: Fix an issue for grading statistics (#9779) --- .../ProgrammingExerciseGradingService.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseGradingService.java b/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseGradingService.java index 097e0db39d3c..7738b6615b2f 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseGradingService.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseGradingService.java @@ -1078,7 +1078,25 @@ private static Map categorizeStaticCodeAnalysisIssues(Result re private static void updateTestCaseMapBasedOnResultFeedback(Result result, HashMap testCaseStatsMap) { result.getFeedbacks().stream() // Filter the feedbacks to include only those that are automatic and have an assigned test case - .filter(feedback -> FeedbackType.AUTOMATIC.equals(feedback.getType()) && feedback.getTestCase() != null) + .filter(feedback -> { + if (!FeedbackType.AUTOMATIC.equals(feedback.getType())) { + return false; + } + if (feedback.getTestCase() == null) { + return false; + } + if (feedback.getTestCase().getTestName() == null) { + // Log the feedback id with null test name to analyse NullPointer issue if it occurs again in the future + log.warn("Feedback with ID {} has a test case with a null test name.", feedback.getId()); + return false; + } + if (feedback.isPositive() == null) { + // Log the feedback with null isPositive value to analyse NullPointer issue if it occurs again in the future + log.warn("Feedback with ID {} has a test case with a null isPositive value.", feedback.getId()); + return false; + } + return true; + }) // Collect the filtered feedbacks into a map grouped by test case name, and partitioned by whether the feedback is positive .collect(Collectors.groupingBy( // Group by the name of the test case associated with the feedback