{% load i18n %}
{% load tz %}
<div id="openassessment__student-info" class="staff-info__student__report">
    {% if submission %}
    <h2 class="title">
        <span class="label">{% trans "Student Information" %}</span>
    </h2>

    <div class="staff-info__content ui-staff__content">
        <div class="wrapper--step__content">
            <div class="step__content">
                <h3 class="title">{% trans "Student Response" %}</h3>
                <div class="student__answer__display__content">
                    {% if workflow_cancellation %}
                        {% blocktrans with removed_by_username=workflow_cancellation.cancelled_by removed_datetime=workflow_cancellation.created_at|utc|date:"N j, Y H:i e" %}
                            Student submission removed by {{ removed_by_username }} on {{ removed_datetime }}
                        {% endblocktrans %}
                        <br>
                        <!-- Comments: Reason for Cancellation-->
                        {% blocktrans with comments=workflow_cancellation.comments %}
                            Comments: {{ comments }}
                        {% endblocktrans %}
                    {% else %}
                        {% include "openassessmentblock/oa_submission_answer.html" with answer=submission.answer answer_text_label="The student's response to the question above:" %}
                    {% endif %}
                </div>

                {% if submission.image_url %}
                <img
                    class="submission--image"
                    alt="{% trans "The image associated with this response" %}"
                    src="{{ submission.image_url }}"
                />
                {% endif %}
            </div>
        </div>

        {% if not workflow_cancellation %}
        <div id="openassessment__staff-info__cancel__submission"
             class="openassessment__staff-info__cancel__submission wrapper--ui-staff wrapper--ui--collapse">
            <div class="ui-staff ui-toggle-visibility is--collapsed">
                <h2 class="staff-info__title ui-staff__title ui-toggle-visibility__control">
                    <i class="ico icon-caret-right"></i>
                    <span class="staff-info__title__copy">{% trans "Remove submission from peer grading" %}</span>
                </h2>

                <div class="staff-info__cancel-submission__content ui-toggle-visibility__content">
                    <div class="ui-staff__content__section">
                        <div class="wrapper--input">

                            <form id="openassessment_staff_cancel_submission_form"
                                  data-submission-uuid="{{ submission.uuid }}">

                                <ul class="list list--actions">
                                    <li>
                                        <div class="has--warnings">
                                            <div class="warning">
                                                {% trans "Caution: Removing a student's submission is irreversible. It should only be used in cases where the student's submission was inappropriate." %}
                                            </div>
                                        </div>
                                    </li>
                                    <li>
                                        <label for="staff-info__cancel-submission__comments"
                                               class="label">{% trans "Comments:" %}</label>
                                    </li>
                                    <li>
                                        <textarea
                                                id="staff-info__cancel-submission__comments"
                                                class="cancel_submission_comments"
                                                value=""
                                                maxlength="10000"></textarea>
                                    </li>
                                </ul>
                                <ul class="list list--actions">
                                    <li class="list--actions__item">
                                        <a data-submission-uuid="{{ submission.uuid }}" aria-role="button" href=""
                                           id="submit_cancel_submission" class="action--submit is--disabled">
                                            <span class="copy">{% trans "Remove submission" %}</span>
                                        </a>

                                        <div class="cancel-submission-error"></div>
                                    </li>
                                </ul>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}

        {% if peer_assessments %}
        <div class="staff-info__status ui-staff__content__section">
            <h3 class="title">{% trans "Peer Assessments for This Student" %}</h3>
            {% for assessment in peer_assessments %}
                {% with peer_num=forloop.counter %}
                <h4 class="title--sub"> {% trans "Peer" %} {{ peer_num }}: </h4>
                <table class="staff-info__status__table" summary="{% trans "Assessment" %}">
                    <thead>
                    <tr>
                        <th abbr="Criterion" scope="col">{% trans "Criterion" %}</th>
                        <th abbr="Selected Option" scope="col">{% trans "Selected Option" %}</th>
                        <th abbr="Feedback" scope="col">{% trans "Feedback" %}</th>
                        <th abbr="Points" scope="col">{% trans "Points" %}</th>
                        <th abbr="Points Possible" scope="col">{% trans "Points Possible" %}</th>
                    </tr>
                    </thead>

                    <tbody>
                    {% for criterion in rubric_criteria %}
                        {% for part in assessment.parts %}
                            {% if part.option.criterion.name == criterion.name %}
                        <tr>
                            <td class="label">{{ criterion.label }}</td>
                            <td class="value">{{ part.option.name }}</td>
                            <td class="value">{{ part.feedback }}</td>
                            <td class="value">{{ part.option.points }}</td>
                            <td class="value">{{ criterion.total_value }}</td>
                        </tr>
                            {% endif %}
                        {% endfor %}
                    {% endfor %}
                    </tbody>
                </table>
            <h4 class="title--sub">{% trans "Overall Feedback" %}</h4>
            <div class="student__answer__display__content">
                {{ assessment.feedback|linebreaks }}
            </div>
                {% endwith %}
            {%  endfor %}
        </div>
        {% endif %}

        {% if submitted_assessments %}
        <div class="staff-info__status ui-staff__content__section">
            <h3 class="title">{% trans "Peer Assessments Completed by This Student" %}</h3>
            {% for assessment in submitted_assessments %}
                {% with peer_num=forloop.counter %}
                    <h4 class="title--sub">{% trans "Assessment" %} {{ peer_num }}:</h4>
                    <table class="staff-info__status__table" summary="{% trans "Assessment" %}">
                        <thead>
                        <tr>
                            <th abbr="Criterion" scope="col">{% trans "Criterion" %}</th>
                            <th abbr="Selected Option" scope="col">{% trans "Selected Option" %}</th>
                            <th abbr="Feedback" scope="col">{% trans "Feedback" %}</th>
                            <th abbr="Points" scope="col">{% trans "Points" %}</th>
                            <th abbr="Points Possible" scope="col">{% trans "Points Possible" %}</th>
                        </tr>
                        </thead>

                        <tbody>
                        {% for criterion in rubric_criteria %}
                            {% for part in assessment.parts %}
                                {% if part.option.criterion.name == criterion.name %}
                                    <tr>
                                        <td class="label">{{ criterion.label }}</td>
                                        <td class="value">{{ part.option.name }}</td>
                                        <td class="value">{{ part.feedback }}</td>
                                        <td class="value">{{ part.option.points }}</td>
                                        <td class="value">{{ criterion.total_value }}</td>
                                    </tr>
                                {% endif %}
                            {% endfor %}
                        {% endfor %}
                        </tbody>
                    </table>
                    <h4 class="title--sub">{% trans "Overall Feedback" %}</h4>
                    <div class="student__answer__display__content">
                        {{ assessment.feedback|linebreaks }}
                    </div>
                {% endwith %}
            {%  endfor %}
        </div>
        {% endif %}

        {% if self_assessment %}
        <div class="staff-info__status ui-staff__content__section">
            <h3 class="title">{% trans "Student's Self Assessment" %}</h3>
            <table class="staff-info__status__table" summary="{% trans "Self Assessment" %}">
                <thead>
                <tr>
                    <th abbr="Criterion" scope="col">{% trans "Criterion" %}</th>
                    <th abbr="Selected Option" scope="col">{% trans "Selected Option" %}</th>
                    <th abbr="Points" scope="col">{% trans "Points" %}</th>
                    <th abbr="Points Possible" scope="col">{% trans "Points Possible" %}</th>
                </tr>
                </thead>

                <tbody>
                {% for criterion in rubric_criteria %}
                    {% for part in self_assessment.parts %}
                        {% if part.option.criterion.name == criterion.name %}
                            <tr>
                                <td class="label">{{ criterion.label }}</td>
                                <td class="value">{{ part.option.name }}</td>
                                <td class="value">{{ part.option.points }}</td>
                                <td class="value">{{ criterion.total_value }}</td>
                            </tr>
                        {% endif %}
                    {% endfor %}
                {% endfor %}
                </tbody>
            </table>
        </div>
        {% endif %}

        {% if example_based_assessment %}
            <div class="staff-info__status ui-staff__content__section">
                <h3 class="title">{% trans "Example-Based Assessment" %}</h3>
                <table class="staff-info__status__table" summary="{% trans "Example Based Assessment" %}">
                    <thead>
                    <tr>
                        <th abbr="Criterion" scope="col">{% trans "Criterion" %}</th>
                        <th abbr="Selected Option" scope="col">{% trans "Selected Option" %}</th>
                        <th abbr="Points" scope="col">{% trans "Points" %}</th>
                        <th abbr="Points Possible" scope="col">{% trans "Points Possible" %}</th>
                    </tr>
                    </thead>

                    <tbody>
                    {% for criterion in rubric_criteria %}
                        {% for part in example_based_assessment.parts %}
                            {% if part.option.criterion.name == criterion.name %}
                                <tr>
                                    <td class="label">{{ criterion.label }}</td>
                                    <td class="value">{{ part.option.name }}</td>
                                    <td class="value">{{ part.option.points }}</td>
                                    <td class="value">{{ criterion.total_value }}</td>
                                </tr>
                            {% endif %}
                        {% endfor %}
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        {% endif %}
    </div>
    {% else %}
        {% trans "Couldn't find a response for this student." %}
    {% endif %}
</div>