{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}

{{!
    @template format_tiles/multi_section_page

    Multi section page template.

    The purpose of this template is to render the course landing page
    i.e. all of the tiles representing all of the sections in the course

    Either this or single_section_page will be the first template called
    when the user launches a page from PHP

    Classes required for JS:
    * none

    Data attributes required for JS:
    * none

    Context variables required for this template:
        * from_ajax - is this called from AJAX?
        * completionenabled - is completion enabled?
        * section_zero - info for section_zero template,
        * tiles - info for multi_section_tile and multi_section_tilebar templates
        * all_tiles_expanded - are we expanding all tiles?
        * activity_clipboard - moodle activity clipboard (not tiles),
        * course_activity_clipboard: moodle course activity clipboard (not tiles)

    Context variables required for Snap in this template:
        * course_tools - from shared::course_tools output HTML to render Snap Course tools
        * edit_mode - from shared::render_edit_mode output HTML to render edit mode button
        See theme/snap/classes/output/format_tiles/content/tiles_content.php

    Example context (json):
    {
        "from_ajax": 1,
        "completionenabled": 1,
        "section_zero": [],
        "tiles": [],
        "all_tiles_expanded": 0,
        "activity_clipboard": "",
        "course_activity_clipboard": ""
    }
}}

<section id="tiles-section" class="clearfix" tabindex="-1"> {{! Open LMS patch for INT-17879. }}

{{^from_ajax}}
    {{> format_tiles/above_tiles}}
{{/from_ajax}}

{{^jsnavuserenabled}}
    <div id="jswarning" class="alert alert-secondary">
        {{#str}}jsdeactivated, format_tiles{{/str}}
        <a href="{{{config.wwwroot}}}/course/view.php?id={{courseid}}&stopjsnav=1">({{#str}}reactivate, format_tiles{{/str}})</a>
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">&times;</span>
            <span class="sr-only">{{#str}}dismissnotification, core{{/str}}</span>
        </button>
    </div>
{{/jsnavuserenabled}}
{{#jsnavuserenabled}}
    <noscript>
        {{^jsSessionDisabled}}
            <div id="jswarning" class="alert alert-secondary">{{#str}}nojswarning, format_tiles{{/str}}
                {{#showJScancelLink}}
                    <a href="{{{config.wwwroot}}}/course/view.php?id={{courseid}}&stopjsnav=1">{{#str}}refresh{{/str}}</a>
                {{/showJScancelLink}}
                <button type="button" class="close" data-dismiss="alert">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">{{#str}}dismissnotification, core{{/str}}</span>
                </button>
            </div>
        {{/jsSessionDisabled}}
    </noscript>
{{/jsnavuserenabled}}

{{#showinitialpageloadingicon}}
    <a id="page-loading-icon" href="{{config.wwwroot}}/course/view.php?id={{courseid}}&skipcheck=1">
        <div class="text-center mt-5">
        {{> format_tiles/loading}}
            <div class="text-center" style="text-decoration: none;"><small>{{#str}}clickiffailstoload, format_tiles{{/str}}</small></div>
        </div>
    </a>
{{/showinitialpageloadingicon}}

<ul class="tiles" id="multi_section_tiles">
    {{#tiles}}
        {{^editing}}
            {{> format_tiles/multi_section_tile}}
        {{/editing}}
        {{#editing}}
            {{> format_tiles/multi_section_tilebar}}
        {{/editing}}
    {{/tiles}}

    {{^editing}}
    {{!empty tiles at end to ensure correct flex spacing of last row}}
        <li class="tile spacer" aria-hidden="true"></li>
        <li class="tile spacer" aria-hidden="true"></li>
        <li class="tile spacer" aria-hidden="true"></li>
        <li class="tile spacer" aria-hidden="true"></li>
        <li class="tile spacer" aria-hidden="true"></li>
        <li class="tile spacer" aria-hidden="true"></li>
        <li class="tile spacer" aria-hidden="true" id="lasttile"></li>

        {{!moveable sections for JS to add content to and move around (one relating to each tile)}}
        {{#tiles}}
            <li class="section main moveablesection" style="display: none;" id="section-{{tileid}}"
                data-section="{{tileid}}" data-sectionid="{{secid}}"></li>
        {{/tiles}}
    {{/editing}}
</ul>
</section>

{{#editing}}
    {{^from_ajax}}
        {{activity_clipboard}}
    {{/from_ajax}}
    {{{course_activity_clipboard}}}
{{/editing}}

<div id="format_tiles_overlay" style="position: fixed; top: 0; left: 0; background-color:rgba(0,0,0,0.5); width: 100vw; height: 100vh; display: none;"></div>

{{{ course_tools }}}
{{{ edit_mode }}}
