Search in sources :

Example 1 with TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement 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);
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) PlagiarismSubmission(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission) TextExercise(de.tum.in.www1.artemis.domain.TextExercise) Course(de.tum.in.www1.artemis.domain.Course) TextSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement) PlagiarismComparisonStatusDTO(de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 2 with TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement in project Artemis by ls1intum.

the class PlagiarismIntegrationTest method getPlagiarismComparisonsForEditor.

@Test
@WithMockUser(username = "editor1", roles = "EDITOR")
public void getPlagiarismComparisonsForEditor() throws Exception {
    Course course = database.addCourseWithOneFinishedTextExercise();
    TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
    TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
    PlagiarismComparison<TextSubmissionElement> plagiarismComparison1 = new PlagiarismComparison<>();
    plagiarismComparison1.setPlagiarismResult(textPlagiarismResult);
    plagiarismComparison1.setStatus(PlagiarismStatus.CONFIRMED);
    var savedComparison = plagiarismComparisonRepository.save(plagiarismComparison1);
    var comparison = request.get("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + savedComparison.getId() + "/for-split-view", HttpStatus.OK, plagiarismComparison1.getClass());
    assertThat(comparison.getPlagiarismResult()).isEqualTo(textPlagiarismResult);
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) TextExercise(de.tum.in.www1.artemis.domain.TextExercise) Course(de.tum.in.www1.artemis.domain.Course) TextSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 3 with TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement in project Artemis by ls1intum.

the class PlagiarismIntegrationTest method getPlagiarismComparisonsForCourse_instructor.

/**
 * Checks the method getPlagiarismComparisonsForCourse as instructor
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void getPlagiarismComparisonsForCourse_instructor() throws Exception {
    Course course = database.addCourseWithOneFinishedTextExercise();
    TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
    TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
    PlagiarismComparison<TextSubmissionElement> plagiarismComparison1 = new PlagiarismComparison<>();
    plagiarismComparison1.setPlagiarismResult(textPlagiarismResult);
    plagiarismComparison1.setStatus(PlagiarismStatus.CONFIRMED);
    PlagiarismComparison<TextSubmissionElement> plagiarismComparison2 = new PlagiarismComparison<>();
    plagiarismComparison2.setPlagiarismResult(textPlagiarismResult);
    plagiarismComparison2.setStatus(PlagiarismStatus.CONFIRMED);
    plagiarismComparisonRepository.save(plagiarismComparison1);
    plagiarismComparisonRepository.save(plagiarismComparison2);
    var comparisons = request.getList("/api/courses/" + course.getId() + "/plagiarism-cases", HttpStatus.OK, plagiarismComparison1.getClass());
    assertThat(comparisons.size()).isEqualTo(2);
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) TextExercise(de.tum.in.www1.artemis.domain.TextExercise) Course(de.tum.in.www1.artemis.domain.Course) TextSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 4 with TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement in project Artemis by ls1intum.

the class PlagiarismIntegrationTest method saveInstructorStatementForStudentB.

/**
 * Checks the method updatePlagiarismComparisonInstructorStatement for student B
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveInstructorStatementForStudentB() 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);
    PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
    PlagiarismSubmission<TextSubmissionElement> submissionB = new PlagiarismSubmission<>();
    submissionA.setStudentLogin("student1");
    submissionB.setStudentLogin("student2");
    plagiarismComparison.setSubmissionA(submissionA);
    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() + "/instructor-statement/student2", statement, HttpStatus.OK);
    var comparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
    assertThat(comparison.getInstructorStatementB()).as("should update instructor statement").isEqualTo("test statement");
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) PlagiarismSubmission(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission) TextExercise(de.tum.in.www1.artemis.domain.TextExercise) Course(de.tum.in.www1.artemis.domain.Course) TextSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 5 with TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement in project Artemis by ls1intum.

the class PlagiarismIntegrationTest method saveInstructorStatementForUnknownStudent.

/**
 * Checks the method updatePlagiarismComparisonInstructorStatement for unknown student
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveInstructorStatementForUnknownStudent() 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);
    PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
    PlagiarismSubmission<TextSubmissionElement> submissionB = new PlagiarismSubmission<>();
    submissionA.setStudentLogin("student1");
    submissionB.setStudentLogin("student2");
    plagiarismComparison.setSubmissionA(submissionA);
    plagiarismComparison.setSubmissionB(submissionB);
    plagiarismComparisonRepository.save(plagiarismComparison);
    request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/instructor-statement/student42", new PlagiarismResource.PlagiarismStatementDTO(), HttpStatus.NOT_FOUND);
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) PlagiarismResource(de.tum.in.www1.artemis.web.rest.PlagiarismResource) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) PlagiarismSubmission(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission) TextExercise(de.tum.in.www1.artemis.domain.TextExercise) Course(de.tum.in.www1.artemis.domain.Course) TextSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Aggregations

TextSubmissionElement (de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement)27 WithMockUser (org.springframework.security.test.context.support.WithMockUser)25 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)23 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)23 Test (org.junit.jupiter.api.Test)23 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)22 Course (de.tum.in.www1.artemis.domain.Course)21 TextExercise (de.tum.in.www1.artemis.domain.TextExercise)21 PlagiarismComparisonStatusDTO (de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO)6 Post (de.tum.in.www1.artemis.domain.metis.Post)4 PlagiarismCase (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 User (de.tum.in.www1.artemis.domain.User)2 PlagiarismResource (de.tum.in.www1.artemis.web.rest.PlagiarismResource)2 MimeMessage (javax.mail.internet.MimeMessage)2