From 95c136d3f3935a3b31f4c441415a98b541df5519 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 27 Nov 2023 09:11:48 +0000 Subject: [PATCH] improve user score view --- anatomy/filters.py | 3 ++- anatomy/tables.py | 8 ++++++++ generic/templates/generic/exam_cids_edit.html | 2 +- .../generic/exam_overview_headers.html | 2 +- templates/user_scores.html | 18 +++++++++++------- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/anatomy/filters.py b/anatomy/filters.py index f4ab4416..a4748a71 100644 --- a/anatomy/filters.py +++ b/anatomy/filters.py @@ -52,7 +52,7 @@ class AnatomyUserAnswerFilter(django_filters.FilterSet): fields = ( "cid", "user", - "question", + #"question", "answer", #"answer_compare", "exam", @@ -63,5 +63,6 @@ class AnatomyUserAnswerFilter(django_filters.FilterSet): def __init__(self, data=None, queryset=None, prefix=None, strict=None, user=None, request=None): if not request.user.groups.filter(name="anatomy_checker").exists(): queryset = queryset.filter(open_access=True) | queryset.filter(author__id=request.user.id) + #queryset = queryset.prefetch_related("question", "question__question_type", "exam") super(AnatomyUserAnswerFilter, self).__init__(data=data, queryset=queryset, prefix=prefix, request=request) pass \ No newline at end of file diff --git a/anatomy/tables.py b/anatomy/tables.py index 7192bd5b..6d00185f 100644 --- a/anatomy/tables.py +++ b/anatomy/tables.py @@ -79,3 +79,11 @@ class AnatomyUserAnswerTable(tables.Table): "updated", ) + def __init__(self, data=None, *args, **kwargs): + super().__init__( + data.prefetch_related( + "exam", "question", "question__question_type", "question__modality", "question__examination", "question__region", "user" + ), + *args, + **kwargs, + ) diff --git a/generic/templates/generic/exam_cids_edit.html b/generic/templates/generic/exam_cids_edit.html index d2ad6de4..2606d148 100644 --- a/generic/templates/generic/exam_cids_edit.html +++ b/generic/templates/generic/exam_cids_edit.html @@ -2,7 +2,7 @@

CID Users

{% if groups %} - Users from the following groups are available: {% for group in groups %}{{group}}, {% endfor %} . + Users from the following groups are available: {% for group in groups %}{{group}}, {% endfor %} . {% else %} This exam is not associated with any user groups. Edit and add a group to enable user management. {% endif %} diff --git a/generic/templates/generic/exam_overview_headers.html b/generic/templates/generic/exam_overview_headers.html index c1e3f82e..eeac7ca4 100644 --- a/generic/templates/generic/exam_overview_headers.html +++ b/generic/templates/generic/exam_overview_headers.html @@ -35,7 +35,7 @@ {% endif %} -This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds. +This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds. Exam mode: {{ exam.exam_mode }}
{% if exam.exam_mode %} diff --git a/templates/user_scores.html b/templates/user_scores.html index 845a5096..b87505c5 100644 --- a/templates/user_scores.html +++ b/templates/user_scores.html @@ -3,15 +3,16 @@ {% block content %}

User: {{ cid_user.username }}

-

Assigned exams

+

Assigned Exams

The following exams will be available to take when active. {% for exam_type, exams in available_exams %} @@ -19,7 +20,10 @@

{{exam_type|title}}

    {% for exam in exams %} -
  • {{exam.name}} {% if exam.active %}[Active]{% endif %} {% if exam.publish_results %}[Results Published]{% endif %}
  • +
  • {{exam.name}} + {% if exam.active %}{% endif %} + {% if exam.publish_results %}{% endif %} +
  • {% endfor %}
{% endif %} @@ -27,7 +31,7 @@
{% if all_exams %} -

Exam results

+

Exam Results

The following exam results been found. Click to view answers (and scores when the results are published): {% for exam_type, exams in all_exams %} @@ -38,9 +42,9 @@
  • {% if admin %} - + {% else %} - + {% endif %} {{exam.name}} {% if exam.active %}[Active]{% endif %} {% if exam.publish_results %}[Results Published]{% endif %}