Question detail view: Show total number of answers

This commit is contained in:
Raphael Michel
2023-10-04 11:44:53 +02:00
parent c6cf8b6f24
commit 1d0dbae77a
2 changed files with 9 additions and 2 deletions

View File

@@ -717,13 +717,13 @@ class QuestionView(EventPermissionRequiredMixin, QuestionMixin, ChartContainingV
total = sum(a['count'] for a in r)
for a in r:
a['percentage'] = (a['count'] / total * 100.) if total else 0
return r
return r, total
def get_context_data(self, **kwargs):
ctx = super().get_context_data()
ctx['items'] = self.object.items.all()
stats = self.get_answer_statistics()
ctx['stats'] = stats
ctx['stats'], ctx['total'] = stats
ctx['stats_json'] = json.dumps(stats)
return ctx