diff --git a/crowdsourcer/management/commands/export_marks.py b/crowdsourcer/management/commands/export_marks.py index caa549a..264b2c3 100644 --- a/crowdsourcer/management/commands/export_marks.py +++ b/crowdsourcer/management/commands/export_marks.py @@ -141,7 +141,9 @@ def handle( answer_data = None if output_answers or questions_only: if not questions_only: - answer_data = get_all_question_data(scoring) + answer_data = get_all_question_data( + scoring, marking_session=session.label + ) questions = ( Question.objects.filter(section__marking_session=session) diff --git a/crowdsourcer/scoring.py b/crowdsourcer/scoring.py index 2cea35a..8944387 100644 --- a/crowdsourcer/scoring.py +++ b/crowdsourcer/scoring.py @@ -4,6 +4,7 @@ from django.db.models import Count, Max, OuterRef, Q, Subquery, Sum from crowdsourcer.models import ( + MarkingSession, Option, PublicAuthority, Question, @@ -707,10 +708,13 @@ def get_response_data( return data -def get_all_question_data(scoring, response_type="Audit"): +def get_all_question_data(scoring, marking_session=None, response_type="Audit"): rt = ResponseType.objects.get(type=response_type) + session = MarkingSession.objects.get(label=marking_session) responses = ( - Response.objects.filter(response_type=rt) + Response.objects.filter( + response_type=rt, question__section__marking_session=session + ) .annotate(multi_count=Count("multi_option__pk")) .order_by( "authority__name", diff --git a/crowdsourcer/templates/crowdsourcer/stats.html b/crowdsourcer/templates/crowdsourcer/stats.html index 0508e2c..f70ebe0 100644 --- a/crowdsourcer/templates/crowdsourcer/stats.html +++ b/crowdsourcer/templates/crowdsourcer/stats.html @@ -46,8 +46,12 @@