From 9039469eae73e77357eaff6f472452775a6dd54a Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 17 Oct 2021 09:45:26 +0100 Subject: [PATCH] . --- anatomy/templates/anatomy/exam_overview.html | 7 +++++-- generic/views.py | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/anatomy/templates/anatomy/exam_overview.html b/anatomy/templates/anatomy/exam_overview.html index 927362b2..54939f88 100644 --- a/anatomy/templates/anatomy/exam_overview.html +++ b/anatomy/templates/anatomy/exam_overview.html @@ -27,8 +27,8 @@
Publish results: [When checked the exam results will be available to users on this site]
+

{% endif %} -

    {% for question in questions.all %} @@ -41,7 +41,10 @@
    {{ question.question_type }}: {{ question.get_primary_answer }}
    - Modality: {{ question.modality }}, Mark + Modality: {{ question.modality }}, + {% if exam.exam_mode %} + Mark + {% endif %} [id: {{question.pk}}] {% endfor %} diff --git a/generic/views.py b/generic/views.py index 063e1843..3e38eb0a 100644 --- a/generic/views.py +++ b/generic/views.py @@ -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: