From f2e28c0561bb9a74ff0298207d1e195c19bd7e2c Mon Sep 17 00:00:00 2001 From: Ilya Tregubov Date: Mon, 28 Jun 2021 14:35:58 +0200 Subject: [PATCH] MDL-71037 course: Make sections collapsible for Topics/Weeks format. --- .../classes/output/local/content/section.php | 12 ++ .../output/local/content/section/header.php | 6 +- .../templates/local/content/section.mustache | 15 +- .../local/content/section/header.mustache | 58 +++++- .../behat/course_collapse_sections.feature | 192 ++++++++++++++++++ 5 files changed, 268 insertions(+), 15 deletions(-) create mode 100644 course/tests/behat/course_collapse_sections.feature diff --git a/course/format/classes/output/local/content/section.php b/course/format/classes/output/local/content/section.php index 1545d217f17..6d3940bee28 100644 --- a/course/format/classes/output/local/content/section.php +++ b/course/format/classes/output/local/content/section.php @@ -152,6 +152,18 @@ class section implements renderable, templatable { } } + $coursedisplay = $course->coursedisplay ?? COURSE_DISPLAY_SINGLEPAGE; + if ($coursedisplay == COURSE_DISPLAY_MULTIPAGE) { + $data->iscoursedisplaymultipage = true; + } + + if ($course->id == SITEID) { + $data->sitehome = true; + } + + // For now sections are always expanded. User preferences will be done in MDL-71211. + $data->isactive = true; + if ($thissection->section == 0) { // Section zero is always visible only as a cmlist. $cmlist = new $this->cmlistclass($format, $thissection); diff --git a/course/format/classes/output/local/content/section/header.php b/course/format/classes/output/local/content/section/header.php index 595632e9fa5..f6400763c99 100644 --- a/course/format/classes/output/local/content/section/header.php +++ b/course/format/classes/output/local/content/section/header.php @@ -91,10 +91,14 @@ class header implements renderable, templatable { $coursedisplay = $course->coursedisplay ?? COURSE_DISPLAY_SINGLEPAGE; + if ($course->id == SITEID) { + $data->sitehome = true; + } + if (!$format->show_editor() && $coursedisplay == COURSE_DISPLAY_MULTIPAGE && empty($data->issinglesection)) { $data->url = course_get_url($course, $section->section); - $data->name = get_section_name($course, $section); } + $data->name = get_section_name($course, $section); return $data; } diff --git a/course/format/templates/local/content/section.mustache b/course/format/templates/local/content/section.mustache index 0e51f352d99..e0d7459b5f7 100644 --- a/course/format/templates/local/content/section.mustache +++ b/course/format/templates/local/content/section.mustache @@ -70,15 +70,17 @@ "menu": "Edit", "hasmenu": true }, - "cmcontrols": "[Add an activity or resource]" + "cmcontrols": "[Add an activity or resource]", + "iscoursedisplaymultipage": true, + "sectionreturnid": 0, + "isactive": true, + "sitehome": false } }}