{% load partials %}

{% partialdef publish-results %}
    <div id="publish-results-status" class="d-flex align-items-center gap-2">
        <div class="me-2 small text-muted">Publish results</div>
        <div>
            {% if exam.publish_results %}
                <button
                    class="btn btn-sm btn-success"
                    hx-post="{% url exam.get_app_name|add:':exam_toggle_results_published' exam.pk %}"
                    hx-swap="outerHTML"
                    hx-target="#publish-results-status"
                    title="Click to unpublish results"
                    aria-label="Unpublish results"
                    hx-disabled-elt="this"

                >Published</button>
            {% else %}
                <button
                    class="btn btn-sm btn-secondary"
                    hx-post="{% url exam.get_app_name|add:':exam_toggle_results_published' exam.pk %}"
                    hx-swap="outerHTML"
                    hx-target="#publish-results-status"
                    title="Click to publish results"
                    aria-label="Publish results"
                    hx-disabled-elt="this"
                >Unpublished</button>
            {% endif %}
        </div>
    </div>
{% endpartialdef publish-results %}


{% partialdef exam-active %}
    <div id="exam-active-status" class="d-flex align-items-center gap-2">
        <div class="me-2 small text-muted">Exam active</div>
        <div>
            {% if exam.active %}
                <button
                    class="btn btn-sm btn-success"
                    hx-post="{% url exam.get_app_name|add:':exam_toggle_active' exam.pk %}"
                    hx-swap="outerHTML"
                    hx-target="#exam-active-status"
                    title="Click to deactivate this exam"
                    aria-label="Deactivate exam"
                    hx-disabled-elt="this"
                >Active</button>
            {% else %}
                <button
                    class="btn btn-sm btn-secondary"
                    hx-post="{% url exam.get_app_name|add:':exam_toggle_active' exam.pk %}"
                    hx-swap="outerHTML"
                    hx-target="#exam-active-status"
                    title="Click to activate this exam"
                    aria-label="Activate exam"
                    hx-disabled-elt="this"
                >Inactive</button>
            {% endif %}
        </div>
    </div>
{% endpartialdef exam-active %}