Search in sources :

Example 11 with ModelingExercise

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

the class DatabaseUtilService method addExerciseGroupsAndExercisesToExam.

public Exam addExerciseGroupsAndExercisesToExam(Exam exam, boolean withProgrammingExercise) {
    // text
    ModelFactory.generateExerciseGroup(true, exam);
    // quiz
    ModelFactory.generateExerciseGroup(true, exam);
    // file upload
    ModelFactory.generateExerciseGroup(true, exam);
    // modeling
    ModelFactory.generateExerciseGroup(true, exam);
    // bonus text
    ModelFactory.generateExerciseGroup(true, exam);
    // not included text
    ModelFactory.generateExerciseGroup(true, exam);
    exam.setNumberOfExercisesInExam(6);
    exam.setMaxPoints(24);
    exam = examRepository.save(exam);
    // NOTE: we have to reassign, otherwise we get problems, because the objects have changed
    var exerciseGroup0 = exam.getExerciseGroups().get(0);
    var exerciseGroup1 = exam.getExerciseGroups().get(1);
    var exerciseGroup2 = exam.getExerciseGroups().get(2);
    var exerciseGroup3 = exam.getExerciseGroups().get(3);
    var exerciseGroup4 = exam.getExerciseGroups().get(4);
    var exerciseGroup5 = exam.getExerciseGroups().get(5);
    TextExercise textExercise1 = ModelFactory.generateTextExerciseForExam(exerciseGroup0);
    TextExercise textExercise2 = ModelFactory.generateTextExerciseForExam(exerciseGroup0);
    textExercise1.setKnowledge(textAssessmentKnowledgeService.createNewKnowledge());
    textExercise2.setKnowledge(textAssessmentKnowledgeService.createNewKnowledge());
    exerciseGroup0.setExercises(Set.of(textExercise1, textExercise2));
    exerciseRepo.save(textExercise1);
    exerciseRepo.save(textExercise2);
    QuizExercise quizExercise1 = createQuizForExam(exerciseGroup1);
    QuizExercise quizExercise2 = createQuizForExam(exerciseGroup1);
    exerciseGroup1.setExercises(Set.of(quizExercise1, quizExercise2));
    exerciseRepo.save(quizExercise1);
    exerciseRepo.save(quizExercise2);
    FileUploadExercise fileUploadExercise1 = ModelFactory.generateFileUploadExerciseForExam("pdf", exerciseGroup2);
    FileUploadExercise fileUploadExercise2 = ModelFactory.generateFileUploadExerciseForExam("pdf", exerciseGroup2);
    exerciseGroup2.setExercises(Set.of(fileUploadExercise1, fileUploadExercise2));
    exerciseRepo.save(fileUploadExercise1);
    exerciseRepo.save(fileUploadExercise2);
    ModelingExercise modelingExercise1 = ModelFactory.generateModelingExerciseForExam(DiagramType.ClassDiagram, exerciseGroup3);
    ModelingExercise modelingExercise2 = ModelFactory.generateModelingExerciseForExam(DiagramType.ClassDiagram, exerciseGroup3);
    modelingExercise1.setKnowledge(modelAssessmentKnowledgeService.createNewKnowledge());
    modelingExercise2.setKnowledge(modelAssessmentKnowledgeService.createNewKnowledge());
    exerciseGroup3.setExercises(Set.of(modelingExercise1, modelingExercise2));
    exerciseRepo.save(modelingExercise1);
    exerciseRepo.save(modelingExercise2);
    TextExercise bonusTextExercise = ModelFactory.generateTextExerciseForExam(exerciseGroup4);
    bonusTextExercise.setIncludedInOverallScore(IncludedInOverallScore.INCLUDED_AS_BONUS);
    bonusTextExercise.setKnowledge(textAssessmentKnowledgeService.createNewKnowledge());
    exerciseGroup4.setExercises(Set.of(bonusTextExercise));
    exerciseRepo.save(bonusTextExercise);
    TextExercise notIncludedTextExercise = ModelFactory.generateTextExerciseForExam(exerciseGroup5);
    notIncludedTextExercise.setIncludedInOverallScore(IncludedInOverallScore.NOT_INCLUDED);
    notIncludedTextExercise.setKnowledge(textAssessmentKnowledgeService.createNewKnowledge());
    exerciseGroup5.setExercises(Set.of(notIncludedTextExercise));
    exerciseRepo.save(notIncludedTextExercise);
    if (withProgrammingExercise) {
        // programming
        ModelFactory.generateExerciseGroup(true, exam);
        exam.setNumberOfExercisesInExam(7);
        exam.setMaxPoints(29);
        exam = examRepository.save(exam);
        var exerciseGroup6 = exam.getExerciseGroups().get(6);
        // Programming exercises need a proper setup for 'prepare exam start' to work
        ProgrammingExercise programmingExercise1 = ModelFactory.generateProgrammingExerciseForExam(exerciseGroup6);
        exerciseRepo.save(programmingExercise1);
        addTemplateParticipationForProgrammingExercise(programmingExercise1);
        addSolutionParticipationForProgrammingExercise(programmingExercise1);
        exerciseGroup6.setExercises(Set.of(programmingExercise1));
    }
    return exam;
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise)

