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