{% import '@ChamiloTheme/Macros/box.html.twig' as macro %}

{% autoescape false %}
    {% if not session is empty %}
        <div class="grid-session">
    {% for item in session %}
        {% set image %}
            {% if item.category %}
                <div class="category" style="background: {{ item.color.color }}; color:{{ item.color.luminosity }}">
                    {{ item.category.name }}
                </div>
            {% endif %}
            <img src="{{ item.image }}" class="img-fluid">
        {% endset %}
        {% set title %}

            {% if item.show_actions %}
                <div class="float-right">
                    <a class="btn btn-outline-secondary btn-sm" title="{{ "Edit"|get_lang }}" href="{{ _p.web_main ~ "session/resume_session.php?id_session=" ~ row.id }}">
                        <i class="fas fa-pencil-alt"></i>
                    </a>
                </div>
            {% endif %}

            <h5 class="card-title">
                <a href="{{ item.url }}" class="" title="{{ item.title }}">{{ item.title }}</a>
            </h5>

            <div class="card-date d-flex flex-row bd-highlight">
                <span class="date px-2 bd-highlight">
                    <i class="far fa-calendar"></i>
                    {{ item.date }}
                </span>
            </div>
            <div class="card-details d-flex flex-row bd-highlight mb-3">
                <span class="num-users px-2 bd-highlight">
                    <i class="fas fa-user"></i>
                    {{ item.num_users }}
                </span>
                <span class="num-courses px-2 bd-highlight">
                    <i class="fas fa-book"></i>
                    {{ item.num_courses }}
                </span>
            </div>
            {#{% if item.description %}
                <div class="card-description">
                    {{ item.description }}
                </div>
            {% endif %}#}
            {% if item.coach_name %}
                <div class="card-coach">
                    {{ item.coach_name }}
                </div>
            {% endif %}
        {% endset %}
        {% set content %}

            <ul class="list-group list-group-flush">
                {% for row in item.courses %}
                    <li class="list-group-item">
                        <img src="{{ row.icon }}" width="32px">
                        <a href="{{ row.link }}">{{ row.name }}</a>
                    </li>
                {% endfor %}
            </ul>


            {% if item.student_info %}
                {% if (item.student_info.progress is not null) and (item.student_info.score is not null) %}
                    <div class="card-report">
                        <div class="student-info">
                            {% if (item.student_info.progress is not null) %}
                                {{ "StudentCourseProgressX" | get_lang | format(item.student_info.progress) }}
                            {% endif %}

                            {% if (item.student_info.score is not null) %}
                                {{ "StudentCourseScoreX" | get_lang | format(item.student_info.score) }}
                            {% endif %}

                            {% if (item.student_info.certificate is not null) %}
                                {{ "StudentCourseCertificateX" | get_lang | format(item.student_info.certificate) }}
                            {% endif %}
                        </div>
                    </div>
                {% endif %}
            {% endif %}

        {% endset %}
        <div class="item-session">
            {{ macro.box_session(item.id, title, content, image) }}
        </div>

    {% endfor %}
        </div>
        {% endif %}
{% endautoescape %}