diff --git a/generic/views.py b/generic/views.py index 63804ca2..6f3dbe99 100644 --- a/generic/views.py +++ b/generic/views.py @@ -568,7 +568,12 @@ class ExamViews(View, LoginRequiredMixin): n = 0 for answer in json.loads(request.POST.get("answers")): - ret_status, ret = self.loadJsonAnswer(answer) + try: + ret_status, ret = self.loadJsonAnswer(answer) + except: + # We catch the error here so users get an error (rather than 500) + return JsonResponse({"success": False, "error": "Invalid data"}) + #if ret is not True: # return ret diff --git a/physics/views.py b/physics/views.py index ab5cc735..5ef506f4 100644 --- a/physics/views.py +++ b/physics/views.py @@ -265,9 +265,9 @@ def loadJsonAnswer(answer): return False, JsonResponse({"success": False, "error": "invalid"}) # The model should catch invalid data but this should be less intensive - #max_int = 10000000 - #if answer["cid"] > max_int or answer["eid"] > max_int: - # return False, JsonResponse({"success": False}) + max_int = 2147483647 + if answer["cid"] > max_int or answer["eid"] > max_int: + return False, JsonResponse({"success": False}) exam = get_object_or_404(Exam, pk=answer["eid"])