start group editing of exams
This commit is contained in:
@@ -317,6 +317,38 @@ def loadJsonAnswer(answer):
|
||||
|
||||
return True
|
||||
|
||||
def exam_json_edit(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):
|
||||
if not "exam" in answer:
|
||||
return JsonResponse({"success": False})
|
||||
|
||||
exam = get_object_or_404(answer["exam"])
|
||||
|
||||
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()
|
||||
|
||||
|
||||
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