{% extends "@templates/"~template~"/view/base.html.twig" %}

{% block content %}
    <h1>Ranking szkół</h1>
    <h2>{{ type.title }}</h2>

    <ul>
    {% set place = 1 %}
    {% set lastPoints = 0 %}
    {% for rankSchool in rankSchools %}
        {% set sports = rankSchoolSports[rankSchool.id] is defined ? rankSchoolSports[rankSchool.id] : null %}
        {% set place = (lastPoints != rankSchool.points ? loop.index : place) %}
        {% set lastPoints = rankSchool.points %}
        <li>
            {{ place }}. {{ rankSchool.title }} <span class="label alert">{{ rankSchool.points }} pkt</span>
            {% if sports is not null %}
                <ul>
                {% for sport in sports %}
                    <li>{{ sport.title }} <span class="label secondary">{{ sport.points }} pkt</span></li>
                {% endfor %}
                </ul>
            {% endif %}
        </li>

    {% endfor %}
    </ul>
{% endblock %}
