use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ParticipationTeamWebsocketService method updateSubmission.
/**
* Updates a modeling or text submission
*
* @param participationId id of participation
* @param submission updated modeling text submission
* @param principal principal of user who wants to update the submission
* @param topicPath path of websocket destination topic where to send the new submission
*/
private void updateSubmission(@DestinationVariable Long participationId, @Payload Submission submission, Principal principal, String topicPath) {
// Without this, custom jpa repository methods don't work in websocket channel.
SecurityUtils.setAuthorizationObject();
final StudentParticipation participation = studentParticipationRepository.findByIdElseThrow(participationId);
// user must belong to the team who owns the participation in order to update a submission
if (!participation.isOwnedBy(principal.getName())) {
return;
}
final User user = userRepository.getUserWithGroupsAndAuthorities(principal.getName());
final Exercise exercise = exerciseRepository.findByIdElseThrow(participation.getExercise().getId());
if (submission instanceof ModelingSubmission && exercise instanceof ModelingExercise) {
submission = modelingSubmissionService.save((ModelingSubmission) submission, (ModelingExercise) exercise, principal.getName());
modelingSubmissionService.hideDetails(submission, user);
} else if (submission instanceof TextSubmission && exercise instanceof TextExercise) {
submission = textSubmissionService.handleTextSubmission((TextSubmission) submission, (TextExercise) exercise, principal);
textSubmissionService.hideDetails(submission, user);
} else {
throw new IllegalArgumentException("Submission type '" + submission.getType() + "' not allowed.");
}
// update the last action date for the user and send out list of team members
updateValue(lastActionTracker, participationId, principal.getName());
sendOnlineTeamStudents(participationId);
SubmissionSyncPayload payload = new SubmissionSyncPayload(submission, user);
messagingTemplate.convertAndSend(getDestination(participationId, topicPath), payload);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission 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.ModelingSubmission 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.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 ExerciseImportService#copyExampleResult(Result, Submission, Map)} respectively.
*
* @param originalSubmission The original submission to be copied.
* @param gradingInstructionCopyTracker The mapping from original GradingInstruction Ids to new GradingInstruction instances.
* @return The cloned submission
*/
Submission copySubmission(Submission originalSubmission, Map<Long, GradingInstruction> gradingInstructionCopyTracker) {
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, gradingInstructionCopyTracker));
}
newSubmission = submissionRepository.saveAndFlush(newSubmission);
}
return newSubmission;
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission 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