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

{% block content %}
    <h1>Ranking gmin</h1>
    <h2>{{ type.title }}</h2>

    <ul>
        {% set place = 1 %}
        {% set lastPoints = 0 %}
        {% for commune in communes %}
            {% set communeSchools = schools[commune.id] is defined ? schools[commune.id] : null %}
            {% set place = (lastPoints != commune.points ? loop.index : place) %}
            {% set lastPoints = commune.points %}
            <li>
                {{ place }}. {{ commune.communeTitle}} <span class="label alert">{{ commune.points }} pkt</span>
                {% if communeSchools is not null %}
                    <ul>
                        {% for school in communeSchools %}
                            <li>{{ school.title }} <span class="label secondary">{{ school.points }} pkt</span></li>
                        {% endfor %}
                    </ul>
                {% endif %}
            </li>

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