This commit is contained in:
Ross
2021-12-10 18:59:41 +00:00
parent cf016e6991
commit dfd3308070
2 changed files with 9 additions and 4 deletions
+6 -1
View File
@@ -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
+3 -3
View File
@@ -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"])