Search in sources :

Example 31 with TextPlagiarismResult

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult 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 32 with TextPlagiarismResult

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult 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 33 with TextPlagiarismResult

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

Example 34 with TextPlagiarismResult

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

use of de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult 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));
}
Also used : Post(de.tum.in.www1.artemis.domain.metis.Post) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) PlagiarismCase(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) MimeMessage(javax.mail.internet.MimeMessage) PlagiarismSubmission(de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission) TextSubmissionElement(de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)31 TextSubmissionElement (de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement)25 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)23 WithMockUser (org.springframework.security.test.context.support.WithMockUser)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 Test (org.junit.jupiter.api.Test)21 PlagiarismComparisonStatusDTO (de.tum.in.www1.artemis.web.rest.dto.PlagiarismComparisonStatusDTO)6 ProgrammingExercise (de.tum.in.www1.artemis.domain.ProgrammingExercise)4 Post (de.tum.in.www1.artemis.domain.metis.Post)4 PlagiarismCase (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismCase)4 FeatureToggle (de.tum.in.www1.artemis.service.feature.FeatureToggle)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 JPlag (de.jplag.JPlag)2 JPlagResult (de.jplag.JPlagResult)2 JPlagOptions (de.jplag.options.JPlagOptions)2 TextSubmission (de.tum.in.www1.artemis.domain.TextSubmission)2 User (de.tum.in.www1.artemis.domain.User)2