{% extends 'rapids/exams.html' %}
{% block navigation %}
    {{ block.super }}
    {% include 'generic/exam_overview_headers.html' %}
{% endblock navigation %}

{% block content %}

    {% load thumbnail %}
    <div class="rapids">

        {% if exam.exam_mode %}
            <a href="{% url exam.get_app_name|add:':mark_overview' pk=exam.pk %}"><button>Mark exam</button></a>
            <a href="{% url 'rapids:mark_review' exam_pk=exam.pk sk=0 %}"><button>Review exam</button></a></p>
        {% endif %}

        {# Migrate all rapids in this exam to shorts (exam authors + superusers) #}
        {% if request.user.is_superuser or request.user in exam.author.all %}
            <a href="{% url 'rapids:exam_migrate_rapids_to_shorts' pk=exam.pk %}" onclick="return confirm('Migrate all rapids in this exam to shorts? This will create new short questions.')"><button>Migrate all to Shorts</button></a>
        {% endif %}

        <ol id="full-question-list" class="sortable">
            {% for question in questions.all %}

                <li data-question_pk={{question.pk}}>
                    <span class="flex-col">
                        <a href="{% url 'rapids:exam_question_detail' pk=exam.pk sk=forloop.counter0 %}">
                            {% for image in question.get_images %}
                                <img src="{{ image|thumbnail_url:'exam-list' }}" alt="thumbail" />
                            {% empty %}
                                No image added.
                            {% endfor %}
                        </a>
                    </span>
                    <span class="flex-col-4">
                        {% if not question.normal %}
                            <b>Abnormality:</b> {{ question.get_abnormalities }} <b>Region:</b> {{ question.get_regions }}
                            <br />
                            {{ question.get_primary_answer }}
                        {% else %}
                            <b>Normal</b>
                        {% endif %}
                        <br />
                        Examination: {{ question.get_examinations }},
                        {% if exam.exam_mode %}
                            <a href="{% url 'rapids:mark' exam_pk=exam.pk sk=forloop.counter0 %}">Mark</a>
                        {% endif %}
                        <span class="id"><a href="{% url 'rapids:question_detail' pk=question.pk %}">[id: {{question.pk}}]</a></span>
                    </span>
                </li>
            {% endfor %}
        </ol>
        <div>
            Author: {% for author in exam.author.all %}
                {{ author }},
            {% endfor %}
        </div>
        {% include 'generic/exam_footer.html' %}

    </div>
    {% include 'exam_overview_js.html' %}

{% endblock %}