.
This commit is contained in:
+4
-4
@@ -245,17 +245,17 @@ def exam_take(request, pk):
|
||||
def loadJsonAnswer(answer):
|
||||
# As access is not restricted make sure the data appears valid
|
||||
if (not isinstance(answer["cid"], int)) or (not isinstance(answer["eid"], int)):
|
||||
return JsonResponse({"success": False, "error": "invalid"})
|
||||
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 JsonResponse({"success": False})
|
||||
return False, JsonResponse({"success": False})
|
||||
|
||||
exam = get_object_or_404(Exam, pk=answer["eid"])
|
||||
|
||||
if not exam.active:
|
||||
return JsonResponse(
|
||||
return False, JsonResponse(
|
||||
{"success": False, "error": "No active exam: {}".format(answer["eid"])}
|
||||
)
|
||||
|
||||
@@ -296,6 +296,6 @@ def loadJsonAnswer(answer):
|
||||
ans.full_clean()
|
||||
ans.save()
|
||||
|
||||
return True
|
||||
return True, None
|
||||
|
||||
PhysicsExamViews = ExamViews(Exam, Question, "physics", "physics", loadJsonAnswer)
|
||||
Reference in New Issue
Block a user