Search in sources :

Example 36 with StudentParticipation

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

the class FileUploadAssessmentIntegrationTest method multipleCorrectionRoundsForExam.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void multipleCorrectionRoundsForExam() throws Exception {
    // Setup exam with 2 correction rounds and a programming exercise
    ExerciseGroup exerciseGroup1 = new ExerciseGroup();
    Exam exam = database.addExam(course);
    exam.setNumberOfCorrectionRoundsInExam(2);
    exam.addExerciseGroup(exerciseGroup1);
    exam.setVisibleDate(ZonedDateTime.now().minusHours(3));
    exam.setStartDate(ZonedDateTime.now().minusHours(2));
    exam.setEndDate(ZonedDateTime.now().minusHours(1));
    exam = examRepository.save(exam);
    Exam examWithExerciseGroups = examRepository.findWithExerciseGroupsAndExercisesById(exam.getId()).get();
    exerciseGroup1 = examWithExerciseGroups.getExerciseGroups().get(0);
    FileUploadExercise exercise = ModelFactory.generateFileUploadExerciseForExam("test.pdf", exerciseGroup1);
    exercise = fileUploadExerciseRepository.save(exercise);
    exerciseGroup1.addExercise(exercise);
    // add student submission
    var submission = ModelFactory.generateFileUploadSubmission(true);
    submission = database.addFileUploadSubmission(exercise, submission, "student1");
    // verify setup
    assertThat(exam.getNumberOfCorrectionRoundsInExam()).isEqualTo(2);
    assertThat(exam.getEndDate()).isBefore(ZonedDateTime.now());
    var optionalFetchedExercise = exerciseRepository.findWithEagerStudentParticipationsStudentAndSubmissionsById(exercise.getId());
    assertThat(optionalFetchedExercise).isPresent();
    final var exerciseWithParticipation = optionalFetchedExercise.get();
    final var studentParticipation = exerciseWithParticipation.getStudentParticipations().stream().iterator().next();
    // request to manually assess latest submission (correction round: 0)
    LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("lock", "true");
    params.add("correction-round", "0");
    FileUploadSubmission submissionWithoutFirstAssessment = request.get("/api/exercises/" + exerciseWithParticipation.getId() + "/file-upload-submission-without-assessment", HttpStatus.OK, FileUploadSubmission.class, params);
    // verify that no new submission was created
    assertThat(submissionWithoutFirstAssessment).isEqualTo(submission);
    // verify that the lock has been set
    assertThat(submissionWithoutFirstAssessment.getLatestResult()).isNotNull();
    assertThat(submissionWithoutFirstAssessment.getLatestResult().getAssessor().getLogin()).isEqualTo("tutor1");
    assertThat(submissionWithoutFirstAssessment.getLatestResult().getAssessmentType()).isEqualTo(AssessmentType.MANUAL);
    // make sure that new result correctly appears inside the continue box
    LinkedMultiValueMap<String, String> paramsGetAssessedCR1Tutor1 = new LinkedMultiValueMap<>();
    paramsGetAssessedCR1Tutor1.add("assessedByTutor", "true");
    paramsGetAssessedCR1Tutor1.add("correction-round", "0");
    var assessedSubmissionList = request.getList("/api/exercises/" + exerciseWithParticipation.getId() + "/file-upload-submissions", HttpStatus.OK, FileUploadSubmission.class, paramsGetAssessedCR1Tutor1);
    assertThat(assessedSubmissionList).hasSize(1);
    assertThat(assessedSubmissionList.get(0).getId()).isEqualTo(submissionWithoutFirstAssessment.getId());
    assertThat(assessedSubmissionList.get(0).getResultForCorrectionRound(0)).isEqualTo(submissionWithoutFirstAssessment.getLatestResult());
    // assess submission and submit
    List<Feedback> feedbacks = ModelFactory.generateFeedback().stream().peek(feedback -> feedback.setDetailText("Good work here")).collect(Collectors.toList());
    params = new LinkedMultiValueMap<>();
    params.add("submit", "true");
    final Result firstSubmittedManualResult = request.putWithResponseBodyAndParams(API_FILE_UPLOAD_SUBMISSIONS + submissionWithoutFirstAssessment.getId() + "/feedback", feedbacks, Result.class, HttpStatus.OK, params);
    // make sure that new result correctly appears after the assessment for first correction round
    assessedSubmissionList = request.getList("/api/exercises/" + exerciseWithParticipation.getId() + "/file-upload-submissions", HttpStatus.OK, FileUploadSubmission.class, paramsGetAssessedCR1Tutor1);
    assertThat(assessedSubmissionList).hasSize(1);
    assertThat(assessedSubmissionList.get(0).getId()).isEqualTo(submissionWithoutFirstAssessment.getId());
    assertThat(assessedSubmissionList.get(0).getResultForCorrectionRound(0)).isNotNull();
    assertThat(firstSubmittedManualResult.getAssessor().getLogin()).isEqualTo("tutor1");
    // verify that the result contains the relationship
    assertThat(firstSubmittedManualResult).isNotNull();
    assertThat(firstSubmittedManualResult.getParticipation()).isEqualTo(studentParticipation);
    // verify that the relationship between student participation,
    var databaseRelationshipStateOfResultsOverParticipation = studentParticipationRepository.findWithEagerLegalSubmissionsAndResultsAssessorsById(studentParticipation.getId());
    assertThat(databaseRelationshipStateOfResultsOverParticipation).isPresent();
    var fetchedParticipation = databaseRelationshipStateOfResultsOverParticipation.get();
    assertThat(fetchedParticipation.getSubmissions()).hasSize(1);
    assertThat(fetchedParticipation.findLatestSubmission()).contains(submissionWithoutFirstAssessment);
    assertThat(fetchedParticipation.findLatestLegalResult()).isEqualTo(firstSubmittedManualResult);
    var databaseRelationshipStateOfResultsOverSubmission = studentParticipationRepository.findAllWithEagerSubmissionsAndEagerResultsAndEagerAssessorByExerciseId(exercise.getId());
    assertThat(databaseRelationshipStateOfResultsOverSubmission).hasSize(1);
    fetchedParticipation = databaseRelationshipStateOfResultsOverSubmission.get(0);
    assertThat(fetchedParticipation.getSubmissions()).hasSize(1);
    assertThat(fetchedParticipation.findLatestSubmission()).isPresent();
    // it should contain the lock for the manual result
    assertThat(fetchedParticipation.findLatestSubmission().get().getResults()).hasSize(1);
    assertThat(fetchedParticipation.findLatestSubmission().get().getLatestResult()).isEqualTo(firstSubmittedManualResult);
    // SECOND ROUND OF CORRECTION
    database.changeUser("tutor2");
    LinkedMultiValueMap<String, String> paramsSecondCorrection = new LinkedMultiValueMap<>();
    paramsSecondCorrection.add("lock", "true");
    paramsSecondCorrection.add("correction-round", "1");
    final var submissionWithoutSecondAssessment = request.get("/api/exercises/" + exerciseWithParticipation.getId() + "/file-upload-submission-without-assessment", HttpStatus.OK, FileUploadSubmission.class, paramsSecondCorrection);
    // verify that the submission is not new
    assertThat(submissionWithoutSecondAssessment).isEqualTo(submission);
    // verify that the lock has been set
    assertThat(submissionWithoutSecondAssessment.getLatestResult()).isNotNull();
    assertThat(submissionWithoutSecondAssessment.getLatestResult().getAssessor().getLogin()).isEqualTo("tutor2");
    assertThat(submissionWithoutSecondAssessment.getLatestResult().getAssessmentType()).isEqualTo(AssessmentType.MANUAL);
    // verify that the relationship between student participation,
    databaseRelationshipStateOfResultsOverParticipation = studentParticipationRepository.findWithEagerLegalSubmissionsAndResultsAssessorsById(studentParticipation.getId());
    assertThat(databaseRelationshipStateOfResultsOverParticipation).isPresent();
    fetchedParticipation = databaseRelationshipStateOfResultsOverParticipation.get();
    assertThat(fetchedParticipation.getSubmissions()).hasSize(1);
    assertThat(fetchedParticipation.findLatestSubmission()).contains(submissionWithoutSecondAssessment);
    assertThat(fetchedParticipation.getResults().stream().filter(x -> x.getCompletionDate() == null).findFirst()).contains(submissionWithoutSecondAssessment.getLatestResult());
    databaseRelationshipStateOfResultsOverSubmission = studentParticipationRepository.findAllWithEagerSubmissionsAndEagerResultsAndEagerAssessorByExerciseId(exercise.getId());
    assertThat(databaseRelationshipStateOfResultsOverSubmission).hasSize(1);
    fetchedParticipation = databaseRelationshipStateOfResultsOverSubmission.get(0);
    assertThat(fetchedParticipation.getSubmissions()).hasSize(1);
    assertThat(fetchedParticipation.findLatestSubmission()).isPresent();
    assertThat(fetchedParticipation.findLatestSubmission().get().getResults()).hasSize(2);
    assertThat(fetchedParticipation.findLatestSubmission().get().getLatestResult()).isEqualTo(submissionWithoutSecondAssessment.getLatestResult());
    // assess submission and submit
    feedbacks = ModelFactory.generateFeedback().stream().peek(feedback -> feedback.setDetailText("Good work here")).collect(Collectors.toList());
    params = new LinkedMultiValueMap<>();
    params.add("submit", "true");
    final var secondSubmittedManualResult = request.putWithResponseBodyAndParams(API_FILE_UPLOAD_SUBMISSIONS + submissionWithoutFirstAssessment.getId() + "/feedback", feedbacks, Result.class, HttpStatus.OK, params);
    assertThat(secondSubmittedManualResult).isNotNull();
    // make sure that new result correctly appears after the assessment for second correction round
    LinkedMultiValueMap<String, String> paramsGetAssessedCR2 = new LinkedMultiValueMap<>();
    paramsGetAssessedCR2.add("assessedByTutor", "true");
    paramsGetAssessedCR2.add("correction-round", "1");
    assessedSubmissionList = request.getList("/api/exercises/" + exerciseWithParticipation.getId() + "/file-upload-submissions", HttpStatus.OK, FileUploadSubmission.class, paramsGetAssessedCR2);
    assertThat(assessedSubmissionList).hasSize(1);
    assertThat(assessedSubmissionList.get(0).getId()).isEqualTo(submissionWithoutSecondAssessment.getId());
    assertThat(assessedSubmissionList.get(0).getResultForCorrectionRound(1)).isEqualTo(secondSubmittedManualResult);
    // make sure that they do not appear for the first correction round as the tutor only assessed the second correction round
    LinkedMultiValueMap<String, String> paramsGetAssessedCR1 = new LinkedMultiValueMap<>();
    paramsGetAssessedCR1.add("assessedByTutor", "true");
    paramsGetAssessedCR1.add("correction-round", "0");
    assessedSubmissionList = request.getList("/api/exercises/" + exerciseWithParticipation.getId() + "/file-upload-submissions", HttpStatus.OK, FileUploadSubmission.class, paramsGetAssessedCR1);
    assertThat(assessedSubmissionList).isEmpty();
    // Student should not have received a result over WebSocket as manual correction is ongoing
    verify(messagingTemplate, never()).convertAndSendToUser(notNull(), eq(Constants.NEW_RESULT_TOPIC), isA(Result.class));
}
Also used : Offset(org.assertj.core.data.Offset) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) AssessmentType(de.tum.in.www1.artemis.domain.enumeration.AssessmentType) Collectors(java.util.stream.Collectors) ComplaintType(de.tum.in.www1.artemis.domain.enumeration.ComplaintType) Constants(de.tum.in.www1.artemis.config.Constants) ArrayList(java.util.ArrayList) Mockito(org.mockito.Mockito) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) WithMockUser(org.springframework.security.test.context.support.WithMockUser) org.junit.jupiter.api(org.junit.jupiter.api) ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ModelFactory(de.tum.in.www1.artemis.util.ModelFactory) IncludedInOverallScore(de.tum.in.www1.artemis.domain.enumeration.IncludedInOverallScore) Exam(de.tum.in.www1.artemis.domain.exam.Exam) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) FeedbackType(de.tum.in.www1.artemis.domain.enumeration.FeedbackType) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup) Exam(de.tum.in.www1.artemis.domain.exam.Exam) WithMockUser(org.springframework.security.test.context.support.WithMockUser)

