Skip to content

Commit

Permalink
Quiz exercises: Disable practice mode for imported exercises (#9683)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hialus authored Nov 7, 2024
1 parent fdc2501 commit b42126a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ private QuizExercise copyQuizExerciseBasis(QuizExercise importedExercise) {
newExercise.setRandomizeQuestionOrder(importedExercise.isRandomizeQuestionOrder());
newExercise.setAllowedNumberOfAttempts(importedExercise.getAllowedNumberOfAttempts());
newExercise.setRemainingNumberOfAttempts(importedExercise.getRemainingNumberOfAttempts());
newExercise.setIsOpenForPractice(importedExercise.isIsOpenForPractice());
// The new exercise should not immediately be open for practice
newExercise.setIsOpenForPractice(false);
newExercise.setQuizMode(importedExercise.getQuizMode());
newExercise.setDuration(importedExercise.getDuration());
return newExercise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ void testUpdateQuizExerciseWithNotificationText() throws Exception {
void importQuizExerciseToSameCourse() throws Exception {
ZonedDateTime now = ZonedDateTime.now();
QuizExercise quizExercise = quizExerciseUtilService.createQuiz(now.plusHours(2), null, QuizMode.SYNCHRONIZED);
quizExercise.setIsOpenForPractice(true);
quizExerciseService.handleDndQuizFileCreation(quizExercise,
List.of(new MockMultipartFile("files", "dragItemImage2.png", MediaType.IMAGE_PNG_VALUE, "dragItemImage".getBytes()),
new MockMultipartFile("files", "dragItemImage4.png", MediaType.IMAGE_PNG_VALUE, "dragItemImage".getBytes())));
Expand All @@ -1261,6 +1262,7 @@ void importQuizExerciseToSameCourse() throws Exception {
.isEqualTo(quizExercise.getCourseViaExerciseGroupOrCourseMember().getId());
assertThat(importedExercise.getCourseViaExerciseGroupOrCourseMember()).isEqualTo(quizExercise.getCourseViaExerciseGroupOrCourseMember());
assertThat(importedExercise.getQuizQuestions()).as("Imported exercise has same number of questions").hasSameSizeAs(quizExercise.getQuizQuestions());
assertThat(importedExercise.isIsOpenForPractice()).as("Imported exercise is not open for practice").isFalse();
}

/**
Expand Down

0 comments on commit b42126a

Please sign in to comment.