{# Render a list of submissions for a team page #}
{# @var submission \App\Entity\Submission #}

{% if submissions is empty %}
    <div class="alert alert-warning">No submissions</div>
{% else %}
    {% set is_scoring = false %}
    {% if contest.scoreboardTypeString == 'score' %}
        {% set is_scoring = true %}
    {% endif %}

    <table class="data-table table table-hover table-sm submissions-table">
        <thead class="thead-light">
        <tr>
            <th scope="col">time</th>
            <th scope="col">problem</th>
            <th scope="col">lang</th>
            <th scope="col">result</th>
            {% if is_scoring %}
                <th scope="col" class="right">score</th>
            {% endif %}
            {% if contest.getRuntimeAsScoreTiebreaker() %}
                <th scope="col">runtime</th>
            {% endif %}
            {% if allowDownload %}
                <th scope="col"></th>
            {% endif %}
        </tr>
        </thead>
        <tbody>
        {%- for submission in submissions %}
            {% set link = null %}
            {% if (submission.submittime < current_team_contest.endtime or showTooLateResult) and submission.result and submission.judgings.first is not empty and submission.judgings.first.result is not empty and (not verificationRequired or submission.judgings.first.verified) %}
                {% set link = path('team_submission', {submitId: submission.externalid}) %}
            {% endif %}

            {% set classes = '' %}
            {% if not submission.valid %}
                {% set classes = classes ~ ' ignore' %}
            {% endif %}
            <tr class="{{ classes }}">
                <td>
                    <a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %}>
                        {{ submission.submittime | printtime(null, submission.contest) }}
                    </a>
                </td>
                <td class="probid">
                    <a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %} title="{{ submission.problem.name }}">
                        {{ submission.contestProblem | problemBadge }}
                    </a>
                </td>
                <td class="langid">
                    <a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %} title="{{ submission.language.name }}">
                        {{ submission.language.name }}
                    </a>
                </td>
                <td>
                    <a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %}>
                        {%- if submission.submittime >= submission.contest.endtime %}
                            {{ 'too-late' | printResult }}
                        {%- endif %}
                        {%- if submission.submittime < submission.contest.endtime or showTooLateResult %}
                            {%- if submission.submittime >= submission.contest.endtime %}
                                /
                            {% endif %}
                            {%- if submission.judgings.first is empty or submission.judgings.first.result is empty %}
                                {{- '' | printResult -}}
                            {%- elseif verificationRequired and not submission.judgings.first.verified %}
                                {{- '' | printResult -}}
                            {%- else %}
                                {{- submission.judgings.first.result | printResult -}}
                            {%- endif %}
                        {%- endif %}
                    </a>
                </td>
                {% if is_scoring %}
                    <td class="right">
                        {% if submission.score is not null %}
                            {{ submission.score | number_format(2, '.', '') }}
                        {% else %}
                            {{ '-' }}
                        {% endif %}
                    </td>
                {% endif %}
        {% if contest.getRuntimeAsScoreTiebreaker() %}
                <td>
                    <a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %}>
                        {% if link and submission.getResult()=='correct' %}
                            {{ "%0.3f s" | format(submission.judgings.first.getMaxRuntime()) }}
                        {% else %}
                            -
                        {% endif %}
                    </a>
                </td>
        {% endif %}
        {% if allowDownload %}
                <td>
                    <a title="Download submission ZIP" aria-label="download submission zip" href="{{ path('team_submission_download', {'submitId': submission.externalid}) }}">
                        <i class="fa fa-file-archive"></i>
                    </a>
                </td>
        {% endif %}
            </tr>
        {%- endfor %}
        </tbody>
    </table>
{% endif %}
