Search in sources :

Example 56 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class TextAssessmentIntegrationTest method retrieveParticipationForNonExistingSubmission.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void retrieveParticipationForNonExistingSubmission() throws Exception {
    StudentParticipation participation = request.get("/api/participations/1/submissions/345395769256365/for-text-assessment", HttpStatus.NOT_FOUND, StudentParticipation.class);
    assertThat(participation).as("participation should not be found").isNull();
}
Also used : StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 57 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class TextAssessmentIntegrationTest method getTextSubmissionWithResultId.

@Test
@WithMockUser(username = "instructor1", roles = "TA")
public void getTextSubmissionWithResultId() throws Exception {
    TextSubmission submission = ModelFactory.generateTextSubmission("asdf", null, true);
    submission = (TextSubmission) database.addSubmissionWithTwoFinishedResultsWithAssessor(textExercise, submission, "student1", "tutor1");
    Result storedResult = submission.getResultForCorrectionRound(1);
    var params = new LinkedMultiValueMap<String, String>();
    params.add("resultId", String.valueOf(storedResult.getId()));
    StudentParticipation participation = request.get("/api/participations/" + submission.getParticipation().getId() + "/submissions/" + submission.getId() + "/for-text-assessment", HttpStatus.OK, StudentParticipation.class, params);
    assertThat(participation.getResults()).isNotNull().contains(storedResult);
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 58 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class TextAssessmentIntegrationTest method retrieveParticipationForSubmission_studentHidden.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void retrieveParticipationForSubmission_studentHidden() throws Exception {
    TextSubmission textSubmission = ModelFactory.generateTextSubmission("Some text", Language.ENGLISH, false);
    textSubmission = database.saveTextSubmission(textExercise, textSubmission, "student1");
    StudentParticipation participationWithoutAssessment = request.get("/api/participations/" + textSubmission.getParticipation().getId() + "/submissions/" + textSubmission.getId() + "/for-text-assessment", HttpStatus.OK, StudentParticipation.class);
    assertThat(participationWithoutAssessment).as("participation with submission was found").isNotNull();
    assertThat(participationWithoutAssessment.getSubmissions().iterator().next().getId()).as("participation with correct text submission was found").isEqualTo(textSubmission.getId());
    assertThat(participationWithoutAssessment.getStudent()).as("student of participation is hidden").isEmpty();
}
Also used : StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 59 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class TextAssessmentIntegrationTest method retrieveParticipationForLockedSubmission.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void retrieveParticipationForLockedSubmission() throws Exception {
    TextSubmission textSubmission = ModelFactory.generateTextSubmission("Some text", Language.ENGLISH, false);
    textSubmission = database.saveTextSubmissionWithResultAndAssessor(textExercise, textSubmission, "student1", "tutor2");
    Result result = textSubmission.getLatestResult();
    // assessment is still in progress for this test
    result.setCompletionDate(null);
    resultRepo.save(result);
    StudentParticipation participation = request.get("/api/participations/" + textSubmission.getParticipation().getId() + "/submissions/" + textSubmission.getId() + "/for-text-assessment", HttpStatus.LOCKED, StudentParticipation.class);
    assertThat(participation).as("participation is locked and should not be returned").isNull();
}
Also used : StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 60 with StudentParticipation

use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.

the class TextClusterResourceIntegrationTest method initTestCase.

/**
 * Initializes the database with a course that contains a tutor and a text submission
 */
@BeforeEach
public void initTestCase() throws Error {
    Course course = database.createCourseWithInstructorAndTextExercise();
    exercise = course.getExercises().iterator().next();
    StudentParticipation studentParticipation = studentParticipationRepository.findAll().get(0);
    TextSubmission textSubmission = ModelFactory.generateTextSubmission("This is Part 1, and this is Part 2. There is also Part 3.", Language.ENGLISH, true);
    textSubmissionRepository.save(textSubmission);
    database.addResultToSubmission(textSubmission, AssessmentType.AUTOMATIC);
    Set<TextBlock> textBlocks = Set.of(new TextBlock().text("This is Part 1,").startIndex(0).endIndex(15).automatic(), new TextBlock().text("and this is Part 2.").startIndex(16).endIndex(35).automatic(), new TextBlock().text("There is also Part 3.").startIndex(36).endIndex(57).automatic());
    int[] clusterSizes = { 3 };
    List<TextCluster> clusters = textExerciseUtilService.addTextBlocksToCluster(textBlocks, clusterSizes, (TextExercise) exercise);
    clusters.get(0).setDisabled(true);
    textBlocks.forEach(block -> {
        block.setSubmission(textSubmission);
        block.setCluster(clusters.get(0));
        block.computeId();
    });
    textSubmission.setParticipation(studentParticipation);
    textSubmissionRepository.save(textSubmission);
    textClusterRepository.saveAll(clusters);
    textBlockRepository.saveAll(textBlocks);
}
Also used : StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)219 Test (org.junit.jupiter.api.Test)118 WithMockUser (org.springframework.security.test.context.support.WithMockUser)112 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)60 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)50 ProgrammingExerciseStudentParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation)48 ZonedDateTime (java.time.ZonedDateTime)44 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)42 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)40 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)36 Exam (de.tum.in.www1.artemis.domain.exam.Exam)30 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)30 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)28 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)28 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)26 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)24 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)24 Participation (de.tum.in.www1.artemis.domain.participation.Participation)24 Collectors (java.util.stream.Collectors)24