mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Question stats: Show percentage
This commit is contained in:
@@ -66,7 +66,8 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Answer" %}</th>
|
<th>{% trans "Answer" %}</th>
|
||||||
<th>{% trans "Count" %}</th>
|
<th class="text-right">{% trans "Count" %}</th>
|
||||||
|
<th class="text-right">{% trans "Percentage" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -77,7 +78,8 @@
|
|||||||
{{ stat.answer }}
|
{{ stat.answer }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ stat.count }}</td>
|
<td class="text-right">{{ stat.count }}</td>
|
||||||
|
<td class="text-right">{{ stat.percentage|floatformat:1 }} %</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -563,7 +563,11 @@ class QuestionView(EventPermissionRequiredMixin, QuestionMixin, ChartContainingV
|
|||||||
a['alink'] = a['answer']
|
a['alink'] = a['answer']
|
||||||
a['answer'] = Country(a['answer']).name or a['answer']
|
a['answer'] = Country(a['answer']).name or a['answer']
|
||||||
|
|
||||||
return list(qs)
|
r = list(qs)
|
||||||
|
total = sum(a['count'] for a in r)
|
||||||
|
for a in r:
|
||||||
|
a['percentage'] = a['count'] / total * 100.
|
||||||
|
return r
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
ctx = super().get_context_data()
|
ctx = super().get_context_data()
|
||||||
|
|||||||
Reference in New Issue
Block a user