{{ js_template|safe }}
<div class="poll-block" data-private="{% if private_results %}1{% endif %}" data-can-vote="{% if can_vote %}1{% endif %}">
    {# If no form is present, the Javascript will load the results instead. #}
    {% if not choices or private_results %}
    <h3 class="poll-header">{{block_name}}</h3>
    <form>
        <table class="survey-table">
            <thead>
              <tr>
                  <th></th>
                  {% for answer, label in answers %}
                    <th class="survey-answer">{{label}}</th>
                  {% endfor %}
              </tr>
            </thead>
        {% for key, question in questions %}
            <tr class="survey-row">
                <td class="survey-question">
                    {% if question.img %}
                        <div class="poll-image-td">
                                <img src="{{question.img}}" />
                        </div>
                    {% endif %}
                  {{question.label|safe}}
                </td>
            {% for answer, answer_details in answers %}
                <td class="survey-option">
                    <input type="radio" name="{{key}}" value="{{answer}}"{% if question.choice == answer %} checked{% endif %}/>
                </td>
            {% endfor %}
            </tr>
        {% endfor %}
        </table>
        <input class="input-main" type="button" name="poll-submit" value="{% if choices and can_vote %}Resubmit{% else %}Submit{% endif %}" disabled />
    </form>
    <div class="poll-voting-thanks{% if not choices or can_vote %} poll-hidden{% endif %}"><span>Thank you for your submission!</span></div>
    <div class="poll-submissions-count poll-hidden">
        You have used <span class="poll-current-count">{{ submissions_count }}</span>
        out of <span class="poll-max-submissions">{{ max_submissions }}</span> submissions.
    </div>
    {% if feedback %}
        <div class="poll-feedback-container{% if not choices %} poll-hidden{% endif %}">
            <hr />
            <h3 class="poll-header">Feedback</h3>
            <div class="poll-feedback">
                {{feedback|safe}}
            </div>
        </div>
    {% endif %}

    {% if can_view_private_results %}
        <div class="view-results-button-wrapper"><a class="view-results-button">View results</a></div>
    {% endif %}
  {% endif %}
</div>