Example 37 with StudentParticipation

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

the class FileUploadSubmissionIntegrationTest method cannotSeeStudentDetailsInSubmissionListAsTutor.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void cannotSeeStudentDetailsInSubmissionListAsTutor() throws Exception {
    FileUploadSubmission submission1 = database.saveFileUploadSubmissionWithResultAndAssessor(releasedFileUploadExercise, submittedFileUploadSubmission, "student1", "tutor1");
    List<FileUploadSubmission> submissions = request.getList("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submissions?assessedByTutor=true", HttpStatus.OK, FileUploadSubmission.class);
    assertThat(submissions).as("one file upload submission was found").hasSize(1);
    assertThat(submissions.get(0).getId()).as("correct file upload submission was found").isEqualTo(submission1.getId());
    final StudentParticipation participation1 = (StudentParticipation) submissions.get(0).getParticipation();
    assertThat(participation1.getStudent()).as("contains no student details").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 38 with StudentParticipation

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

the class FileUploadSubmissionIntegrationTest method submitExercise_afterDueDate.

@Test
@WithMockUser(username = "student3", roles = "USER")
public void submitExercise_afterDueDate() throws Exception {
    StudentParticipation studentParticipation = database.createAndSaveParticipationForExerciseInTheFuture(releasedFileUploadExercise, "student3");
    submittedFileUploadSubmission.setParticipation(studentParticipation);
    request.postWithMultipartFile("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submissions", submittedFileUploadSubmission, "submission", validFile, FileUploadSubmission.class, HttpStatus.OK);
}
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 39 with StudentParticipation

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

the class AssessmentTeamComplaintIntegrationTest method submitComplaintResponse_updateAssessment.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void submitComplaintResponse_updateAssessment() throws Exception {
    complaint = complaintRepo.save(complaint);
    List<Feedback> feedbacks = database.loadAssessmentFomResources("test-data/model-assessment/assessment.54727.json");
    feedbacks.forEach((feedback -> feedback.setType(FeedbackType.MANUAL)));
    ComplaintResponse complaintResponse = database.createInitialEmptyResponse("tutor1", complaint);
    complaintResponse.getComplaint().setAccepted(true);
    complaintResponse.setResponseText("accepted");
    AssessmentUpdate assessmentUpdate = new AssessmentUpdate().feedbacks(feedbacks).complaintResponse(complaintResponse);
    Result receivedResult = request.putWithResponseBody("/api/modeling-submissions/" + modelingSubmission.getId() + "/assessment-after-complaint", assessmentUpdate, Result.class, HttpStatus.OK);
    assertThat(((StudentParticipation) receivedResult.getParticipation()).getStudent()).as("student is hidden in response").isEmpty();
    Complaint storedComplaint = complaintRepo.findByResultId(modelingAssessment.getId()).get();
    assertThat(storedComplaint.isAccepted()).as("complaint is accepted").isTrue();
    Result resultOfComplaint = storedComplaint.getResult();
    // set dates to UTC and round to milliseconds for comparison
    resultOfComplaint.setCompletionDate(ZonedDateTime.ofInstant(resultOfComplaint.getCompletionDate().truncatedTo(ChronoUnit.MILLIS).toInstant(), ZoneId.of("UTC")));
    modelingAssessment.setCompletionDate(ZonedDateTime.ofInstant(modelingAssessment.getCompletionDate().truncatedTo(ChronoUnit.MILLIS).toInstant(), ZoneId.of("UTC")));
    assertThat(resultOfComplaint.getAssessor()).isEqualTo(modelingAssessment.getAssessor());
    assertThat(resultOfComplaint).isEqualTo(modelingAssessment);
    String[] ignoringFields = { "participation", "submission", "feedbacks", "assessor" };
    Submission submission = submissionRepository.findOneWithEagerResultAndFeedback(modelingAssessment.getSubmission().getId());
    assertThat(submission.getLatestResult()).isNotNull();
    assertThat(submission.getFirstResult()).isNotNull();
    database.checkFeedbackCorrectlyStored(feedbacks, submission.getLatestResult().getFeedbacks(), FeedbackType.MANUAL);
    assertThat(submission.getFirstResult().getAssessor()).as("assessor is still the original one").isEqualTo(modelingAssessment.getAssessor());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ExerciseMode(de.tum.in.www1.artemis.domain.enumeration.ExerciseMode) Autowired(org.springframework.beans.factory.annotation.Autowired) ComplaintType(de.tum.in.www1.artemis.domain.enumeration.ComplaintType) ZoneId(java.time.ZoneId) Test(org.junit.jupiter.api.Test) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) FileUtils(de.tum.in.www1.artemis.util.FileUtils) ChronoUnit(java.time.temporal.ChronoUnit) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) WithMockUser(org.springframework.security.test.context.support.WithMockUser) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ModelFactory(de.tum.in.www1.artemis.util.ModelFactory) FeedbackType(de.tum.in.www1.artemis.domain.enumeration.FeedbackType) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 40 with StudentParticipation

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

