use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison in project Artemis by ls1intum.
the class PlagiarismService method anonymizeComparisonForStudent.
/**
* Anonymize the comparison for the student view.
* A student should not have sensitive information (e.g. the userLogin of the other student)
*
* @param comparison to anonymize.
* @param userLogin of the student asking to see his plagiarism comparison.
* @return the anonymized plagiarism comparison for the given student
*/
public PlagiarismComparison anonymizeComparisonForStudent(PlagiarismComparison comparison, String userLogin) {
if (comparison.getSubmissionA().getStudentLogin().equals(userLogin)) {
comparison.getSubmissionA().setStudentLogin(YOUR_SUBMISSION);
comparison.getSubmissionB().setStudentLogin(OTHER_SUBMISSION);
} else if (comparison.getSubmissionB().getStudentLogin().equals(userLogin)) {
comparison.getSubmissionA().setStudentLogin(OTHER_SUBMISSION);
comparison.getSubmissionB().setStudentLogin(YOUR_SUBMISSION);
} else {
throw new AccessForbiddenException("This plagiarism comparison is not related to the requesting user.");
}
return comparison;
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison in project Artemis by ls1intum.
the class PlagiarismResource method getPlagiarismComparisonForSplitView.
/**
* Retrieves the plagiarismComparison specified by its ID.
* If a studentLogin is passed the comparison is anonymized
*
* @param courseId the id of the course
* @param comparisonId the id of the PlagiarismComparison
* @param studentLogin optional login of the student
* @return the PlagiarismComparison
* @throws AccessForbiddenException if the requesting user is not affected by the plagiarism case.
*/
@GetMapping("courses/{courseId}/plagiarism-comparisons/{comparisonId}/for-split-view")
@PreAuthorize("hasRole('USER')")
public ResponseEntity<PlagiarismComparison<?>> getPlagiarismComparisonForSplitView(@PathVariable("courseId") long courseId, @PathVariable("comparisonId") Long comparisonId, @RequestParam(value = "studentLogin", required = false) String studentLogin) {
var comparisonA = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsAndElementsAElseThrow(comparisonId);
var comparisonB = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsAndElementsBElseThrow(comparisonId);
Course course = courseRepository.findByIdElseThrow(courseId);
User user = userRepository.getUserWithGroupsAndAuthorities();
if (!authenticationCheckService.isAtLeastStudentInCourse(course, user)) {
throw new AccessForbiddenException("Only students registered for this course can access this plagiarism comparison.");
}
if (!Objects.equals(comparisonA.getPlagiarismResult().getExercise().getCourseViaExerciseGroupOrCourseMember().getId(), courseId)) {
throw new BadRequestAlertException("The courseId does not belong to the given comparisonId", "PlagiarismComparison", "idMismatch");
}
comparisonA.setSubmissionB(comparisonB.getSubmissionB());
if (studentLogin != null) {
comparisonA = this.plagiarismService.anonymizeComparisonForStudent(comparisonA, studentLogin);
}
comparisonA.getSubmissionA().setPlagiarismComparison(null);
comparisonB.getSubmissionB().setPlagiarismComparison(null);
return ResponseEntity.ok(comparisonA);
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison in project Artemis by ls1intum.
the class TextSubmissionIntegrationTest method getTextSubmissionWithResult_involved_allowed.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void getTextSubmissionWithResult_involved_allowed() throws Exception {
textSubmission = database.saveTextSubmission(finishedTextExercise, textSubmission, "student1");
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
submissionA.setSubmissionId(this.textSubmission.getId());
plagiarismComparison.setSubmissionA(submissionA);
PlagiarismCase plagiarismCase = new PlagiarismCase();
plagiarismCase = plagiarismCaseRepository.save(plagiarismCase);
Post post = new Post();
post.setAuthor(userRepository.getUserByLoginElseThrow("instructor1"));
post.setTitle("Title Plagiarism Case Post");
post.setContent("Content Plagiarism Case Post");
post.setVisibleForStudents(true);
post.setPlagiarismCase(plagiarismCase);
postRepository.save(post);
submissionA.setPlagiarismCase(plagiarismCase);
plagiarismComparisonRepository.save(plagiarismComparison);
var submission = request.get("/api/text-submissions/" + this.textSubmission.getId(), HttpStatus.OK, TextSubmission.class);
assertThat(submission.getParticipation()).as("Should anonymize participation").isNull();
assertThat(submission.getResults()).as("Should anonymize results").isEmpty();
assertThat(submission.getSubmissionDate()).as("Should anonymize submission date").isNull();
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison in project Artemis by ls1intum.
the class PlagiarismCaseIntegrationTest method initTestCase.
@BeforeEach
public void initTestCase() {
database.addUsers(3, 1, 1, 1);
course = database.addCourseWithOneFinishedTextExercise();
textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
plagiarismCase1 = new PlagiarismCase();
plagiarismCase1.setExercise(textExercise);
User student1 = database.getUserByLogin("student1");
plagiarismCase1.setStudent(student1);
plagiarismCase1 = plagiarismCaseRepository.save(plagiarismCase1);
PlagiarismResult<TextSubmissionElement> textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
plagiarismComparison = plagiarismComparisonRepository.save(plagiarismComparison);
PlagiarismSubmission<TextSubmissionElement> plagiarismSubmission1 = new PlagiarismSubmission<>();
plagiarismSubmission1.setStudentLogin("student1");
plagiarismSubmission1.setPlagiarismCase(plagiarismCase1);
plagiarismSubmission1.setPlagiarismComparison(plagiarismComparison);
PlagiarismSubmission<TextSubmissionElement> plagiarismSubmission2 = new PlagiarismSubmission<>();
plagiarismSubmission2.setStudentLogin("student2");
plagiarismSubmission2.setPlagiarismCase(plagiarismCase1);
plagiarismSubmission2.setPlagiarismComparison(plagiarismComparison);
plagiarismComparison.setSubmissionA(plagiarismSubmission1);
plagiarismComparison.setSubmissionB(plagiarismSubmission2);
plagiarismComparisonRepository.save(plagiarismComparison);
plagiarismCase2 = new PlagiarismCase();
plagiarismCase2.setExercise(textExercise);
User student2 = database.getUserByLogin("student2");
plagiarismCase2.setStudent(student2);
plagiarismCase2 = plagiarismCaseRepository.save(plagiarismCase2);
plagiarismCase3 = new PlagiarismCase();
plagiarismCase3.setExercise(textExercise);
User student3 = database.getUserByLogin("student3");
plagiarismCase3.setStudent(student3);
plagiarismCase3 = plagiarismCaseRepository.save(plagiarismCase3);
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison in project ArTEMiS by ls1intum.
the class SingleUserNotificationServiceTest method setUp.
/**
* Sets up all needed mocks and their wanted behavior
*/
@BeforeEach
public void setUp() {
SecurityUtils.setAuthorizationObject();
course = database.createCourse();
List<User> users = database.addUsers(3, 0, 0, 0);
user = users.get(0);
exercise = new TextExercise();
exercise.setCourse(course);
exercise.setMaxPoints(10D);
fileUploadExercise = new FileUploadExercise();
fileUploadExercise.setCourse(course);
Lecture lecture = new Lecture();
lecture.setCourse(course);
post = new Post();
post.setExercise(exercise);
post.setLecture(lecture);
post.setAuthor(user);
post.setCourse(course);
PlagiarismSubmission<TextSubmissionElement> plagiarismSubmission = new PlagiarismSubmission<>();
plagiarismSubmission.setStudentLogin(user.getLogin());
TextPlagiarismResult plagiarismResult = new TextPlagiarismResult();
plagiarismResult.setExercise(exercise);
plagiarismComparison = new PlagiarismComparison<>();
plagiarismComparison.setSubmissionA(plagiarismSubmission);
plagiarismComparison.setPlagiarismResult(plagiarismResult);
plagiarismCase = new PlagiarismCase();
plagiarismCase.setExercise(exercise);
result = new Result();
result.setScore(1D);
result.setCompletionDate(ZonedDateTime.now().minusMinutes(1));
doNothing().when(javaMailSender).send(any(MimeMessage.class));
}
Aggregations