From 9a950dd54021d09e73bff8c6f15c4e0ea7412d9a Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 19 Jul 2023 18:03:25 +0100 Subject: [PATCH] add stats page for bad responses --- ceuk-marking/urls.py | 5 +++ .../templates/crowdsourcer/bad_responses.html | 39 +++++++++++++++++++ crowdsourcer/templates/crowdsourcer/base.html | 3 ++ crowdsourcer/views/stats.py | 21 ++++++++++ 4 files changed, 68 insertions(+) create mode 100644 crowdsourcer/templates/crowdsourcer/bad_responses.html diff --git a/ceuk-marking/urls.py b/ceuk-marking/urls.py index e1fb8c64..ae15ec78 100644 --- a/ceuk-marking/urls.py +++ b/ceuk-marking/urls.py @@ -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//authorities/", diff --git a/crowdsourcer/templates/crowdsourcer/bad_responses.html b/crowdsourcer/templates/crowdsourcer/bad_responses.html new file mode 100644 index 00000000..42b44aa1 --- /dev/null +++ b/crowdsourcer/templates/crowdsourcer/bad_responses.html @@ -0,0 +1,39 @@ +{% extends 'crowdsourcer/base.html' %} + +{% block content %} +{% if show_login %} +

Sign in

+Sign in +{% else %} +

Bad Audit Responses

+ +

+ This is a list of audit responses that don't have an answer set. +

+ + + + + + + + + + + {% for response in responses %} + + + + + + {% endfor %} + +
AuthoritySectionQuestion
+ {{ response.authority.name }} + + {{ response.question.section.title }} + + {{ response.question.number_and_part }} +
+{% endif %} +{% endblock %} diff --git a/crowdsourcer/templates/crowdsourcer/base.html b/crowdsourcer/templates/crowdsourcer/base.html index 9efcb4d7..50113ed7 100644 --- a/crowdsourcer/templates/crowdsourcer/base.html +++ b/crowdsourcer/templates/crowdsourcer/base.html @@ -86,6 +86,9 @@
  • Per question data
  • +
  • + Responses with no answer +
  • Weighted section totals (CSV)
  • diff --git a/crowdsourcer/views/stats.py b/crowdsourcer/views/stats.py index 174ee456..471c1752 100644 --- a/crowdsourcer/views/stats.py +++ b/crowdsourcer/views/stats.py @@ -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