improve user score view

This commit is contained in:
Ross
2023-11-27 09:11:48 +00:00
parent d414d3baa2
commit 95c136d3f3
5 changed files with 23 additions and 10 deletions
+2 -1
View File
@@ -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
+8
View File
@@ -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,
)
@@ -2,7 +2,7 @@
<h3>CID Users</h3>
{% 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 %}<a href='{{group.get_absolute_url}}'>{{group}}</a>, {% endfor %} .
{% else %}
This exam is not associated with any user groups. <a href="{% url exam.app_name|add:':exam_update' exam.pk %}">Edit and add a group</a> to enable user management.
{% endif %}
@@ -35,7 +35,7 @@
{% endif %}
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.
This exam has {{question_number}} questions. <span title="Time per question: {% widthratio exam.time_limit question_number 1 %} seconds">Time limit: {{exam.time_limit}} seconds</span>.
Exam mode: {{ exam.exam_mode }}<br />
{% if exam.exam_mode %}
+11 -7
View File
@@ -3,15 +3,16 @@
{% block content %}
<div class="">
<h2>User: {{ cid_user.username }}</h2>
<h3>Assigned exams</h3>
<div class="alert alert-dark" role="alert">
<details>
<summary>Help</summary>
<p>This page shows the exam(s) to which you have access.</p>
<p>When an exam is available to take it will be highlighted with the text [Active]. </p>
<p>Once you have submitted answers you will be able to view them from the Exam results section. (Please note: although your answers will be visible as soon as they are submitted correct answers will only be available when the exam results have been published.)</p>
<p>When an exam is available to take it will have a "Start" button next to it.</p>
<p>Once you have submitted answers you will be able to view them from the Exam results section. (Please note: although your answers will be visible as soon as they are submitted, correct answers will only be available when the exam results have been published.)</p>
<p>If you have not submitted any answer for an exam it will not appear in the Exam Results section below. In this case you can still review the pubilshed results by following the "Results Published" link in the assigend exams section.</p>
</details>
</div>
<h3>Assigned Exams</h3>
<div id="exam-assigned">
The following exams will be available to take when active.
{% for exam_type, exams in available_exams %}
@@ -19,7 +20,10 @@
<h4>{{exam_type|title}}</h4>
<ul class='{{exam_type|lower}}'>
{% for exam in exams %}
<li class="exam" data-exam-id="{{exam.pk}}"><a href="{{exam.get_take_url}}" target="_blank">{{exam.name}}</a> {% if exam.active %}[Active]{% endif %} {% if exam.publish_results %}[Results Published]{% endif %}</li>
<li class="exam" data-exam-id="{{exam.pk}}">{{exam.name}}
{% if exam.active %}<a href="{{exam.get_take_url}}" target="_blank" title="Click to take exam"><button class="small-url-button">Start</button></a>{% endif %}
{% if exam.publish_results %}<a href= "{% url exam_type|lower|add:':exam_scores_user' pk=exam.pk %}" title="Click to view results"><button class="small-url-button">Results Published</button></a>{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
@@ -27,7 +31,7 @@
</div>
{% if all_exams %}
<h3>Exam results</h3>
<h3>Exam Results</h3>
<div id="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 @@
<li class="exam" data-exam-id="{{exam.pk}}">
{% if admin %}
<a href= "{% url exam_type|add:':exam_scores_user_admin' pk=exam.pk user_id=user.pk %}" >
<a href= "{% url exam_type|add:':exam_scores_user_admin' pk=exam.pk user_id=user.pk %}" title="Click to view results">
{% else %}
<a href= "{% url exam_type|add:':exam_scores_user' pk=exam.pk %}" >
<a href= "{% url exam_type|add:':exam_scores_user' pk=exam.pk %}" title="Click to view results">
{% endif %}
{{exam.name}}</a> {% if exam.active %}[Active]{% endif %} {% if exam.publish_results %}[Results Published]{% endif %}</li>