Search in sources :

Example 51 with QuizSubmission

use of de.tum.in.www1.artemis.domain.quiz.QuizSubmission in project ArTEMiS by ls1intum.

the class ResultServiceIntegrationTest method testGetResultsForQuizExercise.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testGetResultsForQuizExercise() throws Exception {
    var now = ZonedDateTime.now();
    QuizExercise quizExercise = database.createQuiz(course, now.minusMinutes(5), now.minusMinutes(2));
    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) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

QuizSubmission (de.tum.in.www1.artemis.domain.quiz.QuizSubmission)28 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)20 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)19 Result (de.tum.in.www1.artemis.domain.Result)17 SubmittedAnswer (de.tum.in.www1.artemis.domain.quiz.SubmittedAnswer)11 User (de.tum.in.www1.artemis.domain.User)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)8 QuizSubmissionException (de.tum.in.www1.artemis.exception.QuizSubmissionException)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)6 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)6 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)6 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)6 Test (org.junit.jupiter.api.Test)6 Submission (de.tum.in.www1.artemis.domain.Submission)4 AssessmentType (de.tum.in.www1.artemis.domain.enumeration.AssessmentType)4 InitializationState (de.tum.in.www1.artemis.domain.enumeration.InitializationState)4 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)4 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)4