This commit is contained in:
Ross
2022-03-01 18:12:42 +00:00
parent 607ec7bd79
commit ab2b29eebd
2 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -629,12 +629,12 @@ def loadJsonAnswer(answer):
# 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 = 999999999999999999999 max_int = 999999999999999999999
if answer["cid"] > max_int or eid > max_int: if cid > max_int or eid > max_int:
return False, JsonResponse({"success": False, "error": "invalid cid"}) return False, JsonResponse({"success": False, "error": "invalid cid"})
exam = get_object_or_404(Exam, pk=eid) exam = get_object_or_404(Exam, pk=eid)
if not exam.check_cid_user(answer["cid"], answer["passcode"]): if not exam.check_cid_user(cid, answer["passcode"]):
return False, JsonResponse( return False, JsonResponse(
{"success": False, "error": "invalid cid / passcode"} {"success": False, "error": "invalid cid / passcode"}
) )
@@ -645,7 +645,7 @@ def loadJsonAnswer(answer):
# ) # )
exiting_answers = CidUserAnswer.objects.filter( exiting_answers = CidUserAnswer.objects.filter(
question__id=answer["qid"], exam__id=eid, cid=answer["cid"] question__id=answer["qid"], exam__id=eid, cid=cid
) )
posted_answer = answer["ans"] posted_answer = answer["ans"]
@@ -655,7 +655,7 @@ def loadJsonAnswer(answer):
# If the user answer does not exist # If the user answer does not exist
if not exiting_answers: if not exiting_answers:
ans = CidUserAnswer(cid=answer["cid"]) ans = CidUserAnswer(cid=cid)
ans.question_id = answer["qid"] ans.question_id = answer["qid"]
ans.exam_id = eid ans.exam_id = eid
+4 -4
View File
@@ -522,12 +522,12 @@ def loadJsonAnswer(answer):
# 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 = 999999999999999999999 max_int = 999999999999999999999
if answer["cid"] > max_int or eid > max_int: if cid > max_int or eid > max_int:
return False, JsonResponse({"success": False, "error": "invalid cid"}) return False, JsonResponse({"success": False, "error": "invalid cid"})
exam = get_object_or_404(Exam, pk=eid) exam = get_object_or_404(Exam, pk=eid)
if not exam.check_cid_user(answer["cid"], answer["passcode"]): if not exam.check_cid_user(cid, answer["passcode"]):
return False, JsonResponse( return False, JsonResponse(
{"success": False, "error": "invalid cid / passcode"} {"success": False, "error": "invalid cid / passcode"}
) )
@@ -538,7 +538,7 @@ def loadJsonAnswer(answer):
# ) # )
exiting_answers = CidUserAnswer.objects.filter( exiting_answers = CidUserAnswer.objects.filter(
question__id=answer["qid"], exam__id=eid, cid=answer["cid"] question__id=answer["qid"], exam__id=eid, cid=cid
) )
posted_answer = answer["ans"] posted_answer = answer["ans"]
@@ -553,7 +553,7 @@ def loadJsonAnswer(answer):
normal = True normal = True
if not exiting_answers: if not exiting_answers:
ans = CidUserAnswer(answer=posted_answer, normal=normal, cid=answer["cid"]) ans = CidUserAnswer(answer=posted_answer, normal=normal, cid=cid)
ans.question_id = answer["qid"] ans.question_id = answer["qid"]
ans.exam_id = eid ans.exam_id = eid