From 17e7e3fdc9808c92677191d6a22d10d8d924ff09 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:45:08 +0100 Subject: [PATCH] Compromise with the Course Index that it will always refer to the main course page and the format implement its own single page access and navigation. Fix single section page navigation visibility. --- Changes.md | 3 +++ classes/output/courseformat/content/sectionnavigation.php | 4 ++-- classes/output/courseformat/content/sectionselector.php | 6 ++++-- lib.php | 8 +++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Changes.md b/Changes.md index e033654..7ce55f1 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,9 @@ Version 404.1.1 - Development started ---------------------------- 1. Show section zero if the section has meaningful content. 2. Fix single section page navigation. +3. Compromise with the Course Index that it will always refer to the main course page and the format + implement its own single page access and navigation. +4. Fix single section page navigation visibility. Version 404.1.0 - 01/07/2024 ---------------------------- diff --git a/classes/output/courseformat/content/sectionnavigation.php b/classes/output/courseformat/content/sectionnavigation.php index 2e0ac0b..059ff9c 100644 --- a/classes/output/courseformat/content/sectionnavigation.php +++ b/classes/output/courseformat/content/sectionnavigation.php @@ -68,7 +68,7 @@ public function export_for_template(\renderer_base $output): \stdClass { $back = $this->sectionno - 1; while ($back > 0 && empty($data->previousurl)) { - if ($canviewhidden || $sections[$back]->uservisible) { + if ($canviewhidden || $format->is_section_visible($back)) { if (!$sections[$back]->visible) { $data->previoushidden = true; } @@ -82,7 +82,7 @@ public function export_for_template(\renderer_base $output): \stdClass { $forward = $this->sectionno + 1; $numsections = $format->get_last_section_number(); while ($forward <= $numsections && empty($data->nexturl)) { - if ($canviewhidden || $sections[$forward]->uservisible) { + if ($canviewhidden || $format->is_section_visible($forward)) { if (!$sections[$forward]->visible) { $data->nexthidden = true; } diff --git a/classes/output/courseformat/content/sectionselector.php b/classes/output/courseformat/content/sectionselector.php index 7e462a8..4d42b85 100644 --- a/classes/output/courseformat/content/sectionselector.php +++ b/classes/output/courseformat/content/sectionselector.php @@ -65,8 +65,10 @@ public function export_for_template(\renderer_base $output): \stdClass { while ($section <= $numsections) { $thissection = $modinfo->get_section_info($section); $url = $format->get_view_url($section, ['navigation' => false]); - if ($thissection->uservisible && $url && $section != $data->currentsection) { - $sectionmenu[$url->out(false)] = get_section_name($course, $section); + if ($url && $section != $data->currentsection) { + if ($format->is_section_visible($thissection)) { + $sectionmenu[$url->out(false)] = get_section_name($course, $section); + } } $section++; } diff --git a/lib.php b/lib.php index 3fb16e2..f53b6b3 100644 --- a/lib.php +++ b/lib.php @@ -420,11 +420,9 @@ public function get_view_url($section, $options = []) { $sectionno = $section; } if ((!empty($options['navigation'])) && $sectionno !== null) { - // Display section on separate page. - $sectioninfo = $this->get_section($sectionno); - return new moodle_url('/course/section.php', ['id' => $sectioninfo->id]); - } - if ($this->uses_sections() && $sectionno !== null) { + // Unlike core, navigate to section on course page. + $url->set_anchor('section-'.$sectionno); + } else if ($this->uses_sections() && $sectionno !== null) { if ($this->coursedisplay == COURSE_DISPLAY_MULTIPAGE) { $url->param('section', $sectionno); } else {