From 7ddea6df993c96c915fc8a2708cac84d080b434b Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 14 Dec 2020 14:20:50 +0000 Subject: [PATCH] add function to get exam index from list --- anatomy/models.py | 3 +++ anatomy/templates/anatomy/exam_scores.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/anatomy/models.py b/anatomy/models.py index e7d805a8..fd1b07d4 100644 --- a/anatomy/models.py +++ b/anatomy/models.py @@ -275,6 +275,9 @@ class Exam(models.Model): def get_json_url(self): return reverse("anatomy:exam_json", args=(self.pk,)) + def get_question_index(self, question): + return list(self.exam_questions.all()).index(question) + class UserAnswer(models.Model): question = models.ForeignKey( diff --git a/anatomy/templates/anatomy/exam_scores.html b/anatomy/templates/anatomy/exam_scores.html index a9975140..26cd2f6e 100644 --- a/anatomy/templates/anatomy/exam_scores.html +++ b/anatomy/templates/anatomy/exam_scores.html @@ -7,7 +7,7 @@ {% if unmarked %} The following questions need marking {% for question in unmarked %} - {{question.pk}} + {{ exam|get_question_index:question }} {% endfor %} {% endif %}