Search in sources :

Example 11 with ModelingSubmission

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

the class ModelingExerciseImportService method copySubmission.

/**
 * This helper function does a hard copy of the {@code originalSubmission} and stores the values in {@code newSubmission}.
 * To copy the submission results this function calls {@link #copyExampleResult(Result, Submission)} respectively.
 *
 * @param originalSubmission The original submission to be copied.
 * @return The cloned submission
 */
@Override
Submission copySubmission(Submission originalSubmission) {
    ModelingSubmission newSubmission = new ModelingSubmission();
    if (originalSubmission != null) {
        log.debug("Copying the Submission to new ExampleSubmission: {}", newSubmission);
        newSubmission.setExampleSubmission(true);
        newSubmission.setSubmissionDate(originalSubmission.getSubmissionDate());
        newSubmission.setType(originalSubmission.getType());
        newSubmission.setParticipation(originalSubmission.getParticipation());
        newSubmission.setExplanationText(((ModelingSubmission) originalSubmission).getExplanationText());
        newSubmission.setModel(((ModelingSubmission) originalSubmission).getModel());
        newSubmission = submissionRepository.saveAndFlush(newSubmission);
        if (originalSubmission.getLatestResult() != null) {
            newSubmission.addResult(copyExampleResult(originalSubmission.getLatestResult(), newSubmission));
        }
        newSubmission = submissionRepository.saveAndFlush(newSubmission);
    }
    return newSubmission;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)

Example 12 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 path, String login, boolean submit) throws Exception {
    List<Feedback> feedbackList = loadAssessmentFomResources(path);
    Result result = assessmentService.saveManualAssessment(submission, feedbackList, 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 13 with ModelingSubmission

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

the class DatabaseUtilService method addModelingSubmissionWithResultAndAssessor.

public ModelingSubmission addModelingSubmissionWithResultAndAssessor(ModelingExercise exercise, ModelingSubmission submission, String login, String assessorLogin) {
    StudentParticipation participation = createAndSaveParticipationForExercise(exercise, login);
    participation.addSubmission(submission);
    submission = modelingSubmissionRepo.save(submission);
    Result result = new Result();
    result.setAssessor(getUserByLogin(assessorLogin));
    result.setAssessmentType(AssessmentType.MANUAL);
    result = resultRepo.save(result);
    submission = modelingSubmissionRepo.save(submission);
    studentParticipationRepo.save(participation);
    result = resultRepo.save(result);
    result.setSubmission(submission);
    submission.setParticipation(participation);
    submission.addResult(result);
    submission.getParticipation().addResult(result);
    submission = modelingSubmissionRepo.save(submission);
    studentParticipationRepo.save(participation);
    return submission;
}
Also used : TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 14 with ModelingSubmission

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

the class ModelingSubmissionResourceIntTest method updateModelingSubmission.

@Test
@Transactional
public void updateModelingSubmission() throws Exception {
    // Initialize the database
    modelingSubmissionRepository.saveAndFlush(modelingSubmission);
    int databaseSizeBeforeUpdate = modelingSubmissionRepository.findAll().size();
    // Update the modelingSubmission
    ModelingSubmission updatedModelingSubmission = modelingSubmissionRepository.findOne(modelingSubmission.getId());
    updatedModelingSubmission.submissionPath(UPDATED_SUBMISSION_PATH);
    restModelingSubmissionMockMvc.perform(put("/api/modeling-submissions").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedModelingSubmission))).andExpect(status().isOk());
    // Validate the ModelingSubmission in the database
    List<ModelingSubmission> modelingSubmissionList = modelingSubmissionRepository.findAll();
    assertThat(modelingSubmissionList).hasSize(databaseSizeBeforeUpdate);
    ModelingSubmission testModelingSubmission = modelingSubmissionList.get(modelingSubmissionList.size() - 1);
    assertThat(testModelingSubmission.getSubmissionPath()).isEqualTo(UPDATED_SUBMISSION_PATH);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.ModelingSubmission) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with ModelingSubmission

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

the class ModelingSubmissionResource method getModelingSubmission.

/**
 * GET  /modeling-submissions/:id : get the "id" modelingSubmission.
 *
 * @param id the id of the modelingSubmission to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the modelingSubmission, or with status 404 (Not Found)
 */
@GetMapping("/modeling-submissions/{id}")
@Timed
public ResponseEntity<ModelingSubmission> getModelingSubmission(@PathVariable Long id) {
    log.debug("REST request to get ModelingSubmission : {}", id);
    ModelingSubmission modelingSubmission = modelingSubmissionRepository.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(modelingSubmission));
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.ModelingSubmission) Timed(com.codahale.metrics.annotation.Timed)

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