Search in sources :

Example 1 with QuizMode

use of de.tum.in.www1.artemis.domain.enumeration.QuizMode in project ArTEMiS by ls1intum.

the class ResultServiceIntegrationTest method testGetResultsForQuizExercise.

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
@EnumSource(QuizMode.class)
public void testGetResultsForQuizExercise(QuizMode quizMode) throws Exception {
    var now = ZonedDateTime.now();
    QuizExercise quizExercise = database.createQuiz(course, now.minusHours(5), now.minusMinutes(2), quizMode);
    quizExerciseRepository.save(quizExercise);
    for (int i = 1; i <= 10; i++) {
        QuizSubmission quizSubmission = new QuizSubmission();
        quizSubmission.setScoreInPoints(2.0);
        quizSubmission.submitted(true);
        quizSubmission.submissionDate(now.minusHours(3));
        database.addSubmission(quizExercise, quizSubmission, "student" + i);
        if (i % 3 == 0) {
            database.addResultToSubmission(quizSubmission, AssessmentType.AUTOMATIC, null, 10D, true);
        } else if (i % 4 == 0) {
            database.addResultToSubmission(quizSubmission, AssessmentType.AUTOMATIC, null, 20D, true);
        }
    }
    List<Result> results = request.getList("/api/exercises/" + quizExercise.getId() + "/results", HttpStatus.OK, Result.class);
    assertThat(results).hasSize(5);
// TODO: check additional values
}
Also used : QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with QuizMode

use of de.tum.in.www1.artemis.domain.enumeration.QuizMode in project Artemis by ls1intum.

the class ResultServiceIntegrationTest method testGetResultsForQuizExercise.

@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
@EnumSource(QuizMode.class)
public void testGetResultsForQuizExercise(QuizMode quizMode) throws Exception {
    var now = ZonedDateTime.now();
    QuizExercise quizExercise = database.createQuiz(course, now.minusHours(5), now.minusMinutes(2), quizMode);
    quizExerciseRepository.save(quizExercise);
    for (int i = 1; i <= 10; i++) {
        QuizSubmission quizSubmission = new QuizSubmission();
        quizSubmission.setScoreInPoints(2.0);
        quizSubmission.submitted(true);
        quizSubmission.submissionDate(now.minusHours(3));
        database.addSubmission(quizExercise, quizSubmission, "student" + i);
        if (i % 3 == 0) {
            database.addResultToSubmission(quizSubmission, AssessmentType.AUTOMATIC, null, 10D, true);
        } else if (i % 4 == 0) {
            database.addResultToSubmission(quizSubmission, AssessmentType.AUTOMATIC, null, 20D, true);
        }
    }
    List<Result> results = request.getList("/api/exercises/" + quizExercise.getId() + "/results", HttpStatus.OK, Result.class);
    assertThat(results).hasSize(5);
// TODO: check additional values
}
Also used : QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)2 QuizSubmission (de.tum.in.www1.artemis.domain.quiz.QuizSubmission)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2