{% endmacro %}
{% macro forum_poll(poll, options, user_answers, topic_id, can_vote, preview_results) %}
{% from '_layout/input.twig' import input_csrf, input_hidden, input_checkbox, input_checkbox_raw %}
{% set user_answers = user_answers is empty or user_answers is not iterable ? [] : user_answers %}
{% set user_answered = user_answers|length > 0 %}
{% set results_available = preview_results or user_answered or poll.poll_expired or poll.poll_preview_results %}
{% set options_available = not poll.poll_expired and (poll.poll_change_vote or not user_answered) %}
{% set display_results = user_answered or poll.poll_expired %}
{% if options is iterable and options|length > 0 %}
{% if results_available %}
{% if options_available %}
{{ input_checkbox_raw('', display_results, 'forum__poll__toggle', '', false, {'id':'forum-poll-toggle'}) }}
{% endif %}
{% for option in options %}
{% set percent = poll.poll_votes < 1 ? 0 : (option.option_votes / poll.poll_votes) * 100 %}