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