diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java index 1101f94d4708..bb775298efb5 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java @@ -59,7 +59,8 @@ public interface StudentParticipationRepository extends ArtemisJpaRepository findByCourseIdWithEagerRatedResults(@Param("courseId") long courseId); @@ -69,8 +70,10 @@ public interface StudentParticipationRepository extends ArtemisJpaRepository findByCourseIdAndStudentIdWithEagerRatedResults(@Param("courseId") long courseId, @Param("studentId") long studentId); @@ -79,7 +82,8 @@ SELECT COUNT(p.id) > 0 FROM StudentParticipation p LEFT JOIN p.team.students ts WHERE p.exercise.course.id = :courseId - AND (p.student.id = :studentId OR ts.id = :studentId) + AND (p.student.id = :studentId + OR ts.id = :studentId) """) boolean existsByCourseIdAndStudentId(@Param("courseId") long courseId, @Param("studentId") long studentId); @@ -91,7 +95,8 @@ SELECT COUNT(p.id) > 0 WHERE p.testRun = FALSE AND p.exercise.exerciseGroup.exam.id = :examId AND r.rated = TRUE - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) List findByExamIdWithEagerLegalSubmissionsRatedResults(@Param("examId") long examId); @@ -125,7 +130,8 @@ SELECT COUNT(p.id) > 0 LEFT JOIN FETCH p.submissions s WHERE p.exercise.id = :exerciseId AND p.student.login = :username - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) Optional findWithEagerLegalSubmissionsByExerciseIdAndStudentLogin(@Param("exerciseId") long exerciseId, @Param("username") String username); @@ -135,7 +141,8 @@ SELECT COUNT(p.id) > 0 LEFT JOIN FETCH p.submissions s WHERE p.exercise.id = :exerciseId AND p.student.login = :username - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) AND p.testRun = :testRun """) Optional findWithEagerLegalSubmissionsByExerciseIdAndStudentLoginAndTestRun(@Param("exerciseId") long exerciseId, @Param("username") String username, @@ -157,7 +164,8 @@ Optional findWithEagerLegalSubmissionsByExerciseIdAndStude LEFT JOIN FETCH t.students WHERE p.exercise.id = :exerciseId AND p.team.id = :teamId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) Optional findWithEagerLegalSubmissionsAndTeamStudentsByExerciseIdAndTeamId(@Param("exerciseId") long exerciseId, @Param("teamId") long teamId); @@ -175,8 +183,9 @@ SELECT COUNT(p) > 0 FROM StudentParticipation p LEFT JOIN p.team.students u LEFT JOIN p.student s - WHERE p.id = :participationId AND - (s.login = :login OR u.login = :login) + WHERE p.id = :participationId + AND (s.login = :login + OR u.login = :login) """) boolean existsByIdAndParticipatingStudentLogin(@Param("participationId") long participationId, @Param("login") String login); @@ -187,7 +196,8 @@ SELECT COUNT(p) > 0 LEFT JOIN FETCH s.results WHERE p.exercise.id = :exerciseId AND p.testRun = :testRun - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) List findByExerciseIdAndTestRunWithEagerLegalSubmissionsResult(@Param("exerciseId") long exerciseId, @Param("testRun") boolean testRun); @@ -235,7 +245,10 @@ Optional findByExerciseIdAndStudentIdAndTestRunWithEagerSu LEFT JOIN FETCH r.assessmentNote WHERE p.exercise.id = :exerciseId AND ( - r.id = (SELECT MAX(p_r.id) FROM p.results p_r) + r.id = ( + SELECT MAX(p_r.id) + FROM p.results p_r + ) OR r.assessmentType <> de.tum.cit.aet.artemis.assessment.domain.AssessmentType.AUTOMATIC OR r IS NULL ) @@ -260,29 +273,16 @@ Optional findByExerciseIdAndStudentIdAndTestRunWithEagerSu LEFT JOIN FETCH t.students WHERE p.exercise.id = :exerciseId AND ( - r.id = (SELECT MAX(p_r.id) FROM p.results p_r) + r.id = ( + SELECT MAX(p_r.id) + FROM p.results p_r + ) OR r.assessmentType <> de.tum.cit.aet.artemis.assessment.domain.AssessmentType.AUTOMATIC OR r IS NULL ) """) Set findByExerciseIdWithLatestAndManualResultsWithTeamInformation(@Param("exerciseId") long exerciseId); - @Query(""" - SELECT DISTINCT p - FROM StudentParticipation p - LEFT JOIN FETCH p.results r - LEFT JOIN FETCH r.submission s - LEFT JOIN FETCH p.submissions - LEFT JOIN FETCH r.assessmentNote - WHERE p.exercise.id = :exerciseId - AND ( - r.id = (SELECT MAX(p_r.id) FROM p.results p_r WHERE p_r.rated = TRUE) - OR r.assessmentType <> de.tum.cit.aet.artemis.assessment.domain.AssessmentType.AUTOMATIC - OR r IS NULL - ) - """) - Set findByExerciseIdWithLatestAndManualRatedResultsAndAssessmentNote(@Param("exerciseId") long exerciseId); - @Query(""" SELECT DISTINCT p FROM StudentParticipation p @@ -292,7 +292,11 @@ Optional findByExerciseIdAndStudentIdAndTestRunWithEagerSu AND p.testRun = :testRun AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) AND r.assessmentType <> de.tum.cit.aet.artemis.assessment.domain.AssessmentType.AUTOMATIC - AND r.id = (SELECT MAX(r2.id) FROM p.results r2 WHERE r2.completionDate IS NOT NULL) + AND r.id = ( + SELECT MAX(r2.id) + FROM p.results r2 + WHERE r2.completionDate IS NOT NULL + ) """) Set findByExerciseIdAndTestRunWithEagerLegalSubmissionsAndLatestResultWithCompletionDate(@Param("exerciseId") long exerciseId, @Param("testRun") boolean testRun); @@ -343,16 +347,14 @@ default List findByExerciseIdWithLatestAutomaticResultAndF LEFT JOIN FETCH f.testCase LEFT JOIN FETCH r.submission s WHERE p.id = :participationId - AND (r.id = ( + AND r.id = ( SELECT MAX(pr.id) FROM p.results pr LEFT JOIN pr.submission prs WHERE pr.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.AUTOMATIC - AND ( - prs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL - OR prs.type IS NULL - ) - )) + AND (prs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR prs.type IS NULL) + ) """) Optional findByIdWithLatestAutomaticResultAndFeedbacksAndTestCases(@Param("participationId") long participationId); @@ -366,10 +368,8 @@ SELECT MAX(pr.id) LEFT JOIN FETCH r.submission s WHERE p.exercise.id = :exerciseId AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) - AND ( - r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.MANUAL - OR r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.SEMI_AUTOMATIC - ) + AND (r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.MANUAL + OR r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.SEMI_AUTOMATIC) """) List findByExerciseIdWithManualResultAndFeedbacksAndTestCases(@Param("exerciseId") long exerciseId); @@ -385,11 +385,10 @@ default List findByExerciseIdWithManualResultAndFeedbacksA LEFT JOIN FETCH f.testCase LEFT JOIN FETCH r.submission s WHERE p.id = :participationId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) - AND ( - r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.MANUAL - OR r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.SEMI_AUTOMATIC - ) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) + AND (r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.MANUAL + OR r.assessmentType = de.tum.cit.aet.artemis.assessment.domain.AssessmentType.SEMI_AUTOMATIC) """) Optional findByIdWithManualResultAndFeedbacks(@Param("participationId") long participationId); @@ -399,7 +398,8 @@ default List findByExerciseIdWithManualResultAndFeedbacksA LEFT JOIN FETCH p.submissions s WHERE p.exercise.id = :exerciseId AND p.student.id = :studentId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) List findByExerciseIdAndStudentIdWithEagerLegalSubmissions(@Param("exerciseId") long exerciseId, @Param("studentId") long studentId); @@ -427,7 +427,8 @@ default List findByExerciseIdWithManualResultAndFeedbacksA LEFT JOIN FETCH p.submissions s WHERE p.exercise.id = :exerciseId AND p.team.id = :teamId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) List findByExerciseIdAndTeamIdWithEagerLegalSubmissions(@Param("exerciseId") long exerciseId, @Param("teamId") long teamId); @@ -451,8 +452,10 @@ default List findByExerciseIdWithManualResultAndFeedbacksA LEFT JOIN FETCH t.students WHERE p.exercise.id = :exerciseId AND p.team.id = :teamId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) - AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR rs.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) + AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR rs.type IS NULL) """) List findByExerciseIdAndTeamIdWithEagerResultsAndLegalSubmissionsAndTeamStudents(@Param("exerciseId") long exerciseId, @Param("teamId") long teamId); @@ -471,7 +474,8 @@ SELECT MAX(pr.id) LEFT JOIN pr.submission prs WHERE prs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR prs.type IS NULL - ) OR r.id IS NULL) + ) + OR r.id IS NULL) """) Optional findByExerciseIdAndStudentIdAndTestRunWithLatestResult(@Param("exerciseId") long exerciseId, @Param("studentId") long studentId, @Param("testRun") boolean testRun); @@ -524,7 +528,10 @@ WHERE prs.assessmentType IN ( ) ) AND submission.submitted = TRUE - AND submission.id = (SELECT MAX(s.id) FROM p.submissions s) + AND submission.id = ( + SELECT MAX(s.id) + FROM p.submissions s + ) """) List findByExerciseIdWithLatestSubmissionWithoutManualResultsAndIgnoreTestRunParticipation(@Param("exerciseId") long exerciseId, @Param("correctionRound") long correctionRound); @@ -548,7 +555,10 @@ WHERE prs.assessmentType IN ( de.tum.cit.aet.artemis.assessment.domain.AssessmentType.SEMI_AUTOMATIC ) ) AND s.submitted = TRUE - AND s.id = (SELECT MAX(s.id) FROM p.submissions s) + AND s.id = ( + SELECT MAX(s.id) + FROM p.submissions s + ) """) List findByExerciseIdWithLatestSubmissionWithoutManualResultsWithPassedIndividualDueDateIgnoreTestRuns(@Param("exerciseId") long exerciseId, @Param("now") ZonedDateTime now); @@ -558,7 +568,8 @@ List findByExerciseIdWithLatestSubmissionWithoutManualResu FROM Participation p LEFT JOIN FETCH p.submissions s WHERE p.id = :participationId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) Optional findWithEagerLegalSubmissionsById(@Param("participationId") long participationId); @@ -593,8 +604,10 @@ List findByExerciseIdWithLatestSubmissionWithoutManualResu LEFT JOIN FETCH p.team t LEFT JOIN FETCH t.students WHERE p.id = :participationId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) - AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR rs.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) + AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR rs.type IS NULL) """) Optional findWithEagerLegalSubmissionsResultsFeedbacksById(@Param("participationId") long participationId); @@ -617,10 +630,9 @@ List findByExerciseIdWithLatestSubmissionWithoutManualResu FROM StudentParticipation p JOIN Result r ON r.participation.id = p.id WHERE p.exercise.id = :exerciseId - AND ( - p.student.firstName LIKE %:partialStudentName% - OR p.student.lastName LIKE %:partialStudentName% - ) AND r.completionDate IS NOT NULL + AND (p.student.firstName LIKE %:partialStudentName% + OR p.student.lastName LIKE %:partialStudentName%) + AND r.completionDate IS NOT NULL """) List findIdsByExerciseIdAndStudentName(@Param("exerciseId") long exerciseId, @Param("partialStudentName") String partialStudentName, Pageable pageable); @@ -632,10 +644,9 @@ SELECT COUNT(p) FROM StudentParticipation p JOIN Result r ON r.participation.id = p.id WHERE p.exercise.id = :exerciseId - AND ( - p.student.firstName LIKE %:partialStudentName% - OR p.student.lastName LIKE %:partialStudentName% - ) AND r.completionDate IS NOT NULL + AND (p.student.firstName LIKE %:partialStudentName% + OR p.student.lastName LIKE %:partialStudentName%) + AND r.completionDate IS NOT NULL """) long countByExerciseIdAndStudentName(@Param("exerciseId") long exerciseId, @Param("partialStudentName") String partialStudentName); @@ -666,8 +677,10 @@ default Page findAllWithEagerSubmissionsAndResultsByExerci LEFT JOIN FETCH p.submissions s LEFT JOIN FETCH s.results sr WHERE p.exercise.id = :exerciseId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) - AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR rs.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) + AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR rs.type IS NULL) """) List findAllWithEagerLegalSubmissionsAndEagerResultsByExerciseId(@Param("exerciseId") long exerciseId); @@ -697,12 +710,17 @@ default Page findAllWithEagerSubmissionsAndResultsByExerci LEFT JOIN FETCH p.team WHERE p.exercise.id = :exerciseId AND p.testRun = FALSE - AND s.id = (SELECT MAX(s2.id) - FROM p.submissions s2 - WHERE s2.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s2.type IS NULL) - AND r.id = (SELECT MAX(r2.id) - FROM s.results r2 - WHERE r2.rated = TRUE) + AND s.id = ( + SELECT MAX(s2.id) + FROM p.submissions s2 + WHERE s2.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s2.type IS NULL + ) + AND r.id = ( + SELECT MAX(r2.id) + FROM s.results r2 + WHERE r2.rated = TRUE + ) """) List findAllForPlagiarism(@Param("exerciseId") long exerciseId); @@ -713,7 +731,8 @@ default Page findAllWithEagerSubmissionsAndResultsByExerci LEFT JOIN FETCH s.results r WHERE p.student.id = :studentId AND p.exercise IN :exercises - AND (p.testRun = FALSE OR :includeTestRuns = TRUE) + AND (p.testRun = FALSE + OR :includeTestRuns = TRUE) """) Set findByStudentIdAndIndividualExercisesWithEagerSubmissionsResult(@Param("studentId") long studentId, @Param("exercises") Collection exercises, @Param("includeTestRuns") boolean includeTestRuns); @@ -786,7 +805,8 @@ List findTestRunParticipationsByStudentIdAndIndividualExer LEFT JOIN FETCH t.students teamStudent WHERE teamStudent.id = :studentId AND p.exercise IN :exercises - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) Set findByStudentIdAndTeamExercisesWithEagerLegalSubmissionsResult(@Param("studentId") long studentId, @Param("exercises") Collection exercises); @@ -799,7 +819,8 @@ Set findByStudentIdAndTeamExercisesWithEagerLegalSubmissio LEFT JOIN FETCH p.team t WHERE p.exercise.course.id = :courseId AND t.shortName = :teamShortName - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) """) List findAllByCourseIdAndTeamShortNameWithEagerLegalSubmissionsResult(@Param("courseId") long courseId, @Param("teamShortName") String teamShortName); @@ -831,7 +852,8 @@ SELECT p.id, COUNT(s) LEFT JOIN p.submissions s WHERE p.team.shortName = :teamShortName AND p.exercise.course.id = :courseId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL + OR s.type IS NULL) GROUP BY p.id """) List countLegalSubmissionsPerParticipationByCourseIdAndTeamShortName(@Param("courseId") long courseId, @Param("teamShortName") String teamShortName); @@ -850,7 +872,8 @@ AND EXISTS ( FROM p.submissions s1 WHERE s1.participation.id = p.id AND s1.submitted = TRUE - AND (r.assessor = :assessor OR r.assessor.id IS NULL) + AND (r.assessor = :assessor + OR r.assessor.id IS NULL) ) """) List findAllByParticipationExerciseIdAndResultAssessorAndCorrectionRoundIgnoreTestRuns(@Param("exerciseId") long exerciseId, diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/web/ParticipationResource.java b/src/main/java/de/tum/cit/aet/artemis/exercise/web/ParticipationResource.java index 4d549bb3fe66..b56b2df2aed9 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/web/ParticipationResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/web/ParticipationResource.java @@ -66,7 +66,6 @@ import de.tum.cit.aet.artemis.core.service.messaging.InstanceMessageSendService; import de.tum.cit.aet.artemis.core.util.HeaderUtil; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.domain.ExerciseType; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; @@ -595,9 +594,7 @@ public ResponseEntity> updateParticipationDueDates(@P } private Set findParticipationWithLatestResults(Exercise exercise) { - if (exercise.getExerciseType() == ExerciseType.QUIZ) { - return studentParticipationRepository.findByExerciseIdWithLatestAndManualRatedResultsAndAssessmentNote(exercise.getId()); - } + // TODO: we should reduce the amount of data fetched here and sent to the client, because submissions and results are not used at all if (exercise.isTeamMode()) { // For team exercises the students need to be eagerly fetched return studentParticipationRepository.findByExerciseIdWithLatestAndManualResultsWithTeamInformation(exercise.getId()); diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java index ffe438217b64..90d514ca4b68 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java @@ -50,7 +50,8 @@ default ProgrammingSubmission findFirstByParticipationIdAndCommitHashOrderByIdDe @Query(value = """ SELECT new de.tum.cit.aet.artemis.programming.dto.ProgrammingSubmissionIdAndSubmissionDateDTO(ps.id, ps.submissionDate) FROM ProgrammingSubmission ps - WHERE ps.participation.id = :participationId ORDER BY ps.submissionDate DESC + WHERE ps.participation.id = :participationId + ORDER BY ps.submissionDate DESC """) List findFirstIdByParticipationIdOrderBySubmissionDateDesc(@Param("participationId") long participationId, Pageable pageable); @@ -72,8 +73,8 @@ default Optional findFirstByParticipationIdWithResultsOrd if (result.isEmpty()) { return Optional.empty(); } - long id = result.getFirst().programmingSubmissionId(); - return findProgrammingSubmissionWithResultsById(id); + long submissionId = result.getFirst().programmingSubmissionId(); + return findProgrammingSubmissionWithResultsById(submissionId); } @Query(""" @@ -104,8 +105,7 @@ default Optional findFirstByParticipationIdWithResultsOrd * @return ProgrammingSubmission list (can be empty!) */ default List findGradedByParticipationIdWithResultsOrderBySubmissionDateDesc(long participationId, Pageable pageable) { - List ids = findSubmissionIdsAndDatesByParticipationId(participationId, pageable).stream().map(ProgrammingSubmissionIdAndSubmissionDateDTO::programmingSubmissionId) - .toList(); + var ids = findSubmissionIdsAndDatesByParticipationId(participationId, pageable).stream().map(ProgrammingSubmissionIdAndSubmissionDateDTO::programmingSubmissionId).toList(); if (ids.isEmpty()) { return Collections.emptyList(); diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java b/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java index be1c99c67be6..debe78f111da 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseParticipationResource.java @@ -231,12 +231,12 @@ public ResponseEntity getLatestPendingSubmission(@PathVar @GetMapping("programming-exercises/{exerciseId}/latest-pending-submissions") @EnforceAtLeastTutor public ResponseEntity>> getLatestPendingSubmissionsByExerciseId(@PathVariable Long exerciseId) { - ProgrammingExercise programmingExercise; - programmingExercise = programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationElseThrow(exerciseId); + ProgrammingExercise programmingExercise = programmingExerciseRepository.findByIdWithTemplateAndSolutionParticipationElseThrow(exerciseId); if (!authCheckService.isAtLeastTeachingAssistantForExercise(programmingExercise)) { throw new AccessForbiddenException("exercise", exerciseId); } + // TODO: this REST call is quite slow for > 100 participations. We should consider a more efficient way to get the latest pending submissions. Map> pendingSubmissions = submissionService.getLatestPendingSubmissionsForProgrammingExercise(exerciseId); // Remove unnecessary data to make response smaller (exercise, student of participation). pendingSubmissions = pendingSubmissions.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> { diff --git a/src/main/webapp/app/exercises/shared/participation/participation.component.html b/src/main/webapp/app/exercises/shared/participation/participation.component.html index c3eadf5cd3e1..27f175995eef 100644 --- a/src/main/webapp/app/exercises/shared/participation/participation.component.html +++ b/src/main/webapp/app/exercises/shared/participation/participation.component.html @@ -4,38 +4,36 @@

{{ exercise?.title }} - {{ filteredParticipationsSize }}

- @if (exercise?.type === ExerciseType.PROGRAMMING) { -
- - +
+ + + + @if (exercise.type === ExerciseType.PROGRAMMING && afterDueDate) { - @if (exercise.type === ExerciseType.PROGRAMMING && afterDueDate) { - - } -
- } + } +
@if (exercise?.type !== ExerciseType.QUIZ && exercise?.isAtLeastInstructor) {
diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationIntegrationTest.java index 8e97d56893d8..3f32fb13ca5d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationIntegrationTest.java @@ -916,7 +916,8 @@ void getAllParticipationsForExercise_withLatestResults_forQuizExercise() throws courseRepository.save(course); exerciseRepository.save(quizExercise); - var participation = participationUtilService.createAndSaveParticipationForExercise(quizExercise, TEST_PREFIX + "student1"); + final var login = TEST_PREFIX + "student1"; + var participation = participationUtilService.createAndSaveParticipationForExercise(quizExercise, login); var result1 = participationUtilService.createSubmissionAndResult(participation, 42, true); var notGradedResult = participationUtilService.addResultToParticipation(participation, result1.getSubmission()); notGradedResult.setRated(false); @@ -926,11 +927,10 @@ void getAllParticipationsForExercise_withLatestResults_forQuizExercise() throws params.add("withLatestResults", "true"); var participations = request.getList("/api/exercises/" + quizExercise.getId() + "/participations", HttpStatus.OK, StudentParticipation.class, params); - var receivedParticipationWithResult = participations.stream().filter(p -> ((User) p.getParticipant()).getLogin().equals(TEST_PREFIX + "student1")).findFirst() - .orElseThrow(); - assertThat(receivedParticipationWithResult.getResults()).containsOnly(result1); - assertThat(receivedParticipationWithResult.getSubmissions()).isEmpty(); - assertThat(receivedParticipationWithResult.getSubmissionCount()).isEqualTo(1); + var receivedParticipation = participations.stream().filter(p -> p.getParticipantIdentifier().equals(login)).findFirst().orElseThrow(); + assertThat(receivedParticipation.getResults()).containsOnly(notGradedResult); + assertThat(receivedParticipation.getSubmissions()).isEmpty(); + assertThat(receivedParticipation.getSubmissionCount()).isEqualTo(1); } @Test