Skip to content

Commit

Permalink
Exam mode: Only send student notifications when end time has changed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aplr authored Nov 10, 2023
1 parent 7b5fd8d commit c104b9f
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 193 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.tum.in.www1.artemis.repository;

import java.util.List;
import java.util.*;

import javax.transaction.Transactional;

Expand Down Expand Up @@ -32,6 +32,20 @@ public interface ExamLiveEventRepository extends JpaRepository<ExamLiveEvent, Lo
""")
List<ExamLiveEvent> findAllByStudentExamIdOrGlobalByExamId(@Param("examId") Long examId, @Param("studentExamId") Long studentExamId);

/**
* Find all events for the given student exam in reverse creation order.
*
* @param studentExamId the id of the student exam
* @return a list of events
*/
@Query("""
SELECT event
FROM ExamLiveEvent event
WHERE event.studentExamId = :studentExamId
ORDER BY event.id DESC
""")
List<ExamLiveEvent> findAllByStudentExamId(@Param("studentExamId") Long studentExamId);

/**
* Delete all events for the given exam.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Set;
import java.util.*;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;

import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
Expand All @@ -29,10 +26,7 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import de.tum.in.www1.artemis.domain.Commit;
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.domain.VcsRepositoryUrl;
import de.tum.in.www1.artemis.domain.*;
import de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseParticipation;
import de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation;
import de.tum.in.www1.artemis.exception.localvc.LocalVCInternalException;
Expand Down Expand Up @@ -321,6 +315,5 @@ public ZonedDateTime getPushDate(ProgrammingExerciseParticipation participation,
catch (IOException e) {
throw new LocalVCInternalException("Unable to get the push date from participation " + participation.getId() + ": " + participation.getRepositoryUrl(), e);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public ResponseEntity<Exam> updateExam(@PathVariable Long courseId, @RequestBody
}

// NOTE: if the end date was changed, we need to update student exams and re-schedule exercises
if (!originalExam.getEndDate().equals(savedExam.getEndDate())) {
if (comparator.compare(originalExam.getEndDate(), savedExam.getEndDate()) != 0) {
int workingTimeChange = savedExam.getDuration() - originalExamDuration;
updateStudentExamsAndRescheduleExercises(examWithExercises, originalExamDuration, workingTimeChange);
}
Expand Down
5 changes: 1 addition & 4 deletions src/test/java/de/tum/in/www1/artemis/exam/ExamFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import static java.time.ZonedDateTime.now;

import java.time.ZonedDateTime;
import java.util.HashSet;
import java.util.Set;
import java.util.*;

import de.tum.in.www1.artemis.domain.Course;
import de.tum.in.www1.artemis.domain.exam.*;
Expand Down Expand Up @@ -136,7 +135,6 @@ private static Exam generateExamHelper(Course course, boolean testExam, String c
*
* @param mandatory if the exercise group is mandatory
* @param exam the exam that this exercise group should be added to
*
* @return the newly created exercise
*/
public static ExerciseGroup generateExerciseGroup(boolean mandatory, Exam exam) {
Expand All @@ -149,7 +147,6 @@ public static ExerciseGroup generateExerciseGroup(boolean mandatory, Exam exam)
* @param mandatory if the exercise group is mandatory
* @param exam the exam that this exercise group should be added to
* @param title title of the exercise group
*
* @return the newly created exercise
*/
public static ExerciseGroup generateExerciseGroupWithTitle(boolean mandatory, Exam exam, String title) {
Expand Down
Loading

0 comments on commit c104b9f

Please sign in to comment.