Example 12 with ModelingExercise

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

the class DatabaseUtilService method createCourseWithAllExerciseTypesAndParticipationsAndSubmissionsAndResults.

public Course createCourseWithAllExerciseTypesAndParticipationsAndSubmissionsAndResults(boolean hasAssessmentDueDatePassed) {
    Course course = ModelFactory.generateCourse(null, pastTimestamp, futureTimestamp, new HashSet<>(), "tumuser", "tutor", "editor", "instructor");
    ModelingExercise modelingExercise = ModelFactory.generateModelingExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, DiagramType.ClassDiagram, course);
    TextExercise textExercise = ModelFactory.generateTextExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, course);
    FileUploadExercise fileUploadExercise = ModelFactory.generateFileUploadExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, "png", course);
    ProgrammingExercise programmingExercise = ModelFactory.generateProgrammingExercise(pastTimestamp, futureTimestamp, course);
    QuizExercise quizExercise = ModelFactory.generateQuizExercise(pastTimestamp, futureTimestamp, course);
    // Set assessment due dates
    if (hasAssessmentDueDatePassed) {
        modelingExercise.setAssessmentDueDate(ZonedDateTime.now().minusMinutes(10L));
        textExercise.setAssessmentDueDate(ZonedDateTime.now().minusMinutes(10L));
        fileUploadExercise.setAssessmentDueDate(ZonedDateTime.now().minusMinutes(10L));
        programmingExercise.setAssessmentDueDate(ZonedDateTime.now().minusMinutes(10L));
        quizExercise.setAssessmentDueDate(ZonedDateTime.now().minusMinutes(10L));
    } else {
        modelingExercise.setAssessmentDueDate(ZonedDateTime.now().plusMinutes(10L));
        textExercise.setAssessmentDueDate(ZonedDateTime.now().plusMinutes(10L));
        fileUploadExercise.setAssessmentDueDate(ZonedDateTime.now().plusMinutes(10L));
        programmingExercise.setAssessmentDueDate(ZonedDateTime.now().plusMinutes(10L));
        quizExercise.setAssessmentDueDate(ZonedDateTime.now().plusMinutes(10L));
    }
    // Add exercises to course
    course.addExercises(modelingExercise);
    course.addExercises(textExercise);
    course.addExercises(fileUploadExercise);
    course.addExercises(programmingExercise);
    course.addExercises(quizExercise);
    // Save course and exercises to database
    Course courseSaved = courseRepo.save(course);
    modelingExercise = exerciseRepo.save(modelingExercise);
    textExercise = exerciseRepo.save(textExercise);
    fileUploadExercise = exerciseRepo.save(fileUploadExercise);
    programmingExercise = exerciseRepo.save(programmingExercise);
    quizExercise = exerciseRepo.save(quizExercise);
    // Get user and setup participations
    User user = (userRepo.findOneByLogin("student1")).get();
    StudentParticipation participationModeling = ModelFactory.generateStudentParticipation(InitializationState.FINISHED, modelingExercise, user);
    StudentParticipation participationText = ModelFactory.generateStudentParticipation(InitializationState.FINISHED, textExercise, user);
    StudentParticipation participationFileUpload = ModelFactory.generateStudentParticipation(InitializationState.FINISHED, fileUploadExercise, user);
    StudentParticipation participationQuiz = ModelFactory.generateStudentParticipation(InitializationState.FINISHED, quizExercise, user);
    StudentParticipation participationProgramming = ModelFactory.generateStudentParticipation(InitializationState.INITIALIZED, programmingExercise, user);
    // Save participations
    participationModeling = studentParticipationRepo.save(participationModeling);
    participationText = studentParticipationRepo.save(participationText);
    participationFileUpload = studentParticipationRepo.save(participationFileUpload);
    participationQuiz = studentParticipationRepo.save(participationQuiz);
    participationProgramming = studentParticipationRepo.save(participationProgramming);
    // Setup results
    Result resultModeling = ModelFactory.generateResult(true, 10D);
    resultModeling.setAssessmentType(AssessmentType.MANUAL);
    resultModeling.setCompletionDate(ZonedDateTime.now());
    Result resultText = ModelFactory.generateResult(true, 12D);
    resultText.setAssessmentType(AssessmentType.MANUAL);
    resultText.setCompletionDate(ZonedDateTime.now());
    Result resultFileUpload = ModelFactory.generateResult(true, 0D);
    resultFileUpload.setAssessmentType(AssessmentType.MANUAL);
    resultFileUpload.setCompletionDate(ZonedDateTime.now());
    Result resultQuiz = ModelFactory.generateResult(true, 0D);
    resultQuiz.setAssessmentType(AssessmentType.AUTOMATIC);
    resultQuiz.setCompletionDate(ZonedDateTime.now());
    Result resultProgramming = ModelFactory.generateResult(true, 20D);
    resultProgramming.setAssessmentType(AssessmentType.AUTOMATIC);
    resultProgramming.setCompletionDate(ZonedDateTime.now());
    // Connect participations to results and vice versa
    resultModeling.setParticipation(participationModeling);
    resultText.setParticipation(participationText);
    resultFileUpload.setParticipation(participationFileUpload);
    resultQuiz.setParticipation(participationQuiz);
    resultProgramming.setParticipation(participationProgramming);
    participationModeling.addResult(resultModeling);
    participationText.addResult(resultText);
    participationFileUpload.addResult(resultFileUpload);
    participationQuiz.addResult(resultQuiz);
    participationProgramming.addResult(resultProgramming);
    // Save results and participations
    resultModeling = resultRepo.save(resultModeling);
    resultText = resultRepo.save(resultText);
    resultFileUpload = resultRepo.save(resultFileUpload);
    resultQuiz = resultRepo.save(resultQuiz);
    resultProgramming = resultRepo.save(resultProgramming);
    participationModeling = studentParticipationRepo.save(participationModeling);
    participationText = studentParticipationRepo.save(participationText);
    participationFileUpload = studentParticipationRepo.save(participationFileUpload);
    participationQuiz = studentParticipationRepo.save(participationQuiz);
    participationProgramming = studentParticipationRepo.save(participationProgramming);
    // Connect exercises with participations
    modelingExercise.addParticipation(participationModeling);
    textExercise.addParticipation(participationText);
    fileUploadExercise.addParticipation(participationFileUpload);
    quizExercise.addParticipation(participationQuiz);
    programmingExercise.addParticipation(participationProgramming);
    // Setup submissions and connect with participations
    ModelingSubmission modelingSubmission = ModelFactory.generateModelingSubmission("model1", true);
    TextSubmission textSubmission = ModelFactory.generateTextSubmission("text of text submission", Language.ENGLISH, true);
    FileUploadSubmission fileUploadSubmission = ModelFactory.generateFileUploadSubmission(true);
    QuizSubmission quizSubmission = ModelFactory.generateQuizSubmission(true);
    ProgrammingSubmission programmingSubmission = ModelFactory.generateProgrammingSubmission(true);
    // Save submissions
    modelingSubmission = submissionRepository.save(modelingSubmission);
    textSubmission = submissionRepository.save(textSubmission);
    fileUploadSubmission = submissionRepository.save(fileUploadSubmission);
    quizSubmission = submissionRepository.save(quizSubmission);
    programmingSubmission = submissionRepository.save(programmingSubmission);
    modelingSubmission.setParticipation(participationModeling);
    modelingSubmission.addResult(resultModeling);
    textSubmission.setParticipation(participationText);
    textSubmission.addResult(resultText);
    fileUploadSubmission.setParticipation(participationFileUpload);
    fileUploadSubmission.addResult(resultFileUpload);
    quizSubmission.setParticipation(participationQuiz);
    quizSubmission.addResult(resultQuiz);
    programmingSubmission.setParticipation(participationProgramming);
    programmingSubmission.addResult(resultProgramming);
    // Save submissions
    modelingSubmission = submissionRepository.save(modelingSubmission);
    textSubmission = submissionRepository.save(textSubmission);
    fileUploadSubmission = submissionRepository.save(fileUploadSubmission);
    quizSubmission = submissionRepository.save(quizSubmission);
    programmingSubmission = submissionRepository.save(programmingSubmission);
    // Save exercises
    exerciseRepo.save(modelingExercise);
    exerciseRepo.save(textExercise);
    exerciseRepo.save(fileUploadExercise);
    exerciseRepo.save(programmingExercise);
    exerciseRepo.save(quizExercise);
    // Connect participations with submissions
    participationModeling.setSubmissions(Set.of(modelingSubmission));
    participationText.setSubmissions(Set.of(textSubmission));
    participationFileUpload.setSubmissions(Set.of(fileUploadSubmission));
    participationQuiz.setSubmissions(Set.of(quizSubmission));
    participationProgramming.setSubmissions(Set.of(programmingSubmission));
    // Save participations
    studentParticipationRepo.save(participationModeling);
    studentParticipationRepo.save(participationText);
    studentParticipationRepo.save(participationFileUpload);
    studentParticipationRepo.save(participationQuiz);
    studentParticipationRepo.save(participationProgramming);
    return courseSaved;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 13 with ModelingExercise

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

