.
This commit is contained in:
+11
-28
@@ -317,38 +317,21 @@ def loadJsonAnswer(answer):
|
||||
|
||||
return True
|
||||
|
||||
def exam_json_edit(request):
|
||||
if request.is_ajax and request.method == "POST":
|
||||
def exam_json_edit(request, pk):
|
||||
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):
|
||||
if not "exam" in answer:
|
||||
return JsonResponse({"success": False})
|
||||
exam = get_object_or_404(Exam, pk=pk)
|
||||
|
||||
exam = get_object_or_404(answer["exam"])
|
||||
for q in exam.exam_questions.all():
|
||||
q.open_acess = request.POST.get("set_open_access")
|
||||
q.save()
|
||||
|
||||
if "set_open_access" in answer:
|
||||
#answer["set_open_access"]
|
||||
for q in exam.exam_questions.all():
|
||||
q.open_acess = answer["set_open_access"]
|
||||
q.save()
|
||||
|
||||
data = {"status": "success"}
|
||||
return JsonResponse(data, status=200)
|
||||
else:
|
||||
data = {"status": "error"}
|
||||
return JsonResponse(data, status=400)
|
||||
|
||||
return JsonResponse({"success": True})
|
||||
|
||||
|
||||
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, "question_count": n})
|
||||
return JsonResponse({"success": False, "error": "Invalid data"})
|
||||
|
||||
@csrf_exempt
|
||||
def postExamAnswers(request):
|
||||
|
||||
Reference in New Issue
Block a user