{{!
    @template local_kid/student_view

    * ispreview - bool
    * previewoptions - { action, students: [{id, name, selected}] } | null
    * previewbanner - string, optional
    * nopromotion - bool
    * fullname, promotionname, codeena - string
    * downloadurl_docx, downloadurl_pdf - string, optional
    * sections - array of { title, emptylabel, hasitems, items: [{ titre,
      date, statusbadge, publishedlabel, publishedclass,
      itemopenurl, appreciationglobale, commentaireglobal, competences: [{code, libelle,
      niveaulabel, niveauclass, commentaire, moodlefeedback, hasmoodlefeedback}] }] }
}}
<div class="fr-scope">
{{#previewoptions}}
<form method="get" action="{{action}}" class="fr-grid-row fr-grid-row--gutters fr-grid-row--bottom fr-mb-4w">
    <div class="fr-col-12 fr-col-md-4">
        <div class="fr-select-group fr-mb-0">
            <label class="fr-label" for="local-kid-preview-select">{{#str}}student_preview_select_label, local_kid{{/str}}</label>
            <select class="fr-select" name="studentid" id="local-kid-preview-select">
                {{#students}}
                <option value="{{id}}" {{#selected}}selected{{/selected}}>{{name}}</option>
                {{/students}}
            </select>
        </div>
    </div>
    <div class="fr-col">
        <button type="submit" class="fr-btn fr-btn--secondary">{{#str}}student_preview_go, local_kid{{/str}}</button>
    </div>
</form>
{{/previewoptions}}

{{#previewbanner}}
<div class="fr-alert fr-alert--info fr-mb-4w">
    <p>{{previewbanner}}</p>
</div>
{{/previewbanner}}

{{#nopromotion}}
    {{> local_kid/empty_state}}
{{/nopromotion}}

{{^nopromotion}}
<div class="fr-card fr-mb-4w">
    <div class="fr-card__body">
        <div class="fr-card__content">
            <p class="fr-mb-1w"><strong>{{fullname}}</strong><br>
            {{promotionname}}
            {{#codeena}}<br>{{#str}}student_field_code, local_kid{{/str}} : {{codeena}}{{/codeena}}</p>

            {{#downloadurl_docx}}
            <ul class="fr-btns-group fr-btns-group--inline-md fr-btns-group--sm fr-mb-0">
                <li><a class="fr-btn fr-btn--tertiary fr-btn--sm" href="{{downloadurl_docx}}">{{#str}}fiche_download_student, local_kid{{/str}} ({{#str}}fiche_format_docx, local_kid{{/str}})</a></li>
                <li><a class="fr-btn fr-btn--tertiary fr-btn--sm" href="{{downloadurl_pdf}}">{{#str}}fiche_download_student, local_kid{{/str}} ({{#str}}fiche_format_pdf, local_kid{{/str}})</a></li>
            </ul>
            {{/downloadurl_docx}}
        </div>
    </div>
</div>

<div class="fr-mb-2w">
    <button type="button" class="fr-btn fr-btn--tertiary fr-btn--sm" data-role="kid-accordion-toggle-all">{{#str}}student_accordions_collapse_all, local_kid{{/str}}</button>
</div>
<div data-region="kid-student-sections">
{{#sections}}
<section class="fr-accordion fr-mb-2w">
    <h3 class="fr-accordion__title">
        <button class="fr-accordion__btn" aria-expanded="true" aria-controls="kid-student-section-{{slug}}">{{title}}</button>
    </h3>
    <div class="fr-collapse fr-collapse--expanded" id="kid-student-section-{{slug}}">
        {{^hasitems}}
        <p class="fr-text--sm">{{emptylabel}}</p>
        {{/hasitems}}
        {{#hasitems}}
        {{#items}}
        <div class="fr-card fr-mb-2w">
            <div class="fr-card__body">
                <div class="fr-card__content">
                    <h4 class="fr-card__title">
                        <a href="{{itemopenurl}}">{{titre}}</a>{{#date}} — {{date}}{{/date}}
                        {{{statusbadge}}}
                        <span class="{{publishedclass}}">{{publishedlabel}}</span>
                    </h4>
                    <div class="fr-table fr-table--no-caption">
                        <table>
                            <caption>{{titre}}</caption>
                            <thead>
                                <tr>
                                    <th scope="col">{{#str}}grid_competence, local_kid{{/str}}</th>
                                    <th scope="col">{{#str}}grid_niveau, local_kid{{/str}}</th>
                                    <th scope="col">{{#str}}grid_commentaire, local_kid{{/str}}</th>
                                </tr>
                            </thead>
                            <tbody>
                                {{#competences}}
                                <tr>
                                    <td title="{{code}}">{{libelle}}</td>
                                    <td>{{> local_kid/niveau_badge}}</td>
                                    <td>{{commentaire}}</td>
                                </tr>
                                {{#hasmoodlefeedback}}
                                <tr>
                                    <td></td>
                                    <td></td>
                                    <td><strong>{{#str}}eval_feedback_heading, local_kid{{/str}}</strong> : {{moodlefeedback}}</td>
                                </tr>
                                {{/hasmoodlefeedback}}
                                {{/competences}}
                            </tbody>
                        </table>
                    </div>
                    {{#appreciationglobale}}
                    <p class="fr-mb-0"><strong>{{#str}}capp_appreciation_globale, local_kid{{/str}}</strong> : {{appreciationglobale}}</p>
                    {{/appreciationglobale}}
                    {{#commentaireglobal}}
                    <p class="fr-mb-0"><strong>{{#str}}stage_commentaire_global, local_kid{{/str}}</strong> : {{commentaireglobal}}</p>
                    {{/commentaireglobal}}
                </div>
            </div>
        </div>
        {{/items}}
        {{/hasitems}}
    </div>
</section>
{{/sections}}
</div>
{{/nopromotion}}
</div>
