From 2a3662a9a1ea925c4dc14fda92e273410eedbf4d Mon Sep 17 00:00:00 2001 From: mikaelGusse Date: Tue, 21 Jan 2025 16:21:08 +0200 Subject: [PATCH] Fix small bug with personalized points goal - Personalized points goal checks that the goal is more than the required points for a module. However this happens AFTER the points goal is saved. This fixes that --- exercise/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercise/views.py b/exercise/views.py index 0742b4cfc..d5a116c14 100644 --- a/exercise/views.py +++ b/exercise/views.py @@ -673,6 +673,9 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> JsonResponse: goal_percentage = points_goal / cached_module.max_points * 100 + if points_goal < self.module.points_to_pass: + return JsonResponse({"error": "less_than_required"}, status=400) + goal, _ = StudentModuleGoal.objects.update_or_create( student=request.user.userprofile, module=self.module, @@ -681,9 +684,6 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> JsonResponse: cached_points = CachedPoints(self.instance, request.user, True) cached_points.invalidate(self.module.course_instance, request.user) - if goal.goal_points < self.module.points_to_pass: - return JsonResponse({"error": "less_than_required"}, status=400) - return JsonResponse({ "goal_points": goal.goal_points, "goal_percentage": goal_percentage,