use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.
the class ExamIntegrationTest method testStartExercisesWithModelingExercise.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testStartExercisesWithModelingExercise() throws Exception {
// TODO IMPORTANT test more complex exam configurations (mixed exercise type, more variants and more registered students)
// registering users
var student1 = database.getUserByLogin("student1");
var student2 = database.getUserByLogin("student2");
var registeredUsers = Set.of(student1, student2);
exam2.setRegisteredUsers(registeredUsers);
// setting dates
exam2.setStartDate(now().plusHours(2));
exam2.setEndDate(now().plusHours(3));
exam2.setVisibleDate(now().plusHours(1));
// creating exercise
ModelingExercise modelingExercise = ModelFactory.generateModelingExerciseForExam(DiagramType.ClassDiagram, exam2.getExerciseGroups().get(0));
exam2.getExerciseGroups().get(0).addExercise(modelingExercise);
exerciseGroupRepository.save(exam2.getExerciseGroups().get(0));
modelingExercise = exerciseRepo.save(modelingExercise);
List<StudentExam> createdStudentExams = new ArrayList<>();
// creating student exams
for (User user : registeredUsers) {
StudentExam studentExam = new StudentExam();
studentExam.addExercise(modelingExercise);
studentExam.setUser(user);
exam2.addStudentExam(studentExam);
createdStudentExams.add(studentExamRepository.save(studentExam));
}
exam2 = examRepository.save(exam2);
// invoke start exercises
Integer noGeneratedParticipations = request.postWithResponseBody("/api/courses/" + course1.getId() + "/exams/" + exam2.getId() + "/student-exams/start-exercises", Optional.empty(), Integer.class, HttpStatus.OK);
assertThat(noGeneratedParticipations).isEqualTo(exam2.getStudentExams().size());
List<Participation> studentParticipations = participationTestRepository.findAllWithSubmissions();
for (Participation participation : studentParticipations) {
assertThat(participation.getExercise()).isEqualTo(modelingExercise);
assertThat(participation.getExercise().getCourseViaExerciseGroupOrCourseMember()).isNotNull();
assertThat(participation.getExercise().getExerciseGroup()).isEqualTo(exam2.getExerciseGroups().get(0));
assertThat(participation.getSubmissions()).hasSize(1);
var textSubmission = (ModelingSubmission) participation.getSubmissions().iterator().next();
assertThat(textSubmission.getModel()).isNull();
assertThat(textSubmission.getExplanationText()).isNull();
}
// Cleanup of Bidirectional Relationships
for (StudentExam studentExam : createdStudentExams) {
exam2.removeStudentExam(studentExam);
}
examRepository.save(exam2);
}
use of de.tum.in.www1.artemis.domain.participation.Participation 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));
}
use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.
the class FileUploadSubmissionIntegrationTest method getDataForFileUpload_latestSubmissionOfParticipationNull.
@Test
@WithMockUser(username = "student1")
public void getDataForFileUpload_latestSubmissionOfParticipationNull() throws Exception {
FileUploadSubmission fileUploadSubmission = ModelFactory.generateFileUploadSubmission(true);
List<Feedback> feedbacks = ModelFactory.generateFeedback();
fileUploadSubmission = database.saveFileUploadSubmissionWithResultAndAssessorFeedback(releasedFileUploadExercise, fileUploadSubmission, "student1", "tutor1", feedbacks);
database.updateExerciseDueDate(releasedFileUploadExercise.getId(), ZonedDateTime.now().minusHours(1));
Participation participation = fileUploadSubmission.getParticipation();
participation.setResults(null);
FileUploadSubmission submission = request.get("/api/participations/" + participation.getId() + "/file-upload-editor", HttpStatus.OK, FileUploadSubmission.class);
assertThat(submission).isNotNull();
assertThat(submission.getLatestResult()).isNotNull();
assertThat(submission.isSubmitted()).isTrue();
assertThat(submission.getLatestResult().getFeedbacks()).as("No feedback should be returned for editor").isEmpty();
assertThat(submission.getLatestResult().getAssessor()).isNull();
}
use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.
the class FileUploadSubmissionIntegrationTest method getDataForFileUpload_wrongExerciseType.
@Test
@WithMockUser(username = "student1")
public void getDataForFileUpload_wrongExerciseType() throws Exception {
Course course = database.addCourseWithOneModelingExercise();
ModelingExercise modelingExercise = database.findModelingExerciseWithTitle(course.getExercises(), "ClassDiagram");
Participation modelingExerciseParticipation = database.createAndSaveParticipationForExercise(modelingExercise, "student1");
FileUploadSubmission submission = request.get("/api/participations/" + modelingExerciseParticipation.getId() + "/file-upload-editor", HttpStatus.BAD_REQUEST, FileUploadSubmission.class);
assertThat(submission).isNull();
}
use of de.tum.in.www1.artemis.domain.participation.Participation 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());
}
Aggregations