. /** * Tiles course format. Display the whole course as "tiles" made of course modules. * * @package format_tiles * @copyright 2018 David Watson {@link http://evolutioncode.uk} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); global $PAGE, $USER; // Horrible backwards compatible parameter aliasing.. if ($topic = optional_param('topic', 0, PARAM_INT)) { $url = $PAGE->url; $url->param('section', $topic); debugging('Outdated topic param passed to course/view.php', DEBUG_DEVELOPER); redirect($url); } // End backwards-compatible aliasing.. $context = context_course::instance($course->id); if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { $course->marker = $marker; course_set_marker($course->id, $marker); } $courseformat = course_get_format($course); // Make sure all sections are created. $course = $courseformat->get_course(); $isediting = $PAGE->user_is_editing(); $renderer = $PAGE->get_renderer('format_tiles'); $ismobile = core_useragent::get_device_type() == core_useragent::DEVICETYPE_MOBILE ? 1 : 0; $allowphototiles = get_config('format_tiles', 'allowphototiles'); $userstopjsnav = get_user_preferences('format_tiles_stopjsnav', 0); // JS navigation and modals in Internet Explorer are not supported by this plugin so we disable JS nav here. $usejsnav = !$userstopjsnav && get_config('format_tiles', 'usejavascriptnav') && !core_useragent::is_ie(); // Inline CSS may be requried if this course is using different tile colours to default - echo this first if so. $templateable = new \format_tiles\output\inline_css_output($course, $ismobile, $usejsnav, $allowphototiles); $data = $templateable->export_for_template($renderer); echo $renderer->render_from_template('format_tiles/inline-css', $data); if ($isediting) { if ($cmid = optional_param('labelconvert', 0, PARAM_INT)) { require_sesskey(); require_once($CFG->dirroot . '/course/format/tiles/locallib.php'); format_tiles_convert_label_to_page($cmid, $course); } // Check if we need to change any session params for teachers expanded section preferences. if (optional_param('expanded', 0, PARAM_INT) == 1) { // User is expanding all sections in course on command. $SESSION->editing_all_sections_expanded_course = $course->id; unset($SESSION->editing_last_edited_section); } else if (optional_param('expanded', 0, PARAM_INT) == -1) { // Cancel all epxanded if user cancels it. unset($SESSION->editing_all_sections_expanded_course); unset($SESSION->editing_last_edited_section); } else if ($secnum = optional_param('expand', 0, PARAM_INT)) { // User is expanding one section. unset($SESSION->editing_all_sections_expanded_course); if ($secnum == -1) { unset($SESSION->editing_last_edited_section); } else { $SESSION->editing_last_edited_section = $course->id . "-" . $secnum; } } } // We display the multi section page if the user is not requesting a specific single section. // We also display it if user is requesting a specific section (URL §ion=xx) with JS enabled. // We know they have JS if $SESSION->format_tiles_jssuccessfullyused is set. // In that case we show them the multi section page and use JS to open the section. if (optional_param('canceljssession', false, PARAM_BOOL)) { // The user is shown a link to cancel the successful JS flag for this session in