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,