Skip to content

Commit

Permalink
Exam mode: Make sure to lock programming exercise repositories in tes…
Browse files Browse the repository at this point in the history
…t exam submission
  • Loading branch information
Stephan Krusche committed Feb 12, 2023
1 parent e29d6e7 commit 5fcf725
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,17 @@ public Optional<Submission> prepareProgrammingSubmission(Optional<Submission> la
return latestSubmission;
}

private void lockStudentRepositories(User currentUser, StudentExam existingStudentExam) {
// Only lock programming exercises when the student submitted early. Otherwise, the lock operations were already scheduled/executed.
if (existingStudentExam.getIndividualEndDate() != null && ZonedDateTime.now().isBefore(existingStudentExam.getIndividualEndDate())) {
private void lockStudentRepositories(User currentUser, StudentExam studentExam) {
// Only lock programming exercises when the student submitted early in real exams. Otherwise, the lock operations were already scheduled/executed.
// Always lock test exams since there is no locking operation scheduled (also see StudentExamService:457)
if (studentExam.getExam().isTestExam() || (studentExam.getIndividualEndDate() != null && ZonedDateTime.now().isBefore(studentExam.getIndividualEndDate()))) {
// Use the programming exercises in the DB to lock the repositories (for safety)
for (Exercise exercise : existingStudentExam.getExercises()) {
if (exercise instanceof ProgrammingExercise) {
for (Exercise exercise : studentExam.getExercises()) {
if (exercise instanceof ProgrammingExercise programmingExercise) {
try {
log.debug("lock student repositories for {}", currentUser);
ProgrammingExerciseStudentParticipation participation = programmingExerciseParticipationService.findStudentParticipationByExerciseAndStudentId(exercise,
currentUser.getLogin());
programmingExerciseParticipationService.lockStudentRepository((ProgrammingExercise) exercise, participation);
var participation = programmingExerciseParticipationService.findStudentParticipationByExerciseAndStudentId(programmingExercise, currentUser.getLogin());
programmingExerciseParticipationService.lockStudentRepository(programmingExercise, participation);
}
catch (Exception e) {
log.error("Locking programming exercise {} submitted manually by {} failed", exercise.getId(), currentUser.getLogin(), e);
Expand Down

0 comments on commit 5fcf725

Please sign in to comment.