.
This commit is contained in:
+6
-1
@@ -568,7 +568,12 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
n = 0
|
n = 0
|
||||||
|
|
||||||
for answer in json.loads(request.POST.get("answers")):
|
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:
|
#if ret is not True:
|
||||||
# return ret
|
# return ret
|
||||||
|
|||||||
+3
-3
@@ -265,9 +265,9 @@ def loadJsonAnswer(answer):
|
|||||||
return False, JsonResponse({"success": False, "error": "invalid"})
|
return False, JsonResponse({"success": False, "error": "invalid"})
|
||||||
|
|
||||||
# The model should catch invalid data but this should be less intensive
|
# The model should catch invalid data but this should be less intensive
|
||||||
#max_int = 10000000
|
max_int = 2147483647
|
||||||
#if answer["cid"] > max_int or answer["eid"] > max_int:
|
if answer["cid"] > max_int or answer["eid"] > max_int:
|
||||||
# return False, JsonResponse({"success": False})
|
return False, JsonResponse({"success": False})
|
||||||
|
|
||||||
exam = get_object_or_404(Exam, pk=answer["eid"])
|
exam = get_object_or_404(Exam, pk=answer["eid"])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user