numerous improvements
This commit is contained in:
+9
-2
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user