From df59de8e7380d99ef7f5762fe6435a591d0d3401 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 4 Jan 2021 11:00:18 +0000 Subject: [PATCH] clearer error messages when submitting answers fails --- anatomy/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anatomy/views.py b/anatomy/views.py index 7bc47e1a..339c812a 100644 --- a/anatomy/views.py +++ b/anatomy/views.py @@ -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"])