<div id="quiz-title" class="course-home-headings">{{ quiz.title }}</div>

<div class="card-divider"></div>

<div class="mt-5">
  <form id="quiz-form">
    <div class="questions">
      {% for question in quiz.questions %}
      <div class="question {% if loop.index == 1 %} active-question {% else %} hide {% endif %}"
        data-question="{{ question.question }}" data-multi="{{ question.multiple}}" data-qt-index="{{ loop.index }}">
        <p>{{ frappe.utils.md_to_html(question.question) }}</p>

        {% if question.multiple %}
        <small class="font-weight-bold">Choose all answers that apply:</small>
        {% else %}
        <small class="font-weight-bold">Choose 1 answer:</small>
        {% endif %}

        <div class="card-divider"></div>

        {% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %}

        {% for option in options %}
        {% if option %}

        <div class="custom-checkbox">
          <label class="quiz-label">
            <input class="option" value="{{ option | urlencode }}"
              data-correct="{{ question['is_correct_' + loop.index | string] }}" {% if question.multiple %}
              type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}>
            <img class="empty-checkbox mr-3" />
            <span class="label-area">{{ frappe.utils.md_to_html(option) }}</span>
          </label>
        </div>

        {% set explanation = question['explanation_' + loop.index | string] %}
        {% if explanation %}
        <small class="explanation muted-text hide">{{ explanation }}</small>
        {% endif %}

        <div class="card-divider"></div>
        {% endif %}
        {% endfor %}

      </div>
      {% endfor %}
    </div>
    <div class="quiz-footer">
      <span class="font-weight-bold"> <span class="current-question">1</span> of {{ quiz.questions | length }}</span>
      <button class="button pull-right" id="check" disabled>Check</button>
      <button class="button hide" id="next">Next Question</button>
      <button class="button is-default hide" id="summary">Summary</button>
      <small id="submission-message" class="font-weight-bold hide"> Please join the course to submit the Quiz.</small>
    </div>
    <div class="button is-secondary pull-right hide" id="try-again">Try Again</div>
    <h4 class="success-message"></h4>
    <h5 class="score text-muted"></h5>
  </form>
</div>
