diff --git a/exercise/static/exercise/chapter.js b/exercise/static/exercise/chapter.js index 856b4ae5f..b324778ea 100644 --- a/exercise/static/exercise/chapter.js +++ b/exercise/static/exercise/chapter.js @@ -793,15 +793,17 @@ exercise.hideLoader(); if (!exercise.active_element) { - var f = exercise.element.find(exercise.settings.response_selector) - .empty().append( - $(data).filter(exercise.settings.exercise_selector).contents() - ); + const responseElement = exercise.element.find(exercise.settings.response_selector); + // Remove only the exercise content, not the alerts above it + responseElement.children().not('.alert').remove(); + responseElement.append( + $(data).filter(exercise.settings.exercise_selector).contents() + ); exercise.dom_element.dispatchEvent( new CustomEvent("aplus:exercise-loaded", {bubbles: true, detail: {type: exercise.exercise_type}})); // TODO: remove magic constant (variable defined in group.js) - f.removeClass('group-augmented'); + responseElement.removeClass('group-augmented'); exercise.bindFormEvents(exercise.element); exercise.dom_element.dispatchEvent( new CustomEvent("aplus:exercise-ready", diff --git a/exercise/views.py b/exercise/views.py index 6a7882691..bca5c0324 100644 --- a/exercise/views.py +++ b/exercise/views.py @@ -87,8 +87,6 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: SUBMIT_STATUS.NOT_ENROLLED, ] should_enroll = submission_status == SUBMIT_STATUS.NOT_ENROLLED - if self.exercise.grading_mode == BaseExercise.GRADING_MODE.LAST: - messages.warning(request, _('ONLY_YOUR_LAST_SUBMISSION_WILL_BE_GRADED')) if (self.exercise.status == LearningObject.STATUS.MAINTENANCE or self.module.status == CourseModule.STATUS.MAINTENANCE): @@ -210,6 +208,9 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: page=page, students=students, submission=new_submission)) def submission_check(self, error=False, request=None): + if self.exercise.grading_mode == BaseExercise.GRADING_MODE.LAST: + # Add warning about the grading mode. + messages.warning(self.request, _('ONLY_YOUR_LAST_SUBMISSION_WILL_BE_GRADED')) if not self.profile: issue = _('SUBMISSION_MUST_SIGN_IN_AND_ENROLL_TO_SUBMIT_EXERCISES') messages.error(self.request, issue)