This commit is contained in:
Ross
2021-12-12 16:39:26 +00:00
parent 86890a104a
commit bc51f829eb
2 changed files with 8 additions and 6 deletions
+3
View File
@@ -239,6 +239,9 @@ def loadJsonAnswer(answer):
exam = get_object_or_404(Exam, pk=eid)
if not exam.check_cid_user(answer["cid"], answer["passcode"]):
return False, JsonResponse({"success": False, "error": "invalid cid / passcode"})
# if not exam.active:
# return False, JsonResponse(
# {"success": False, "error": "No active exam: {}".format(eid)}
+5 -6
View File
@@ -669,12 +669,11 @@ 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"})
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