{% extends 'base.html' %}
{% load help_tags %}

{% block content %}
    <div class="sbas">
        {% include 'user_score_header.html' %}
        <ul>
            {% for question, a, score, correct_answer, chosen_answer in answers_and_marks %}
                <li class="user-answer-li">
                    {% if request.user.is_authenticated %}
                        <a href="{% url 'sbas:exam_take_user' pk=exam.id sk=forloop.counter0 %}">
                            Question {{forloop.counter}}
                        </a>
                    {% else %}
                        <a href="{% url 'sbas:exam_take' exam.pk forloop.counter0 cid passcode %}">
                            Question {{forloop.counter}}
                        </a>
                    {% endif %}
                    - {{ question.stem |safe}}
                    {% if exam.publish_results %}
                        <span class="correct-answer">Correct answer: {{correct_answer|safe}}</span> <br />
                    {% endif %}

                    Chosen answer: <span class="submitted-user-answer">{{a}}</span>
                    {{chosen_answer|safe}}
                    {% if exam.publish_results or view_all_results %}
                        <span class="answer-{{score}}">(Score: {{score}})</span>
                    {% endif %}
                    {% if request.user.is_staff or view_all_results or request.user in exam.author.all %}
                        {% with ua=user_answers_map|get_item:question.pk %}
                            {% if ua %}
                                <a href="{% url 'generic:view_answer_history' app_name='sbas' model_name='UserAnswer' pk=ua.pk %}" class="btn btn-sm btn-outline-info ms-2" style="font-size: 11px; padding: 2px 6px; vertical-align: middle;">History</a>
                            {% endif %}
                        {% endwith %}
                    {% endif %}

                </li>

            {% endfor %}
        </ul>
        {% include 'user_scores_footer.html' %}
    </div>
{% endblock %}