Skip to content

Commit

Permalink
add stats page for bad responses
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Jul 19, 2023
1 parent 7a61daa commit 9a950dd
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ceuk-marking/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@
stats.WeightedScoresDataCSVView.as_view(),
name="weighted_totals_csv",
),
path(
"stats/scores/bad_responses/",
stats.BadResponsesView.as_view(),
name="bad_responses",
),
# audit screens
path(
"section/audit/<section_title>/authorities/",
Expand Down
39 changes: 39 additions & 0 deletions crowdsourcer/templates/crowdsourcer/bad_responses.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends 'crowdsourcer/base.html' %}

{% block content %}
{% if show_login %}
<h1 class="mb-4">Sign in</h1>
<a href="{% url 'login' %}">Sign in</a>
{% else %}
<h1 class="mb-4">Bad Audit Responses</h1>

<p>
This is a list of audit responses that don't have an answer set.
</p>

<table class="table">
<thead>
<tr>
<th>Authority</th>
<th>Section</th>
<th>Question</th>
</tr>
</thead>
<tbody>
{% for response in responses %}
<tr>
<td>
<a href="{% url 'authority_ror_progress' response.authority.name %}">{{ response.authority.name }}</a>
</td>
<td>
<a href="{% url 'authority_ror' response.authority.name response.question.section.title %}">{{ response.question.section.title }}</a>
</td>
<td>
{{ response.question.number_and_part }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock %}
3 changes: 3 additions & 0 deletions crowdsourcer/templates/crowdsourcer/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<li>
<a class="dropdown-item d-flex" href="{% url 'stats_select_question' %}">Per question data</a>
</li>
<li>
<a class="dropdown-item d-flex" href="{% url 'bad_responses' %}">Responses with no answer</a>
</li>
<li>
<a class="dropdown-item d-flex" href="{% url 'weighted_totals_csv' %}">Weighted section totals (CSV)</a>
</li>
Expand Down
21 changes: 21 additions & 0 deletions crowdsourcer/views/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,24 @@ def render_to_response(self, context, **response_kwargs):
for row in context["weighted_scores"]:
writer.writerow(row)
return response


class BadResponsesView(UserPassesTestMixin, ListView):
context_object_name = "responses"
template_name = "crowdsourcer/bad_responses.html"

def test_func(self):
return self.request.user.is_superuser

def get_queryset(self):
responses = (
Response.objects.filter(
response_type__type="Audit",
option__isnull=True,
multi_option__isnull=True,
)
.select_related("authority", "question", "question__section")
.order_by("authority", "question__section")
)

return responses

0 comments on commit 9a950dd

Please sign in to comment.