clearer error messages when submitting answers fails
This commit is contained in:
+2
-2
@@ -281,12 +281,12 @@ def loadJsonAnswer(answer):
|
||||
if (not isinstance(answer["cid"], int)) or (
|
||||
not isinstance(answer["eid"], int) or (not isinstance(answer["ans"], str))
|
||||
):
|
||||
return JsonResponse({"success": False})
|
||||
return JsonResponse({"success": False, "error": "cid or eid or answers not defined"})
|
||||
|
||||
# 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 JsonResponse({"success": False, "error": "invalid cid"})
|
||||
|
||||
exam = get_object_or_404(Exam, pk=answer["eid"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user