Search in sources :

Example 6 with TextExercise

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

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

the class DatabaseUtilService method addCourseExamExerciseGroupWithOneTextExercise.

public TextExercise addCourseExamExerciseGroupWithOneTextExercise() {
    ExerciseGroup exerciseGroup = addExerciseGroupWithExamAndCourse(true);
    TextExercise textExercise = ModelFactory.generateTextExerciseForExam(exerciseGroup);
    final var exercisesNrBefore = exerciseRepo.count();
    textExercise.setKnowledge(textAssessmentKnowledgeService.createNewKnowledge());
    exerciseRepo.save(textExercise);
    assertThat(exercisesNrBefore + 1).as("one exercise got stored").isEqualTo(exerciseRepo.count());
    return textExercise;
}
Also used : ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup)

Example 8 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)

Example 9 with TextExercise

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

the class DatabaseUtilService method addCourseWithExercisesAndSubmissions.

/**
 * With this method we can generate a course. We can specify the number of exercises. To not only test one type, this method generates modeling, file-upload and text
 * exercises in a cyclic manner.
 *
 * @param numberOfExercises             number of generated exercises. E.g. if you set it to 4, 2 modeling exercises, one text and one file-upload exercise will be generated.
 *                                      (thats why there is the %3 check)
 * @param numberOfSubmissionPerExercise for each exercise this number of submissions will be generated. E.g. if you have 2 exercises, and set this to 4, in total 8
 *                                      submissions will be created.
 * @param numberOfAssessments           generates the assessments for a submission of an exercise. Example from abobe, 2 exrecises, 4 submissions each. If you set
 *                                      numberOfAssessments to 2, for each exercise 2 assessmetns will be created. In total there will be 4 assessments then. (by two
 *                                      different tutors, as each exercise is assessed by an individual tutor. There are 4 tutors that create assessments)
 * @param numberOfComplaints            generates the complaints for assessments, in the same way as results are created.
 * @param typeComplaint                 true: complaintType==COMPLAINT | false: complaintType==MORE_FEEDBACK
 * @param numberComplaintResponses      generates responses for the complaint/feedback request (as above)
 * @param validModel                    model for the modeling submission
 * @return - the generated course
 */
public Course addCourseWithExercisesAndSubmissions(int numberOfExercises, int numberOfSubmissionPerExercise, int numberOfAssessments, int numberOfComplaints, boolean typeComplaint, int numberComplaintResponses, String validModel) {
    Course course = ModelFactory.generateCourse(null, pastTimestamp, futureFutureTimestamp, new HashSet<>(), "tumuser", "tutor", "editor", "instructor");
    var tutors = userRepo.getTutors(course);
    for (int i = 0; i < numberOfExercises; i++) {
        var currentUser = tutors.get(i % 4);
        if ((i % 3) == 0) {
            ModelingExercise modelingExercise = ModelFactory.generateModelingExercise(pastTimestamp, pastTimestamp.plusHours(1), futureTimestamp, DiagramType.ClassDiagram, course);
            modelingExercise.setTitle("Modeling" + i);
            course.addExercises(modelingExercise);
            course = courseRepo.save(course);
            exerciseRepo.save(modelingExercise);
            for (int j = 1; j <= numberOfSubmissionPerExercise; j++) {
                StudentParticipation participation = createAndSaveParticipationForExercise(modelingExercise, "student" + j);
                ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
                modelSubmissionService.save(submission, modelingExercise, "student" + j);
                studentParticipationRepo.save(participation);
                if (numberOfAssessments >= j) {
                    Result result = generateResult(submission, currentUser);
                    submission.addResult(result);
                    participation.addResult(result);
                    studentParticipationRepo.save(participation);
                    modelingSubmissionRepo.save(submission);
                    generateComplaintAndResponses(j, numberOfComplaints, numberComplaintResponses, typeComplaint, result, currentUser);
                }
            }
        } else if ((i % 3) == 1) {
            TextExercise textExercise = ModelFactory.generateTextExercise(pastTimestamp, pastTimestamp.plusHours(1), futureTimestamp, course);
            textExercise.setTitle("Text" + i);
            course.addExercises(textExercise);
            course = courseRepo.save(course);
            exerciseRepo.save(textExercise);
            for (int j = 1; j <= numberOfSubmissionPerExercise; j++) {
                TextSubmission submission = ModelFactory.generateTextSubmission("submissionText", Language.ENGLISH, true);
                submission = saveTextSubmission(textExercise, submission, "student" + j);
                if (numberOfAssessments >= j) {
                    Result result = generateResult(submission, currentUser);
                    submission.addResult(result);
                    saveResultInParticipation(submission, result);
                    textSubmissionRepo.save(submission);
                    generateComplaintAndResponses(j, numberOfComplaints, numberComplaintResponses, typeComplaint, result, currentUser);
                }
            }
        } else if ((i % 3) == 2) {
            FileUploadExercise fileUploadExercise = ModelFactory.generateFileUploadExercise(pastTimestamp, pastTimestamp.plusHours(1), futureTimestamp, "png,pdf", course);
            fileUploadExercise.setTitle("FileUpload" + i);
            course.addExercises(fileUploadExercise);
            course = courseRepo.save(course);
            exerciseRepo.save(fileUploadExercise);
            for (int j = 1; j <= numberOfSubmissionPerExercise; j++) {
                FileUploadSubmission submission = ModelFactory.generateFileUploadSubmissionWithFile(true, "path/to/file.pdf");
                saveFileUploadSubmission(fileUploadExercise, submission, "student" + j);
                if (numberOfAssessments >= j) {
                    Result result = generateResult(submission, currentUser);
                    saveResultInParticipation(submission, result);
                    fileUploadSubmissionRepo.save(submission);
                    generateComplaintAndResponses(j, numberOfComplaints, numberComplaintResponses, typeComplaint, result, currentUser);
                }
            }
        }
    }
    course = courseRepo.save(course);
    return course;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 10 with TextExercise

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

the class DatabaseUtilService method addCourseWithModelingAndTextAndFileUploadExercise.

public Course addCourseWithModelingAndTextAndFileUploadExercise() {
    Course course = ModelFactory.generateCourse(null, pastTimestamp, futureFutureTimestamp, new HashSet<>(), "tumuser", "tutor", "editor", "instructor");
    ModelingExercise modelingExercise = ModelFactory.generateModelingExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, DiagramType.ClassDiagram, course);
    modelingExercise.setTitle("Modeling");
    course.addExercises(modelingExercise);
    TextExercise textExercise = ModelFactory.generateTextExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, course);
    textExercise.setTitle("Text");
    course.addExercises(textExercise);
    FileUploadExercise fileUploadExercise = ModelFactory.generateFileUploadExercise(pastTimestamp, pastTimestamp, futureFutureTimestamp, "png,pdf", course);
    fileUploadExercise.setTitle("FileUpload");
    course.addExercises(fileUploadExercise);
    course = courseRepo.save(course);
    exerciseRepo.save(modelingExercise);
    exerciseRepo.save(textExercise);
    exerciseRepo.save(fileUploadExercise);
    return course;
}
Also used : 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