Search in sources :

Example 91 with ModelingExercise

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

the class ProgrammingSubmissionIntegrationTest method triggerFailedBuildSubmissionNotFound.

@Test
@WithMockUser(username = "student1", roles = "USER")
void triggerFailedBuildSubmissionNotFound() throws Exception {
    String login = "student1";
    Course course = database.addCourseWithDifferentModelingExercises();
    ModelingExercise classExercise = database.findModelingExerciseWithTitle(course.getExercises(), "ClassDiagram");
    ModelingSubmission modelingSubmission = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/empty-class-diagram.json"), true);
    modelingSubmission = database.addModelingSubmission(classExercise, modelingSubmission, login);
    String url = "/api/programming-submissions/" + modelingSubmission.getParticipation().getId() + "/trigger-failed-build";
    request.postWithoutLocation(url, null, HttpStatus.NOT_FOUND, new HttpHeaders());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 92 with ModelingExercise

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

the class AssessmentServiceTest method createModelingExerciseSubmissionAndCalculateScore.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createModelingExerciseSubmissionAndCalculateScore() {
    ModelingExercise exercise = createModelingExerciseWithSGI(course1);
    Submission submissionWithoutResult = new ModelingSubmission();
    submissionWithoutResult.setSubmissionDate(pastTimestamp.plusMinutes(3L));
    submissionWithoutResult = database.addSubmission(exercise, submissionWithoutResult, "student1");
    database.addSubmission((StudentParticipation) submissionWithoutResult.getParticipation(), submissionWithoutResult);
    List<Feedback> feedbacks = createFeedback(exercise);
    var result = new Result();
    result.setSubmission(submissionWithoutResult);
    result.setFeedbacks(feedbacks);
    result.setParticipation(submissionWithoutResult.getParticipation());
    submissionWithoutResult.addResult(result);
    resultRepository.submitResult(result, exercise, exerciseDateService.getDueDate(result.getParticipation()));
    resultRepository.save(result);
    assertThat(result.getResultString()).isEqualTo("6 of 7 points");
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 93 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.
 * Also fills {@code gradingInstructionCopyTracker}.
 *
 * @param importedExercise The exercise from which to copy the basis
 * @param gradingInstructionCopyTracker  The mapping from original GradingInstruction Ids to new GradingInstruction instances.
 * @return the cloned TextExercise basis
 */
@NotNull
private ModelingExercise copyModelingExerciseBasis(Exercise importedExercise, Map<Long, GradingInstruction> gradingInstructionCopyTracker) {
    log.debug("Copying the exercise basis from {}", importedExercise);
    ModelingExercise newExercise = new ModelingExercise();
    super.copyExerciseBasis(newExercise, importedExercise, gradingInstructionCopyTracker);
    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 94 with ModelingExercise

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

the class ModelingExerciseService method deleteClustersAndElements.

/**
 * Delete clusters and elements of a modeling exercise
 *
 * @param modelingExercise modeling exercise clusters and elements belong to
 */
public void deleteClustersAndElements(ModelingExercise modelingExercise) {
    List<ModelCluster> clustersToDelete = modelClusterRepository.findAllByExerciseIdWithEagerElements(modelingExercise.getId());
    for (ModelCluster cluster : clustersToDelete) {
        modelElementRepository.deleteAll(cluster.getModelElements());
        modelClusterRepository.deleteById(cluster.getId());
    }
}
Also used : ModelCluster(de.tum.in.www1.artemis.domain.modeling.ModelCluster)

Example 95 with ModelingExercise

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

the class ModelingSubmissionService method findRandomSubmissionWithoutExistingAssessment.

/**
 * retrieves a modeling submission without assessment for the specified correction round and potentially locks the submission
 *
 * In case Compass is supported (and activated), this method also assigns a result with feedback suggestions to the submission
 *
 * @param lockSubmission whether the submission should be locked
 * @param correctionRound the correction round (0 = first correction, 1 = second correction
 * @param modelingExercise the modeling exercise for which a
 * @param isExamMode whether the exercise belongs to an exam
 * @return a random modeling submission (potentially based on compass)
 */
public ModelingSubmission findRandomSubmissionWithoutExistingAssessment(boolean lockSubmission, int correctionRound, ModelingExercise modelingExercise, boolean isExamMode) {
    var submissionWithoutResult = super.getRandomSubmissionEligibleForNewAssessment(modelingExercise, isExamMode, correctionRound).orElseThrow(() -> new EntityNotFoundException("Modeling submission for exercise " + modelingExercise.getId() + " could not be found"));
    ModelingSubmission modelingSubmission = (ModelingSubmission) submissionWithoutResult;
    if (lockSubmission) {
        if (compassService.isSupported(modelingExercise) && correctionRound == 0L) {
            modelingSubmission = assignResultWithFeedbackSuggestionsToSubmission(modelingSubmission, modelingExercise);
            setNumberOfAffectedSubmissionsPerElement(modelingSubmission);
        }
        lockSubmission(modelingSubmission, correctionRound);
    }
    return modelingSubmission;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) EntityNotFoundException(de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)

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