clearer error messages when submitting answers fails

This commit is contained in:
Ross
2021-01-04 11:00:18 +00:00
parent 75588f27bf
commit df59de8e73
+2 -2
View File
@@ -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"])