PCv5/app/templates/widgets/polls/simplepoll.html

24 lines
789 B
HTML
Raw Normal View History

2021-02-19 22:07:31 +01:00
{% macro choices(poll) %}
<fieldset>
{% for choice in poll.choices %}
<input type="radio" id="{{ poll.id }}-{{ choice.id }}" name="pollanwsers" value="{{ choice.title }}" />
<label for="{{ poll.id }}-{{ choice.id }}">{{ choice.title }}</label><br>
{% endfor %}
</fieldset>
{% endmacro %}
{% macro results(poll) %}
<table>
{% for choice, votes in poll.results.most_common() %}
<tr>
<td><label for="{{ poll.id }}-{{ choice.id }}">{{ choice.title }}</label></td>
<td>
<progress id="{{ poll.id }}-{{ choice.id }}" value="{{ votes }}" max="{{ len(poll.answers) }}">
{{ votes / len(poll.answers) if len(poll.answers) else 0 }}% ({{ votes }})
</progress>
</td>
</tr>
{% endfor %}
</table>
{% endmacro %}