{{!
    This file is part of Moodle - https://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/format

    Format view file.

    Context variables required for this template:
    * component
    * copyright

    Example context (json):
    {
        "component": "local_test",
        "copyright": "2022 Ferran Recio <ferran@moodle.com>"
    }
}}
{{< common/boilerplate_php }}
{{$ description }} Display the whole course.{{/ description }}
{{$ package }}{{ component }}{{/ package }}
{{$ copyright }}{{ copyright }}{{/ copyright }}
{{/ common/boilerplate_php }}

defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir . '/filelib.php');
require_once($CFG->libdir . '/completionlib.php');

// Retrieve course format option fields and add them to the $course object.
$format = course_get_format($course);
$course = $format->get_course();
$context = context_course::instance($course->id);

// Add any extra logic here.

{{# format_features.uses_sections }}
// Make sure section 0 is created.
course_create_sections_if_missing($course, 0);
{{/ format_features.uses_sections }}

$renderer = $format->get_renderer($PAGE);

{{# format_features.uses_sections }}
// Setup the format base instance.
if (!empty($displaysection)) {
    $format->set_section_number($displaysection);
}
{{/ format_features.uses_sections }}

// Output course content.
$outputclass = $format->get_output_classname('content');
$widget = new $outputclass($format);
echo $renderer->render($widget);

// Include any format js module here using $PAGE->requires->js.
