From 9f8b4ff36aca437a23346de755cb8ab780815bdf Mon Sep 17 00:00:00 2001 From: Ross Date: Fri, 7 Nov 2025 21:10:52 +0000 Subject: [PATCH] Add candidate count method to ExamOrCollectionGenericBase and update exam list template --- generic/models.py | 3 +++ generic/templates/generic/partials/_exam_list.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/generic/models.py b/generic/models.py index d254ba8e..2182a030 100644 --- a/generic/models.py +++ b/generic/models.py @@ -1002,6 +1002,9 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin): def add_marker(self, user): self.markers.add(user) + def get_candidate_count(self): + return self.valid_cid_users.count() + self.valid_user_users.count() + class ExamBase(ExamOrCollectionGenericBase): exam_mode = models.BooleanField( diff --git a/generic/templates/generic/partials/_exam_list.html b/generic/templates/generic/partials/_exam_list.html index 7bef9b9e..65893ba6 100644 --- a/generic/templates/generic/partials/_exam_list.html +++ b/generic/templates/generic/partials/_exam_list.html @@ -15,7 +15,7 @@ Questions: {{ exam.get_questions|length }} - Candidates: {{ exam.stats_candidates|default:0|floatformat:0 }} + Candidates: {{ exam.get_candidate_count }} Authors: {{ exam.get_authors }}