.
This commit is contained in:
+5
-3
@@ -118,15 +118,17 @@ def generic_exam_json_edit(request):
|
||||
|
||||
if "add_exam_questions" in request.POST:
|
||||
question_ids = json.loads(request.POST.get("add_exam_questions"))
|
||||
question_objects = Question.objects.filter(pk__in=question_ids)
|
||||
#question_objects = Question.objects.filter(pk__in=question_ids)
|
||||
|
||||
add_count = 0
|
||||
for i in question_ids:
|
||||
# We get an integrity error if we try to add an object that already exists
|
||||
if not exam.exam_questions.filter(pk=i).exists():
|
||||
add_count += 1
|
||||
exam.exam_questions.add(i)
|
||||
#exam.exam_questions.add(question_objects)
|
||||
|
||||
exam.save()
|
||||
data = {"status": "success"}
|
||||
data = {"status": "success", "questions added" : add_count}
|
||||
return JsonResponse(data, status=200)
|
||||
|
||||
if "set_exam_order" in request.POST:
|
||||
|
||||
Reference in New Issue
Block a user