<div class="row">
<div class="col-md-8 col-12">
<h4 class="mb-3">{{ 'Score'|trans }}</h4>
<div class="btn-toolbar mb-3" role="toolbar">
    <div class="btn-group me-2">
        <form action="{{ path('tvdt_prepare_elimination', {seasonCode: season.seasonCode, quiz: quiz.id}) }}" method="POST">
            <input type="hidden" name="_token" value="{{ csrf_token('prepare_elimination') }}">
            <button type="submit" class="btn btn-secondary rounded-0 rounded-start">{{ 'Prepare Custom Elimination'|trans }}</button>
        </form>
        {%~ if not quiz.eliminations.empty %}
            <button class="btn btn-secondary dropdown-toggle"
                    data-bs-toggle="dropdown">{{ 'Load Prepared Elimination'|trans }}</button>
            <ul class="dropdown-menu">
                {%~ for elimination in quiz.eliminations %}
                    <li><a class="dropdown-item"
                           href="{{ path('tvdt_prepare_elimination_view', {elimination: elimination.id}) }}">{{ elimination.createdAt|format_datetime() }}</a>
                    </li>
                {%~ endfor %}
            </ul>
        {% endif %}
    </div>
</div>
<p class="mb-3">{{ 'Number of dropouts:'|trans }}  {{ quiz.dropouts }} </p>
<table class="table table-hover table-result mb-3">
    <thead>
    <tr>
        <th scope="col">{{ 'Candidate'|trans }}</th>
        <th class="col-result-sm" scope="col">{{ 'Correct Answers'|trans }}</th>
        <th class="col-result-md" scope="col">{{ 'Corrections'|trans }}</th>
        <th class="col-result-md" scope="col">{{ 'Penalty'|trans }}</th>
        <th class="col-result-xs" scope="col">{{ 'Score'|trans }}</th>
        <th class="col-result-md" scope="col">{{ 'Time'|trans }}</th>
    </tr>
    </thead>
    <tbody>
    {%~ for candidate in result ~%}
        <tr class="table-{% if loop.revindex > quiz.dropouts %}success{% else %}danger{% endif %}">
            <td>{{ candidate.name }}</td>
            <td>{{ candidate.correct|default('0') }}</td>
            <td>
                <form method="post"
                      action="{{ path('tvdt_backoffice_modify_correction', {quiz: quiz.id, candidate: candidate.id}) }}">
                    <input type="hidden" name="_token" value="{{ csrf_token('candidate_correction') }}">
                    <div class="d-flex gap-1">
                        <input class="form-control form-control-sm" type="number"
                               value="{{ candidate.corrections }}" step="0.5"
                               name="corrections">
                        <button class="btn btn-sm btn-primary" type="submit">{{ 'Save'|trans }}</button>
                    </div>
                </form>
            </td>
            <td>
                <form method="post"
                      action="{{ path('tvdt_backoffice_modify_penalty', {quiz: quiz.id, candidate: candidate.id}) }}">
                    <input type="hidden" name="_token" value="{{ csrf_token('candidate_penalty') }}">
                    <div class="d-flex gap-1">
                        <input class="form-control form-control-sm" type="number"
                               value="{{ candidate.penaltySeconds }}" step="1"
                               name="penalty">
                        <button class="btn btn-sm btn-primary" type="submit">{{ 'Save'|trans }}</button>
                    </div>
                </form>
            </td>
            <td>{{ candidate.score|default('x') }}</td>
            <td>{{ candidate.time.format('%i:%S') }}</td>
        </tr>
    {% else %}
        <tr>
            <td colspan="6">{{ 'No results'|trans }}</td>
        </tr>
    {% endfor %}
    </tbody>
</table>
</div>
<div class="col-md-4 col-12">
    {{ include('backoffice/help/quiz_result.html.twig') }}
</div>
</div>
