use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission in project Artemis by ls1intum.
the class PlagiarismCaseService method createOrAddToPlagiarismCaseForStudent.
/**
* Create or add to a plagiarism case for a student defined via the submission involved in a plagiarism comparison.
* The following logic applies:
* * <ul>
* * <li>Create a new plagiarism case if the student isn't already part of a plagiarism case in the exercise</li>
* * <li>Add the submission of the student to existing plagiarism case otherwise</li>
* * </ul>
*
* @param plagiarismComparison the plagiarism comparison for which to create the plagiarism case
* @param plagiarismSubmission the plagiarism submission of the student for which to create the plagiarism case
*/
public void createOrAddToPlagiarismCaseForStudent(PlagiarismComparison<?> plagiarismComparison, PlagiarismSubmission<?> plagiarismSubmission) {
var plagiarismCase = plagiarismCaseRepository.findByStudentLoginAndExerciseIdWithPlagiarismSubmissions(plagiarismSubmission.getStudentLogin(), plagiarismComparison.getPlagiarismResult().getExercise().getId());
if (plagiarismCase.isPresent()) {
// add submission to existing PlagiarismCase for student
plagiarismSubmission.setPlagiarismCase(plagiarismCase.get());
plagiarismComparisonRepository.save(plagiarismComparison);
} else {
// create new PlagiarismCase for student
var student = userRepository.getUserByLoginElseThrow(plagiarismSubmission.getStudentLogin());
PlagiarismCase newPlagiarismCase = new PlagiarismCase();
newPlagiarismCase.setExercise(plagiarismComparison.getPlagiarismResult().getExercise());
newPlagiarismCase.setStudent(student);
var savedPlagiarismCase = plagiarismCaseRepository.save(newPlagiarismCase);
plagiarismSubmission.setPlagiarismCase(savedPlagiarismCase);
plagiarismComparisonRepository.save(plagiarismComparison);
}
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmissionWithResult_involved_allowed.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void getModelSubmissionWithResult_involved_allowed() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
submission = database.addModelingSubmission(classExercise, submission, "student1");
PlagiarismComparison<ModelingSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
PlagiarismSubmission<ModelingSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
submissionA.setSubmissionId(submission.getId());
plagiarismComparison.setSubmissionA(submissionA);
PlagiarismCase plagiarismCase = new PlagiarismCase();
plagiarismCase = plagiarismCaseRepository.save(plagiarismCase);
Post post = new Post();
post.setAuthor(userRepo.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 submissionResult = request.get("/api/modeling-submissions/" + submission.getId(), HttpStatus.OK, ModelingSubmission.class);
assertThat(submissionResult.getParticipation()).as("Should anonymize participation").isNull();
assertThat(submissionResult.getResults()).as("Should anonymize results").isEmpty();
assertThat(submissionResult.getSubmissionDate()).as("Should anonymize submission date").isNull();
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission in project Artemis by ls1intum.
the class SingleUserNotificationFactoryTest method setUp.
/**
* sets up all needed mocks and their wanted behavior once for all test cases.
*/
@BeforeAll
public static void setUp() {
course = new Course();
course.setId(COURSE_ID);
lecture = new Lecture();
lecture.setId(LECTURE_ID);
lecture.setCourse(course);
exercise = new TextExercise();
exercise.setId(EXERCISE_ID);
exercise.setTitle(EXERCISE_TITLE);
exercise.setCourse(course);
exercise.setProblemStatement(PROBLEM_STATEMENT);
post = new Post();
post.setExercise(exercise);
post.setLecture(lecture);
answerPost = new AnswerPost();
answerPost.setPost(post);
cheatingUser = new User();
cheatingUser.setLogin(USER_LOGIN);
plagiarismResult = new TextPlagiarismResult();
plagiarismResult.setExercise(exercise);
plagiarismSubmission = new PlagiarismSubmission();
plagiarismSubmission.setStudentLogin(USER_LOGIN);
plagiarismSubmissionSet = new HashSet<>();
plagiarismSubmissionSet.add(plagiarismSubmission);
plagiarismComparison = new PlagiarismComparison();
plagiarismComparison.setPlagiarismResult(plagiarismResult);
plagiarismComparison.setSubmissionA(plagiarismSubmission);
plagiarismCase = new PlagiarismCase();
plagiarismCase.setExercise(exercise);
plagiarismCase.setStudent(cheatingUser);
plagiarismCase.setPlagiarismSubmissions(plagiarismSubmissionSet);
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission in project Artemis by ls1intum.
the class PlagiarismIntegrationTest method saveStudentStatementForUnknownStudent.
/**
* Checks the method updatePlagiarismComparisonStudentStatement for unknown student
*/
@Test
@WithMockUser(username = "student3", roles = "USER")
public void saveStudentStatementForUnknownStudent() 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<>();
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
submissionA.setStudentLogin("student1");
plagiarismComparison.setSubmissionA(submissionA);
plagiarismComparison.setInstructorStatementA(INSTRUCTOR_STATEMENT_A);
PlagiarismSubmission<TextSubmissionElement> submissionB = new PlagiarismSubmission<>();
submissionB.setStudentLogin("student2");
plagiarismComparison.setSubmissionB(submissionB);
plagiarismComparison.setInstructorStatementB(INSTRUCTOR_STATEMENT_B);
plagiarismComparisonRepository.save(plagiarismComparison);
var statement = new PlagiarismResource.PlagiarismStatementDTO();
statement.statement = "test statement";
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/student-statement", statement, HttpStatus.FORBIDDEN);
}
use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission in project Artemis by ls1intum.
the class PlagiarismIntegrationTest method saveStudentStatementForStudentB.
/**
* Checks the method updatePlagiarismComparisonStudentStatement for student B
*/
@Test
@WithMockUser(username = "student2", roles = "USER")
public void saveStudentStatementForStudentB() throws Exception {
Course course = database.addCourseWithOneFinishedTextExercise();
TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
plagiarismComparison.setInstructorStatementB(INSTRUCTOR_STATEMENT_B);
PlagiarismSubmission<TextSubmissionElement> submissionB = new PlagiarismSubmission<>();
submissionB.setStudentLogin("student2");
plagiarismComparison.setSubmissionB(submissionB);
plagiarismComparisonRepository.save(plagiarismComparison);
var statement = new PlagiarismResource.PlagiarismStatementDTO();
statement.statement = "test statement";
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/student-statement", statement, HttpStatus.OK);
var comparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
assertThat(comparison.getStudentStatementB()).as("should update student statement").isEqualTo("test statement");
}
Aggregations