{{!
    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_flexsections/local/content

    Displays the complete course format.

    Example context (json):
    {
        "title": "Course",
        "initialsection": {
            "num": 0,
            "id": 34,
            "cmlist": {
                "cms": [
                    {
                        "cmitem": {
                            "cmformat": {
                                "cmname": {"displayvalue": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Forum example</span></a>"},
                                "hasname": "true"
                            },
                            "cmid": 3,
                            "anchor": "module-3",
                            "module": "forum",
                            "extraclasses": "newmessages"
                        }
                    }
                ],
                "hascms": true
            },
            "iscurrent": true,
            "summary": {
                "summarytext": "Summary text!"
            }
        },
        "sections": [
            {
                "num": 1,
                "id": 35,
                "header": {
                    "title": "Section title",
                    "url": "#"
                },
                "cmlist": {
                    "cms": [
                        {
                            "cmitem": {
                                "cmformat": {
                                    "cmname": {"displayvalue": "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Another forum</span></a>"},
                                    "hasname": "true"
                                },
                                "cmid": 4,
                                "anchor": "module-4",
                                "module": "forum",
                                "extraclasses": "newmessages"
                            }
                        }
                    ],
                    "hascms": true
                },
                "iscurrent": true,
                "summary": {
                    "summarytext": "Summary text!"
                }
            }
        ],
        "format": "flexsections",
        "sectionreturn": 1
    }
}}

{{> format_flexsections/local/navigate_back_to }}

<div id="{{uniqid}}-course-format" data-flexsections-accordion="{{{accordion}}}"
        data-flexsections-mainsection="{{mainsection}}">
    <h2 class="accesshide">{{{title}}}</h2>
    {{{completionhelp}}}
    <ul class="{{format}} flexsections-level-0" data-for="course_sectionlist">
        {{#initialsection}}
            {{> format_flexsections/local/content/section }}
        {{/initialsection}}
        {{#sections}}
            {{> format_flexsections/local/content/section }}
        {{/sections}}
    </ul>
    {{#hasnavigation}}
        <div class="single-section">
            {{#sectionnavigation}}
                {{> format_flexsections/local/content/section }}
            {{/sectionnavigation}}
            <ul class="{{format}}">
                {{#singlesection}}
                    {{> format_flexsections/local/content/section }}
                {{/singlesection}}
            </ul>
            {{#sectionselector}}
                {{> format_flexsections/local/content/section }}
            {{/sectionselector}}
        </div>
    {{/hasnavigation}}
    {{#bulkedittools}}
        {{$ core_courseformat/local/content/bulkedittools}}
            {{> core_courseformat/local/content/bulkedittools}}
        {{/ core_courseformat/local/content/bulkedittools}}
    {{/bulkedittools}}
</div>
{{#js}}
    require(['format_flexsections/local/content'], function(component) {
        component.init('{{uniqid}}-course-format', {}, {{sectionreturn}});
    });
{{/js}}
