use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismStatus 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.domain.plagiarism.PlagiarismStatus 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);
}
Aggregations