diff --git a/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java b/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java index 1b037532e453..350a165409b8 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java @@ -350,7 +350,7 @@ public Course findOneWithExercisesAndLecturesAndExamsAndCompetenciesAndTutorialG course.setExercises(exerciseRepository.findByCourseIdWithCategories(course.getId())); course.setExercises(exerciseService.filterExercisesForCourse(course, user)); exerciseService.loadExerciseDetailsIfNecessary(course, user); - course.setExams(examRepository.findByCourseIdsForUser(Set.of(course.getId()), user.getId(), user.getGroups(), ZonedDateTime.now())); + course.setExams(examRepository.findByCourseIdForUser(course.getId(), user.getId(), user.getGroups(), ZonedDateTime.now())); // TODO: in the future, we only want to know if lectures exist, the actual lectures will be loaded when the user navigates into the lecture course.setLectures(lectureService.filterVisibleLecturesWithActiveAttachments(course, course.getLectures(), user)); // NOTE: in this call we only want to know if competencies exist in the course, we will load them when the user navigates into them diff --git a/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamRepository.java b/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamRepository.java index 429ce9b91e39..a884ed754e4a 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamRepository.java @@ -56,30 +56,30 @@ public interface ExamRepository extends ArtemisJpaRepository { List findByCourseIdWithExerciseGroupsAndExercises(@Param("courseId") long courseId); /** - * Find all exams for multiple courses that are already visible to the user (either registered, at least tutor or the exam is a test exam) + * Find all exams for a given course that are already visible to the user (either registered, at least tutor or the exam is a test exam) * - * @param courseIds set of courseIds that the exams should be retrieved + * @param courseId the course for which the exams should be retrieved * @param userId the id of the user requesting the exams * @param groupNames the groups of the user requesting the exams * @param now the current date, typically ZonedDateTime.now() * @return a set of all visible exams for the user in the provided courses */ @Query(""" - SELECT e + SELECT DISTINCT e FROM Exam e - LEFT JOIN e.examUsers registeredUsers - WHERE e.course.id IN :courseIds + LEFT JOIN e.examUsers eu + LEFT JOIN e.course c + WHERE c.id = :courseId AND e.visibleDate <= :now AND ( - registeredUsers.user.id = :userId - OR e.course.teachingAssistantGroupName IN :groupNames - OR e.course.editorGroupName IN :groupNames - OR e.course.instructorGroupName IN :groupNames + eu.user.id = :userId + OR c.teachingAssistantGroupName IN :groupNames + OR c.editorGroupName IN :groupNames + OR c.instructorGroupName IN :groupNames OR e.testExam = TRUE ) """) - Set findByCourseIdsForUser(@Param("courseIds") Set courseIds, @Param("userId") long userId, @Param("groupNames") Set groupNames, - @Param("now") ZonedDateTime now); + Set findByCourseIdForUser(@Param("courseId") Long courseId, @Param("userId") long userId, @Param("groupNames") Set groupNames, @Param("now") ZonedDateTime now); @Query(""" SELECT new de.tum.cit.aet.artemis.core.dto.CourseContentCount( diff --git a/src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java index 62bc019b38a8..95b620850ddd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java @@ -253,7 +253,7 @@ public void handleEvent(IrisExerciseChatSessionService service) { } - @Test() + @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void testShouldNotFireProgressStalledEventWithEventDisabled() { // Find settings for the current exercise diff --git a/src/test/java/de/tum/cit/aet/artemis/programming/aelous/AeolusTemplateResourceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/aelous/AeolusTemplateResourceTest.java index 8219e383912d..3c82d8858409 100644 --- a/src/test/java/de/tum/cit/aet/artemis/programming/aelous/AeolusTemplateResourceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/aelous/AeolusTemplateResourceTest.java @@ -56,7 +56,7 @@ void testGetAeolusTemplateFile(String templateKey, Integer expectedScriptActions assertWindfileIsCorrect(windfile, expectedScriptActions); } - @Test() + @Test void testInvalidWindfileDeserialization() { try { String invalidWindfile = """ @@ -82,7 +82,7 @@ void testInvalidWindfileDeserialization() { } } - @Test() + @Test void testValidWindfileDeserializationWithClass() throws JsonProcessingException { String validWindfile = """ { @@ -117,7 +117,7 @@ void testValidWindfileDeserializationWithClass() throws JsonProcessingException assertThat(windfile.getActions().getFirst()).isInstanceOf(ScriptAction.class); } - @Test() + @Test void testValidWindfileWithInvalidAction() { // NOTE: the misspellings are intended String invalidWindfile = """