From 055840b6a45829300c995a3ecf4feb9c0862d55a Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 11 Dec 2023 10:31:22 +0000 Subject: [PATCH] improve exam_list view --- generic/views.py | 2 +- templates/exam_list.html | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/generic/views.py b/generic/views.py index f270e958..4ce7e073 100644 --- a/generic/views.py +++ b/generic/views.py @@ -640,7 +640,7 @@ class ExamViews(View, LoginRequiredMixin): "name" ) else: - exam_list = self.Exam.objects.all().order_by("name") + exam_list = self.Exam.objects.prefetch_related("valid_user_users", "valid_cid_users").all().order_by("name") if not all: exam_list = exam_list.filter(exam_mode=True, archive=False).order_by("name") diff --git a/templates/exam_list.html b/templates/exam_list.html index 4eff2a17..71d3a4c0 100644 --- a/templates/exam_list.html +++ b/templates/exam_list.html @@ -11,7 +11,9 @@ {{exam.name}} {% if marking %}Mark{% endif %} - Candidates [{{exam.valid_cid_users.count}} / {{exam.valid_user_users.count}}] + Candidates [ + {{exam.valid_cid_users.count}} + / {{exam.valid_user_users.count}}] Scores @@ -34,7 +36,16 @@
  • {{exam.name}} {% if marking %}Mark{% endif %} - Candidates + + Candidates + + [{{exam.valid_cid_users.count}} + / + {{exam.valid_user_users.count}}] + + + + Scores