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;
}
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();
}
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;
}
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);
}
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));
}
Aggregations