the class ComplaintResponseIntegrationTest method initTestCase.

@BeforeEach
public void initTestCase() throws Exception {
    // creating the users student1-student5, tutor1-tutor10 and instructors1-instructor10
    this.database.addUsers(5, 10, 0, 10);
    // Add users that are not in the course
    userRepository.save(ModelFactory.generateActivatedUser("student42"));
    userRepository.save(ModelFactory.generateActivatedUser("tutor42"));
    userRepository.save(ModelFactory.generateActivatedUser("instructor42"));
    userRepository.flush();
    // creating course
    // students: student1-student 5 | tutors: tutor1-tutor10 | instructors: instructor1 - instructor10
    Course course = this.database.createCourse();
    // creating text exercise
    TextExercise textExercise = ModelFactory.generateTextExercise(null, null, null, course);
    textExercise.setMaxPoints(10.0);
    textExercise.setBonusPoints(0.0);
    textExercise = exerciseRepository.saveAndFlush(textExercise);
    // creating participation of student1 by starting the exercise
    User student1 = userRepository.findOneByLogin("student1").get();
    StudentParticipation studentParticipation = participationService.startExercise(textExercise, student1, false);
    // creating submission of student1
    TextSubmission submission = new TextSubmission();
    submission.setType(SubmissionType.MANUAL);
    submission.setParticipation(studentParticipation);
    submission.setSubmitted(Boolean.TRUE);
    submission.setSubmissionDate(ZonedDateTime.now());
    submission.text("hello world");
    submission = submissionRepository.saveAndFlush(submission);
    // creating assessment by tutor1
    User tutor1 = userRepository.findOneByLogin("tutor1").get();
    Result result = ModelFactory.generateResult(true, 50D);
    result.setAssessor(tutor1);
    result.setHasComplaint(true);
    result.setHasFeedback(false);
    result.setParticipation(studentParticipation);
    result = resultRepository.saveAndFlush(result);
    submission.addResult(result);
    result.setSubmission(submission);
    submission = submissionRepository.saveAndFlush(submission);
    // creating complaint by student 1
    complaint = new Complaint();
    complaint.setComplaintType(ComplaintType.COMPLAINT);
    complaint.setComplaintText("Unfair");
    complaint.setResult(result);
    complaint.setAccepted(null);
    complaint.setSubmittedTime(null);
    complaint.setParticipant(student1);
    complaint = complaintRepository.saveAndFlush(complaint);
}
Also used : WithMockUser(org.springframework.security.test.context.support.WithMockUser) 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