Search in sources :

Example 26 with TextExercise

use of de.tum.in.www1.artemis.domain.TextExercise 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 27 with TextExercise

use of de.tum.in.www1.artemis.domain.TextExercise 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 28 with TextExercise

use of de.tum.in.www1.artemis.domain.TextExercise 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 29 with TextExercise

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

the class ModelingExerciseImportService method copyModelingExerciseBasis.

/**
 * This helper method copies all attributes of the {@code importedExercise} into the new exercise.
 * Here we ignore all external entities as well as the start-, end-, and assessment due date.
 *
 * @param importedExercise The exercise from which to copy the basis
 * @return the cloned TextExercise basis
 */
@NotNull
private ModelingExercise copyModelingExerciseBasis(Exercise importedExercise) {
    log.debug("Copying the exercise basis from {}", importedExercise);
    ModelingExercise newExercise = new ModelingExercise();
    super.copyExerciseBasis(newExercise, importedExercise);
    newExercise.setDiagramType(((ModelingExercise) importedExercise).getDiagramType());
    newExercise.setExampleSolutionModel(((ModelingExercise) importedExercise).getExampleSolutionModel());
    newExercise.setExampleSolutionExplanation(((ModelingExercise) importedExercise).getExampleSolutionExplanation());
    return newExercise;
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) NotNull(javax.validation.constraints.NotNull)

Example 30 with TextExercise

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

the class DatabaseUtilService method generateTestRunForInstructor.

public StudentExam generateTestRunForInstructor(Exam exam, User instructor, List<Exercise> exercises) {
    var testRun = ModelFactory.generateExamTestRun(exam);
    testRun.setUser(instructor);
    examRepository.findWithExerciseGroupsAndExercisesById(exam.getId()).get();
    for (final var exercise : exercises) {
        testRun.addExercise(exercise);
        assertThat(exercise.isExamExercise()).isTrue();
        Submission submission;
        if (exercise instanceof ModelingExercise) {
            submission = addModelingSubmission((ModelingExercise) exercise, ModelFactory.generateModelingSubmission("", false), instructor.getLogin());
        } else if (exercise instanceof TextExercise) {
            submission = saveTextSubmission((TextExercise) exercise, ModelFactory.generateTextSubmission("", null, false), instructor.getLogin());
        } else {
            submission = new ProgrammingSubmission().submitted(true);
            addProgrammingSubmission((ProgrammingExercise) exercise, (ProgrammingSubmission) submission, instructor.getLogin());
            submission = submissionRepository.save(submission);
        }
        var studentParticipation = (StudentParticipation) submission.getParticipation();
        studentParticipation.setTestRun(true);
        studentParticipationRepo.save(studentParticipation);
    }
    return testRun;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise)

Aggregations

WithMockUser (org.springframework.security.test.context.support.WithMockUser)109 Test (org.junit.jupiter.api.Test)105 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)58 TextExercise (de.tum.in.www1.artemis.domain.TextExercise)51 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)50 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)44 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)41 Course (de.tum.in.www1.artemis.domain.Course)31 Exam (de.tum.in.www1.artemis.domain.exam.Exam)30 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)30 BeforeEach (org.junit.jupiter.api.BeforeEach)26 TextSubmissionElement (de.tum.in.www1.artemis.domain.plagiarism.text.TextSubmissionElement)25 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)23 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)22 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)22 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)22 Participation (de.tum.in.www1.artemis.domain.participation.Participation)16 TextAssessmentDTO (de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO)16 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14