the class DatabaseUtilService method addCourseInOtherInstructionGroupAndExercise.

/**
 * @param title The title reflect the genre of exercise that will be added to the course
 */
public void addCourseInOtherInstructionGroupAndExercise(String title) {
    Course course = ModelFactory.generateCourse(null, pastTimestamp, futureFutureTimestamp, new HashSet<>(), "tumuser", "tutor", "editor", "other-instructors");
    if ("Programming".equals(title)) {
        course = courseRepo.save(course);
        var programmingExercise = (ProgrammingExercise) new ProgrammingExercise().course(course);
        populateProgrammingExercise(programmingExercise, "TSTEXC", "Programming", false);
        programmingExercise.setPresentationScoreEnabled(course.getPresentationScore() != 0);
        programmingExercise = programmingExerciseRepository.save(programmingExercise);
        course.addExercises(programmingExercise);
        programmingExercise = addSolutionParticipationForProgrammingExercise(programmingExercise);
        programmingExercise = addTemplateParticipationForProgrammingExercise(programmingExercise);
        assertThat(programmingExercise.getPresentationScoreEnabled()).as("presentation score is enabled").isTrue();
    } else if ("Text".equals(title)) {
        TextExercise textExercise = ModelFactory.generateTextExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, course);
        textExercise.setTitle("Text");
        course.addExercises(textExercise);
        courseRepo.save(course);
        exerciseRepo.save(textExercise);
    } else if ("ClassDiagram".equals(title)) {
        ModelingExercise modelingExercise = ModelFactory.generateModelingExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, DiagramType.ClassDiagram, course);
        modelingExercise.setTitle("ClassDiagram");
        course.addExercises(modelingExercise);
        courseRepo.save(course);
        exerciseRepo.save(modelingExercise);
    }
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise)

