use of de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO in project Artemis by ls1intum.
the class PlagiarismIntegrationTest method updatePlagiarismComparisonFinalStatusForUnknownStudent.
/**
* Checks the method updatePlagiarismComparisonFinalStatus for unknown student
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updatePlagiarismComparisonFinalStatusForUnknownStudent() throws Exception {
Course course = database.addCourseWithOneFinishedTextExercise();
TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
PlagiarismSubmission<TextSubmissionElement> submissionB = new PlagiarismSubmission<>();
submissionB.setStudentLogin("student2");
plagiarismComparison.setInstructorStatementB(INSTRUCTOR_STATEMENT_B);
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
plagiarismComparison.setStatusB(PlagiarismStatus.NONE);
plagiarismComparison.setSubmissionA(submissionA);
plagiarismComparison.setSubmissionB(submissionB);
plagiarismComparisonRepository.save(plagiarismComparison);
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/final-status/student42", new PlagiarismComparisonStatusDTO(), HttpStatus.NOT_FOUND);
}
use of de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO in project Artemis by ls1intum.
the class PlagiarismResource method updatePlagiarismComparisonFinalStatus.
/**
* Updates the final status of a plagiarism comparison concerning one of both students.
* This process will send a notification to the respective student.
* I.e. an instructor sends his final verdict/decision
*
* @param courseId the id of the course
* @param comparisonId of the comparison
* @param studentLogin of the student
* @param statusDTO is the final status of this plagiarism comparison concerning one of both students
* @return the final (updated) status of this plagiarism comparison concerning one of both students
*/
@PutMapping("courses/{courseId}/plagiarism-comparisons/{comparisonId}/final-status/{studentLogin}")
@PreAuthorize("hasRole('INSTRUCTOR')")
public ResponseEntity<PlagiarismComparisonStatusDTO> updatePlagiarismComparisonFinalStatus(@PathVariable("courseId") long courseId, @PathVariable("comparisonId") long comparisonId, @PathVariable("studentLogin") String studentLogin, @RequestBody PlagiarismComparisonStatusDTO statusDTO) {
var comparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(comparisonId);
Course course = courseRepository.findByIdElseThrow(courseId);
User affectedUser = userRepository.getUserWithGroupsAndAuthorities(studentLogin);
User user = userRepository.getUserWithGroupsAndAuthorities();
PlagiarismStatus finalStatus = statusDTO.getStatus();
if (!authenticationCheckService.isAtLeastInstructorInCourse(course, user)) {
throw new AccessForbiddenException("Only instructors responsible for this course can access this plagiarism comparison.");
}
if (!Objects.equals(comparison.getPlagiarismResult().getExercise().getCourseViaExerciseGroupOrCourseMember().getId(), courseId)) {
throw new BadRequestAlertException("The courseId does not belong to the given comparisonId", "PlagiarismComparison", "idMismatch");
}
if (comparison.getSubmissionA().getStudentLogin().equals(studentLogin)) {
plagiarismComparisonRepository.updatePlagiarismComparisonFinalStatusA(comparisonId, finalStatus);
// needed for notifications
comparison.setStatusA(finalStatus);
} else if (comparison.getSubmissionB().getStudentLogin().equals(studentLogin)) {
plagiarismComparisonRepository.updatePlagiarismComparisonFinalStatusB(comparisonId, finalStatus);
// needed for notifications
comparison.setStatusB(finalStatus);
} else {
return ResponseEntity.notFound().build();
}
singleUserNotificationService.notifyUserAboutFinalPlagiarismState(comparison, affectedUser);
return ResponseEntity.ok(statusDTO);
}
use of de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO in project Artemis by ls1intum.
the class PlagiarismResource method updatePlagiarismComparisonStatus.
/**
* Update the status of the plagiarism comparison with the given ID.
* I.e. An editor or instructor sees a possible plagiarism case for the first time and decides if it should be further examined, or if it is not a plagiarism.
*
* @param comparisonId of the plagiarism comparison to update the status of
* @param courseId the id of the course
* @param statusDTO new status for the given comparison
* @return the ResponseEntity with status 200 (Ok) or with status 400 (Bad Request) if the parameters are invalid
*/
@PutMapping("courses/{courseId}/plagiarism-comparisons/{comparisonId}/status")
@PreAuthorize("hasRole('EDITOR')")
public ResponseEntity<Void> updatePlagiarismComparisonStatus(@PathVariable("courseId") long courseId, @PathVariable("comparisonId") long comparisonId, @RequestBody PlagiarismComparisonStatusDTO statusDTO) {
log.info("REST request to update the status {} of the plagiarism comparison with id: {}", statusDTO.getStatus(), comparisonId);
Course course = courseRepository.findByIdElseThrow(courseId);
authenticationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.EDITOR, course, null);
// TODO: this check can take up to a few seconds in the worst case, we should do it directly in the database
var comparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(comparisonId);
if (!Objects.equals(comparison.getPlagiarismResult().getExercise().getCourseViaExerciseGroupOrCourseMember().getId(), courseId)) {
throw new BadRequestAlertException("The courseId does not belong to the given comparisonId", "PlagiarismComparison", "idMismatch");
}
plagiarismComparisonRepository.updatePlagiarismComparisonStatus(comparisonId, statusDTO.getStatus());
log.info("Finished updating the status {} of the plagiarism comparison with id: {}", statusDTO.getStatus(), comparisonId);
return ResponseEntity.ok().body(null);
}
use of de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO in project ArTEMiS by ls1intum.
the class PlagiarismIntegrationTest method updatePlagiarismComparisonFinalStatusForUnknownStudent.
/**
* Checks the method updatePlagiarismComparisonFinalStatus for unknown student
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updatePlagiarismComparisonFinalStatusForUnknownStudent() throws Exception {
Course course = database.addCourseWithOneFinishedTextExercise();
TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
PlagiarismSubmission<TextSubmissionElement> submissionB = new PlagiarismSubmission<>();
submissionB.setStudentLogin("student2");
plagiarismComparison.setInstructorStatementB(INSTRUCTOR_STATEMENT_B);
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
plagiarismComparison.setStatusB(PlagiarismStatus.NONE);
plagiarismComparison.setSubmissionA(submissionA);
plagiarismComparison.setSubmissionB(submissionB);
plagiarismComparisonRepository.save(plagiarismComparison);
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/final-status/student42", new PlagiarismComparisonStatusDTO(), HttpStatus.NOT_FOUND);
}
use of de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO in project ArTEMiS by ls1intum.
the class PlagiarismIntegrationTest method updatePlagiarismComparisonFinalStatusForStudentB.
/**
* Checks the method updatePlagiarismComparisonFinalStatus for second (B) user
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updatePlagiarismComparisonFinalStatusForStudentB() throws Exception {
Course course = database.addCourseWithOneFinishedTextExercise();
TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
PlagiarismSubmission<TextSubmissionElement> submissionB = new PlagiarismSubmission<>();
submissionB.setStudentLogin("student2");
plagiarismComparison.setInstructorStatementB(INSTRUCTOR_STATEMENT_B);
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
plagiarismComparison.setStatusB(PlagiarismStatus.NONE);
plagiarismComparison.setSubmissionA(submissionA);
plagiarismComparison.setSubmissionB(submissionB);
plagiarismComparisonRepository.save(plagiarismComparison);
var plagiarismComparisonStatus = new PlagiarismComparisonStatusDTO();
plagiarismComparisonStatus.setStatus(PlagiarismStatus.CONFIRMED);
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/final-status/student2", plagiarismComparisonStatus, HttpStatus.OK);
var updatedPlagiarismComparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
assertThat(updatedPlagiarismComparison.getStatusB()).as("should update status for studentB").isEqualTo(PlagiarismStatus.CONFIRMED);
}
Aggregations