diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java index 87c381b777d9..5a7b75e82de5 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java @@ -427,6 +427,14 @@ SELECT COUNT(DISTINCT p) */ boolean existsByParticipationId(long participationId); + /** + * Checks if a result exists for the given submission ID. + * + * @param submissionId the ID of the submission to check. + * @return true if a result exists for the given submission ID, false otherwise. + */ + boolean existsBySubmissionId(long submissionId); + /** * Returns true if there is at least one result for the given exercise. * diff --git a/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingSubmissionService.java b/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingSubmissionService.java index 320d041325e9..c8b4285de3b9 100644 --- a/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingSubmissionService.java +++ b/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingSubmissionService.java @@ -131,12 +131,10 @@ public ModelingSubmission handleModelingSubmission(ModelingSubmission modelingSu } // if athena results are present, then create a new submission on submit - if (modelingSubmission.getParticipation() != null && modelingSubmission.getParticipation().getResults() != null - && !modelingSubmission.getParticipation().getResults().isEmpty()) { - log.debug("Creating a new submission due to Athena results for user: {}", user.getLogin()); + // If results exist for this submission, create a new submission by setting the ID to null + if (modelingSubmission.getId() != null && resultRepository.existsBySubmissionId(modelingSubmission.getId())) { modelingSubmission.setId(null); } - modelingSubmission = save(modelingSubmission, exercise, user, participation); return modelingSubmission; } diff --git a/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingSubmissionResource.java b/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingSubmissionResource.java index e48f94b8e955..501309aea8e8 100644 --- a/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingSubmissionResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingSubmissionResource.java @@ -126,7 +126,6 @@ public ResponseEntity createModelingSubmission(@PathVariable @PutMapping("exercises/{exerciseId}/modeling-submissions") @EnforceAtLeastStudent public ResponseEntity updateModelingSubmission(@PathVariable long exerciseId, @Valid @RequestBody ModelingSubmission modelingSubmission) { - log.debug("REST request to update modeling submission: {}", modelingSubmission.getModel()); if (modelingSubmission.getId() == null) { return createModelingSubmission(exerciseId, modelingSubmission); } diff --git a/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts b/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts index 95cc45ed2483..e4684d85321b 100644 --- a/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts +++ b/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts @@ -35,6 +35,7 @@ import { faExclamationTriangle, faGripLines } from '@fortawesome/free-solid-svg- import { faListAlt } from '@fortawesome/free-regular-svg-icons'; import { onError } from 'app/shared/util/global.utils'; import { SubmissionPatch } from 'app/entities/submission-patch.model'; +import { AssessmentType } from 'app/entities/assessment-type.model'; @Component({ selector: 'jhi-modeling-submission', @@ -296,7 +297,9 @@ export class ModelingSubmissionComponent implements OnInit, OnDestroy, Component this.assessmentResult = newResult; this.assessmentResult = this.modelingAssessmentService.convertResult(newResult); this.prepareAssessmentData(); - this.alertService.info('artemisApp.modelingEditor.newAssessment'); + if (this.assessmentResult.assessmentType !== AssessmentType.AUTOMATIC_ATHENA) { + this.alertService.info('artemisApp.modelingEditor.newAssessment'); + } } }); }