add function to get exam index from list
This commit is contained in:
@@ -275,6 +275,9 @@ class Exam(models.Model):
|
|||||||
def get_json_url(self):
|
def get_json_url(self):
|
||||||
return reverse("anatomy:exam_json", args=(self.pk,))
|
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):
|
class UserAnswer(models.Model):
|
||||||
question = models.ForeignKey(
|
question = models.ForeignKey(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{% if unmarked %}
|
{% if unmarked %}
|
||||||
The following questions need marking
|
The following questions need marking
|
||||||
{% for question in unmarked %}
|
{% for question in unmarked %}
|
||||||
<a href="{% url 'anatomy:mark' exam.pk question.pk %}">{{question.pk}}</a>
|
<a href="{% url 'anatomy:mark' exam.pk question.pk %}">{{ exam|get_question_index:question }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user