Search in sources :

Example 11 with TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement 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)

Example 12 with TextSubmissionElement

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

the class PlagiarismIntegrationTest method saveStudentStatementForStudentA.

/**
 * Checks the method updatePlagiarismComparisonStudentStatement for student A
 */
@Test
@WithMockUser(username = "student1", roles = "USER")
public void saveStudentStatementForStudentA() 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.setInstructorStatementA(INSTRUCTOR_STATEMENT_A);
    PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
    submissionA.setStudentLogin("student1");
    plagiarismComparison.setSubmissionA(submissionA);
    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.getStudentStatementA()).as("should update student 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 13 with TextSubmissionElement

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

the class PlagiarismIntegrationTest method saveInstructorStatementForStudentA.

/**
 * Checks the method updatePlagiarismComparisonInstructorStatement for student A
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveInstructorStatementForStudentA() 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<>();
    submissionA.setStudentLogin("student1");
    plagiarismComparison.setSubmissionA(submissionA);
    plagiarismComparisonRepository.save(plagiarismComparison);
    var statement = new PlagiarismResource.PlagiarismStatementDTO();
    statement.statement = "test statement";
    request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/instructor-statement/student1", statement, HttpStatus.OK);
    var comparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
    assertThat(comparison.getInstructorStatementA()).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 14 with TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement 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();
}
Also used : PlagiarismComparison(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison) PlagiarismCase(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase) PlagiarismSubmission(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission) Post(de.tum.in.www1.artemis.domain.metis.Post) 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 TextSubmissionElement

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement 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);
}
Also used : User(de.tum.in.www1.artemis.domain.User) WithMockUser(org.springframework.security.test.context.support.WithMockUser) TextSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement) BeforeEach(org.junit.jupiter.api.BeforeEach)

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