diff --git a/src/main/java/de/tum/in/www1/artemis/domain/Exercise.java b/src/main/java/de/tum/in/www1/artemis/domain/Exercise.java index cbd29d41c9d8..30a5132e4eb4 100644 --- a/src/main/java/de/tum/in/www1/artemis/domain/Exercise.java +++ b/src/main/java/de/tum/in/www1/artemis/domain/Exercise.java @@ -489,10 +489,14 @@ else if (participation.getExercise() instanceof ModelingExercise || participatio * @param ignoreAssessmentDueDate defines if assessment due date is ignored for the selected results * @return the latest relevant result in the given participation, or null, if none exist */ + @Nullable public Result findLatestRatedResultWithCompletionDate(Participation participation, Boolean ignoreAssessmentDueDate) { // for most types of exercises => return latest result (all results are relevant) Result latestResult = null; // we get the results over the submissions + if (participation.getSubmissions() == null || participation.getSubmissions().isEmpty()) { + return null; + } var results = participation.getSubmissions().stream().map(Submission::getResult).filter(Objects::nonNull).collect(Collectors.toSet()); for (Result result : results) { // NOTE: for the dashboard we only use rated results with completion date diff --git a/src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizExercise.java b/src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizExercise.java index 7d90e9e2f77a..31ca1ac1d479 100644 --- a/src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizExercise.java +++ b/src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizExercise.java @@ -6,6 +6,7 @@ import java.util.*; import java.util.stream.Collectors; +import javax.annotation.Nullable; import javax.persistence.*; import org.hibernate.Hibernate; @@ -444,6 +445,7 @@ public StudentParticipation findRelevantParticipation(List } @Override + @Nullable public Result findLatestRatedResultWithCompletionDate(Participation participation, Boolean ignoreAssessmentDueDate) { if (shouldFilterForStudents()) { // results are never relevant before quiz has ended => return null @@ -452,6 +454,9 @@ public Result findLatestRatedResultWithCompletionDate(Participation participatio else { // only rated results are considered relevant Result latestRatedResult = null; + if (participation.getSubmissions() == null || participation.getSubmissions().isEmpty()) { + return null; + } // we get the results over the submissions var results = participation.getSubmissions().stream().map(Submission::getResult).filter(Objects::nonNull).collect(Collectors.toSet()); for (Result result : results) {