Example 14 with ModelingExercise

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

the class DatabaseUtilService method addModelingAssessmentForSubmission.

public Result addModelingAssessmentForSubmission(ModelingExercise exercise, ModelingSubmission submission, String login, boolean submit) {
    Feedback feedback1 = feedbackRepo.save(new Feedback().detailText("detail1"));
    Feedback feedback2 = feedbackRepo.save(new Feedback().detailText("detail2"));
    List<Feedback> feedbacks = new ArrayList<>();
    feedbacks.add(feedback1);
    feedbacks.add(feedback2);
    Result result = assessmentService.saveManualAssessment(submission, feedbacks, null);
    result.setParticipation(submission.getParticipation().results(null));
    result.setAssessor(getUserByLogin(login));
    resultRepo.save(result);
    if (submit) {
        assessmentService.submitManualAssessment(result.getId(), exercise, submission.getSubmissionDate());
    }
    return resultRepo.findWithEagerSubmissionAndFeedbackAndAssessorById(result.getId()).get();
}
Also used : TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 15 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise 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)

Aggregations

ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)196 WithMockUser (org.springframework.security.test.context.support.WithMockUser)132 Test (org.junit.jupiter.api.Test)126 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)96 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)72 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)28 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)26 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)16 BeforeEach (org.junit.jupiter.api.BeforeEach)16 Course (de.tum.in.www1.artemis.domain.Course)14 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)14 ZonedDateTime (java.time.ZonedDateTime)12 Exam (de.tum.in.www1.artemis.domain.exam.Exam)10 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)10 TeamAssignmentPayload (de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload)9 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8