{% extends 'generic/examcollection_base.html' %}

{% block content %}

    <h1>
        {{ object.name }}
        {% if object.date %}
            [{{object.date}}]
        {% endif %}
    </h1>

    <p>
        <a href="{% url 'generic:examcollection_edit' object.pk %}">Edit</a>
        <a href="{% url 'generic:examcollection_clone' object.pk %}">Clone</a>
        <a href="{% url 'generic:examcollection_delete' object.pk %}">Delete</a>
    </p>

    <div>Authors: {{ object.get_authors }}</div>

    <p>This collection contains the following exams<p>




        {% if object.anatomy_exams.all %}
            <h2>Anatomy Exams:</h2>
            {% with exams=object.anatomy_exams.all app_name="anatomy" %}
                {% include "exam_list.html#exam-list" %}
            {% endwith %}
                
            <a href="{% url 'anatomy:exam_list_collection' object.pk %}">View exam list</a>


            <div class="add-marker">
            <button class="btn-sm add-marker-button" hx-get="{% url 'generic:exam_collection_add_marker' object.pk 'anatomy' %}" hx-target=".add-marker" hx-swap="innerHTML">Add marker to Anatomy Exams</button>
            </div>
        {% endif %}

        {% if object.longs_exams.all %}
            <h2>Longs Exams:</h2>
            {% with exams=object.longs_exams.all app_name="longs" %}
                {% include "exam_list.html#exam-list" %}
            {% endwith %}
            <a href="{% url 'longs:exam_list_collection' object.pk %}">View exam list</a>
            <div class="add-marker">
            <button class="btn-sm add-marker-button" hx-get="{% url 'generic:exam_collection_add_marker' object.pk 'longs' %}" hx-target=".add-marker" hx-swap="innerHTML">Add marker to Longs Exams</button>
            </div>
        {% endif %}

        {% if object.rapids_exams.all %}
            <h2>Rapids Exams:</h2>
            {% with exams=object.rapids_exams.all app_name="rapids" %}
                {% include "exam_list.html#exam-list" %}
            {% endwith %}
            <a href="{% url 'rapids:exam_list_collection' object.pk %}">View exam list</a>
            <div class="add-marker">
            <button class="btn-sm add-marker-button" hx-get="{% url 'generic:exam_collection_add_marker' object.pk 'rapids' %}" hx-target=".add-marker" hx-swap="innerHTML">Add marker to Rapids Exams</button>
            </div>
        {% endif %}

        {% if object.shorts_exams.all %}
            <h2>Shorts Exams:</h2>
            {% with exams=object.shorts_exams.all app_name="shorts" %}
                {% include "exam_list.html#exam-list" %}
            {% endwith %}
            <a href="{% url 'shorts:exam_list_collection' object.pk %}">View exam list</a>
            <div class="add-marker">
            <button class="btn-sm add-marker-button" hx-get="{% url 'generic:exam_collection_add_marker' object.pk 'shorts' %}" hx-target=".add-marker" hx-swap="innerHTML">Add marker to Shorts Exams</button>
            </div>
        {% endif %}

        {% if object.physics_exams.all %}
            <h2>Physics Exams:</h2>
            {% with exams=object.physics_exams.all app_name="physics" %}
                {% include "exam_list.html#exam-list" %}
            {% endwith %}
            <a href="{% url 'physics:exam_list_collection' object.pk %}">View exam list</a>
        {% endif %}

        {% if object.sbas_exams.all %}
            <h2>SBAs Exams:</h2>
            {% with exams=object.sbas_exams.all app_name="sbas" %}
                {% include "exam_list.html#exam-list" %}
            {% endwith %}
            <a href="{% url 'sbas:exam_list_collection' object.pk %}">View exam list</a>
        {% endif %}

        <br/>
    <div id="bulk-add-groups">
    <button class="btn-sm" hx-get="{% url 'generic:exam_collection_bulk_add_groups' object.pk %}" hx-target="#bulk-add-groups" hx-swap="innerHTML">Add groups to exams</button>
    </div>

    <div id="add-user">
    <button hx-get="{% url 'generic:exam_collection_add_author' object.pk %}" hx-target="#add-user" hx-swap="innerHTML">Add author to all exams</button>
    </div>

    {% include 'exam_overview_js.html' %}

{% endblock %}

{% block css %}
    <style>
        .add-marker-button {
            opacity: 0.5;
        }
    </style>
{% endblock %}