Skip to content

Commit c4867e5

Browse files
mikaelGussemurhum1
authored andcommitted
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
1 parent fe8c163 commit c4867e5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

exercise/views.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> JsonResponse:
673673

674674
goal_percentage = points_goal / cached_module.max_points * 100
675675

676+
if points_goal < self.module.points_to_pass:
677+
return JsonResponse({"error": "less_than_required"}, status=400)
678+
676679
goal, _ = StudentModuleGoal.objects.update_or_create(
677680
student=request.user.userprofile,
678681
module=self.module,
@@ -681,9 +684,6 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> JsonResponse:
681684
cached_points = CachedPoints(self.instance, request.user, True)
682685
cached_points.invalidate(self.module.course_instance, request.user)
683686

684-
if goal.goal_points < self.module.points_to_pass:
685-
return JsonResponse({"error": "less_than_required"}, status=400)
686-
687687
return JsonResponse({
688688
"goal_points": goal.goal_points,
689689
"goal_percentage": goal_percentage,

0 commit comments

Comments
 (0)