numerous improvements

This commit is contained in:
Ross
2020-12-05 18:10:51 +00:00
parent 45e038ccd6
commit a3bf73059c
5 changed files with 45 additions and 10 deletions
+9 -2
View File
@@ -261,21 +261,28 @@ def loadJsonAnswer(answer):
ans.answer = answer["ans"]
ans.save()
return True
@csrf_exempt
def postExamAnswers(request):
if request.is_ajax and request.method == "POST":
n = 0
# horrible but it works
for k in request.POST.dict():
print(k)
for answer in json.loads(k):
loadJsonAnswer(answer)
ret = loadJsonAnswer(answer)
if ret is not True:
return ret
n = n + 1
# print(UserAnswer.objects.filter(exam__id=q["eid"]))
# print(request.urlencode())
return JsonResponse({"success": True})
return JsonResponse({"success": True, "question-number": n})
return JsonResponse({"success": False, "error": "Invalid data"})
# return render(request, "anatomy/exam.html", {"exam" : exam, "question" : question})