Search in sources :

Example 11 with PlagiarismComparison

use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison in project ArTEMiS by ls1intum.

the class PlagiarismIntegrationTest method getPlagiarismCasesForCourse_instructor.

/**
 * Checks the method getPlagiarismCasesForCourse as instructor
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void getPlagiarismCasesForCourse_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 cases = request.getList("/api/courses/" + course.getId() + "/plagiarism-cases", HttpStatus.OK, PlagiarismCaseDTO.class);
    assertThat(cases.size()).isEqualTo(1);
    assertThat(cases.get(0).getComparisons().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 12 with PlagiarismComparison

use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison 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 13 with PlagiarismComparison

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

use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison 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 15 with PlagiarismComparison

use of de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison in project ArTEMiS by ls1intum.

the class PlagiarismIntegrationTest method updatePlagiarismComparisonFinalStatusForStudentA.

/**
 * Checks the method updatePlagiarismComparisonFinalStatus as instructor
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updatePlagiarismComparisonFinalStatusForStudentA() 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");
    plagiarismComparison.setInstructorStatementA(INSTRUCTOR_STATEMENT_A);
    plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
    plagiarismComparison.setStatusA(PlagiarismStatus.NONE);
    plagiarismComparison.setSubmissionA(submissionA);
    plagiarismComparisonRepository.save(plagiarismComparison);
    var plagiarismComparisonStatus = new PlagiarismComparisonStatusDTO();
    plagiarismComparisonStatus.setStatus(PlagiarismStatus.CONFIRMED);
    request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/final-status/student1", plagiarismComparisonStatus, HttpStatus.OK);
    var updatedPlagiarismComparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
    assertThat(updatedPlagiarismComparison.getStatusA()).as("should update status for studentA").isEqualTo(PlagiarismStatus.CONFIRMED);
}
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)

Aggregations

Course (de.tum.in.www1.artemis.domain.Course)37 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)30 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)28 TextSubmissionElement (de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement)27 WithMockUser (org.springframework.security.test.context.support.WithMockUser)27 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)25 Test (org.junit.jupiter.api.Test)25 TextExercise (de.tum.in.www1.artemis.domain.TextExercise)21 AccessForbiddenException (de.tum.in.www1.artemis.web.rest.errors.AccessForbiddenException)17 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)16 User (de.tum.in.www1.artemis.domain.User)15 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)15 PlagiarismCase (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase)10 Post (de.tum.in.www1.artemis.domain.metis.Post)8 PlagiarismComparisonStatusDTO (de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO)6 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)4 ModelingSubmissionElement (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingSubmissionElement)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 PlagiarismStatus (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismStatus)3 PlagiarismCaseDTO (de.tum.in.www1.artemis.web.rest.dto.PlagiarismCaseDTO)3