diff --git a/longs/views.py b/longs/views.py index 6333c2ae..6cee80c5 100755 --- a/longs/views.py +++ b/longs/views.py @@ -629,12 +629,12 @@ def loadJsonAnswer(answer): # The model should catch invalid data but this should be less intensive 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"}) 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( {"success": False, "error": "invalid cid / passcode"} ) @@ -645,7 +645,7 @@ def loadJsonAnswer(answer): # ) 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"] @@ -655,7 +655,7 @@ def loadJsonAnswer(answer): # If the user answer does not exist if not exiting_answers: - ans = CidUserAnswer(cid=answer["cid"]) + ans = CidUserAnswer(cid=cid) ans.question_id = answer["qid"] ans.exam_id = eid diff --git a/rapids/views.py b/rapids/views.py index 7d232c5d..81380a92 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -522,12 +522,12 @@ def loadJsonAnswer(answer): # The model should catch invalid data but this should be less intensive 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"}) 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( {"success": False, "error": "invalid cid / passcode"} ) @@ -538,7 +538,7 @@ def loadJsonAnswer(answer): # ) 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"] @@ -553,7 +553,7 @@ def loadJsonAnswer(answer): normal = True 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.exam_id = eid