Add candidate count method to ExamOrCollectionGenericBase and update exam list template

This commit is contained in:
Ross
2025-11-07 21:10:52 +00:00
parent 9b8e6f1398
commit 9f8b4ff36a
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -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(
@@ -15,7 +15,7 @@
</a>
<small class="ms-2 text-muted">
<span class="badge bg-secondary">Questions: {{ exam.get_questions|length }}</span>
<span class="badge bg-secondary ms-1">Candidates: {{ exam.stats_candidates|default:0|floatformat:0 }}</span>
<span class="badge bg-secondary ms-1">Candidates: {{ exam.get_candidate_count }}</span>
</small>
</h5>
<small class="text-muted">Authors: {{ exam.get_authors }}</small>