Search in sources :

Example 6 with ModelingSubmission

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

the class DatabaseUtilService method createCourseWithTestModelingAndFileUploadExercisesAndSubmissions.

public Course createCourseWithTestModelingAndFileUploadExercisesAndSubmissions() throws Exception {
    Course course = addCourseWithModelingAndTextAndFileUploadExercise();
    course.setEndDate(ZonedDateTime.now().minusMinutes(5));
    course = courseRepo.save(course);
    var fileUploadExercise = findFileUploadExerciseWithTitle(course.getExercises(), "FileUpload");
    createFileUploadSubmissionWithFile(fileUploadExercise, "uploaded-file.png");
    var textExercise = findTextExerciseWithTitle(course.getExercises(), "Text");
    var textSubmission = ModelFactory.generateTextSubmission("example text", Language.ENGLISH, true);
    saveTextSubmission(textExercise, textSubmission, "student1");
    var modelingExercise = findModelingExerciseWithTitle(course.getExercises(), "Modeling");
    createAndSaveParticipationForExercise(modelingExercise, "student1");
    String emptyActivityModel = FileUtils.loadFileFromResources("test-data/model-submission/empty-activity-diagram.json");
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(emptyActivityModel, true);
    addSubmission(modelingExercise, submission, "student1");
    return course;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) JsonParser.parseString(com.google.gson.JsonParser.parseString)

Example 7 with ModelingSubmission

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

the class DatabaseUtilService method createCourseWithExamAndExercises.

public Course createCourseWithExamAndExercises() throws IOException {
    Course course = courseRepo.save(addEmptyCourse());
    // Create a file upload exercise with a dummy submission file
    var exerciseGroup1 = exerciseGroupRepository.save(new ExerciseGroup());
    var fileUploadExercise = ModelFactory.generateFileUploadExerciseForExam(".png", exerciseGroup1);
    fileUploadExercise = exerciseRepo.save(fileUploadExercise);
    createFileUploadSubmissionWithFile(fileUploadExercise, "uploaded-file.png");
    exerciseGroup1.addExercise(fileUploadExercise);
    exerciseGroup1 = exerciseGroupRepository.save(exerciseGroup1);
    // Create a text exercise with a dummy submission file
    var exerciseGroup2 = exerciseGroupRepository.save(new ExerciseGroup());
    var textExercise = ModelFactory.generateTextExerciseForExam(exerciseGroup2);
    textExercise = exerciseRepo.save(textExercise);
    var textSubmission = ModelFactory.generateTextSubmission("example text", Language.ENGLISH, true);
    saveTextSubmission(textExercise, textSubmission, "student1");
    exerciseGroup2.addExercise(textExercise);
    exerciseGroup2 = exerciseGroupRepository.save(exerciseGroup2);
    // Create a modeling exercise with a dummy submission file
    var exerciseGroup3 = exerciseGroupRepository.save(new ExerciseGroup());
    var modelingExercise = ModelFactory.generateModelingExerciseForExam(DiagramType.ClassDiagram, exerciseGroup2);
    modelingExercise = exerciseRepo.save(modelingExercise);
    String emptyActivityModel = FileUtils.loadFileFromResources("test-data/model-submission/empty-activity-diagram.json");
    var modelingSubmission = ModelFactory.generateModelingSubmission(emptyActivityModel, true);
    addSubmission(modelingExercise, modelingSubmission, "student1");
    exerciseGroup3.addExercise(modelingExercise);
    exerciseGroupRepository.save(exerciseGroup3);
    Exam exam = addExam(course);
    exam.setEndDate(ZonedDateTime.now().minusMinutes(5));
    exam.addExerciseGroup(exerciseGroup1);
    exam.addExerciseGroup(exerciseGroup2);
    examRepository.save(exam);
    return course;
}
Also used : JsonParser.parseString(com.google.gson.JsonParser.parseString) ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup) StudentExam(de.tum.in.www1.artemis.domain.exam.StudentExam) Exam(de.tum.in.www1.artemis.domain.exam.Exam)

Example 8 with ModelingSubmission

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

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

the class DatabaseUtilService method addExampleSubmission.

public ExampleSubmission addExampleSubmission(ExampleSubmission exampleSubmission) {
    Submission submission;
    if (exampleSubmission.getSubmission() instanceof ModelingSubmission) {
        submission = modelingSubmissionRepo.save((ModelingSubmission) exampleSubmission.getSubmission());
    } else {
        submission = textSubmissionRepo.save((TextSubmission) exampleSubmission.getSubmission());
    }
    exampleSubmission.setSubmission(submission);
    return exampleSubmissionRepo.save(exampleSubmission);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)

Example 10 with ModelingSubmission

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

Aggregations

ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)160 Test (org.junit.jupiter.api.Test)108 WithMockUser (org.springframework.security.test.context.support.WithMockUser)106 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)36 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)12 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8 ModelingSubmission (de.tum.in.www1.artemis.domain.ModelingSubmission)6 Result (de.tum.in.www1.artemis.domain.Result)6 ModelElement (de.tum.in.www1.artemis.domain.modeling.ModelElement)6 ModelClusterFactory (de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory)6 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)4 ExerciseHint (de.tum.in.www1.artemis.domain.hestia.ExerciseHint)4 Participation (de.tum.in.www1.artemis.domain.participation.Participation)4 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)4 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)4