{% extends 'atlas/exams.html' %}

{% block content %}
    <h2>{{collection.name}}</h2>


    {% if userexams %}
        <h3>Users</h3>

        <ul>
            {% for userexam in userexams %}
                <li id="user-history-{{ userexam.user_user.pk }}">
                    <b><a href="{% url 'atlas:collection_history_user' collection.pk userexam.user_user.pk %}">{{userexam.get_user_name}}</a><b><br/>
                        Completed: {{userexam.completed}}<br/>
                        Started: {{userexam.start_time}}, Ended: {{userexam.end_time}}<br/>

                        <button
                            hx-post="{% url 'atlas:collection_reset_answers_user' collection.pk userexam.user_user.pk %}"
                            hx-target="#user-history-{{ userexam.user_user.pk }}"
                            hx-swap="outerHTML"
                            hx-confirm="Are you sure you want to delete this user's collection history?"
                            class="btn btn-danger btn-sm remove-button">
                            Delete
                        </button>
                    </li>
            {% endfor %}
        </ul>
    {% endif %}


    {% if cidexams %}
        <h3>CID Users</h3>

        <ul>
            {% for cidexam in cidexams %}
                <li id="cid-history-{{ cidexam.cid_user.pk }}">
                    <b><a href="{% url 'atlas:collection_history_ciduser' collection.pk cidexam.cid_user.cid %}">{{cidexam.cid_user}}</a><b><br/>
                        Completed: {{cidexam.completed}}<br/>
                        Started: {{cidexam.start_time}}, Ended: {{cidexam.end_time}}<br/>

                        <button
                            hx-post="{% url 'atlas:collection_reset_answers_ciduser' collection.pk cidexam.cid_user.cid %}"
                            hx-target="#cid-history-{{ cidexam.cid_user.cid }}"
                            hx-swap="outerHTML"
                            hx-confirm="Are you sure you want to delete this CID user's collection history?"
                            class="btn btn-danger btn-sm remove-button">
                            Delete
                        </button>
                    </li>
            {% endfor %}
        </ul>
    {% endif %}

{% endblock %}
