Search in sources :

Example 26 with ModelingExercise

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

the class ModelingExerciseResourceIntTest method createModelingExercise.

@Test
@Transactional
public void createModelingExercise() throws Exception {
    int databaseSizeBeforeCreate = modelingExerciseRepository.findAll().size();
    // Create the ModelingExercise
    restModelingExerciseMockMvc.perform(post("/api/modeling-exercises").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(modelingExercise))).andExpect(status().isCreated());
    // Validate the ModelingExercise in the database
    List<ModelingExercise> modelingExerciseList = modelingExerciseRepository.findAll();
    assertThat(modelingExerciseList).hasSize(databaseSizeBeforeCreate + 1);
    ModelingExercise testModelingExercise = modelingExerciseList.get(modelingExerciseList.size() - 1);
    assertThat(testModelingExercise.getBaseFilePath()).isEqualTo(DEFAULT_BASE_FILE_PATH);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with ModelingExercise

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

the class ModelingExerciseResource method updateModelingExercise.

/**
 * PUT  /modeling-exercises : Updates an existing modelingExercise.
 *
 * @param modelingExercise the modelingExercise to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated modelingExercise,
 * or with status 400 (Bad Request) if the modelingExercise is not valid,
 * or with status 500 (Internal Server Error) if the modelingExercise couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/modeling-exercises")
@Timed
public ResponseEntity<ModelingExercise> updateModelingExercise(@RequestBody ModelingExercise modelingExercise) throws URISyntaxException {
    log.debug("REST request to update ModelingExercise : {}", modelingExercise);
    if (modelingExercise.getId() == null) {
        return createModelingExercise(modelingExercise);
    }
    ModelingExercise result = modelingExerciseRepository.save(modelingExercise);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, modelingExercise.getId().toString())).body(result);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Timed(com.codahale.metrics.annotation.Timed)

Example 28 with ModelingExercise

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

the class ModelingSubmissionService method lockAndGetModelingSubmission.

/**
 * Get the modeling submission with the given ID from the database and lock the submission to prevent other tutors from receiving and assessing it.
 * Additionally, check if the submission lock limit has been reached.
 *
 * In case Compass is supported (and activated), this method also assigns a result with feedback suggestions to the submission
 *
 * @param submissionId     the id of the modeling submission
 * @param modelingExercise the corresponding exercise
 * @param correctionRound the correction round for which we want the lock
 * @return the locked modeling submission
 */
public ModelingSubmission lockAndGetModelingSubmission(Long submissionId, ModelingExercise modelingExercise, int correctionRound) {
    ModelingSubmission modelingSubmission = modelingSubmissionRepository.findByIdWithEagerResultAndFeedbackAndAssessorAndParticipationResultsElseThrow(submissionId);
    if (modelingSubmission.getLatestResult() == null || modelingSubmission.getLatestResult().getAssessor() == null) {
        checkSubmissionLockLimit(modelingExercise.getCourseViaExerciseGroupOrCourseMember().getId());
        if (compassService.isSupported(modelingExercise) && correctionRound == 0L) {
            modelingSubmission = assignResultWithFeedbackSuggestionsToSubmission(modelingSubmission, modelingExercise);
        }
    }
    lockSubmission(modelingSubmission, correctionRound);
    return modelingSubmission;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)

Example 29 with ModelingExercise

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

the class ModelingSubmissionService method assignResultWithFeedbackSuggestionsToSubmission.

/**
 * Assigns an automatic result generated by Compass to the given modeling submission and saves the updated submission to the database. If the given submission already contains
 * a manual result, it will not get updated with the automatic result.
 *
 * @param modelingSubmission the modeling submission that should be updated with an automatic result generated by Compass
 * @param modelingExercise the modeling exercise to which the submission belongs
 * @return the updated modeling submission
 */
private ModelingSubmission assignResultWithFeedbackSuggestionsToSubmission(ModelingSubmission modelingSubmission, ModelingExercise modelingExercise) {
    var existingResult = modelingSubmission.getLatestResult();
    if (existingResult != null && existingResult.getAssessmentType() != null && existingResult.getAssessmentType() == AssessmentType.MANUAL) {
        return modelingSubmission;
    }
    Result automaticResult = compassService.getSuggestionResult(modelingSubmission, modelingExercise);
    if (automaticResult != null) {
        automaticResult.setSubmission(null);
        automaticResult.setParticipation(modelingSubmission.getParticipation());
        automaticResult = resultRepository.save(automaticResult);
        automaticResult.setSubmission(modelingSubmission);
        modelingSubmission.addResult(automaticResult);
        modelingSubmission = modelingSubmissionRepository.save(modelingSubmission);
    }
    return modelingSubmission;
}
Also used : Result(de.tum.in.www1.artemis.domain.Result)

Example 30 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