From 20de2b68ffd80ce0cc9647412bef8ac80d02f5f8 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:28:41 +0000 Subject: [PATCH] Cope with course index. --- classes/output/courseformat/content.php | 5 ----- lib.php | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/classes/output/courseformat/content.php b/classes/output/courseformat/content.php index 537c99dc..53744b3b 100644 --- a/classes/output/courseformat/content.php +++ b/classes/output/courseformat/content.php @@ -366,11 +366,6 @@ protected function get_grid_sections(\renderer_base $output, $settings): array { continue; } - $sectionformatoptions = $format->get_format_options($thissection); - if ($sectionformatoptions['sectionhideingrid'] == 2) { // Yes. - continue; - } - $section = new stdClass(); $section->id = $thissection->id; $section->num = $thissection->section; diff --git a/lib.php b/lib.php index 2fdd00c8..6333fd23 100755 --- a/lib.php +++ b/lib.php @@ -207,9 +207,9 @@ public function get_default_section_name($section) { * @return bool; */ public function is_section_visible(section_info $section): bool { + global $PAGE; if ($section->section > $this->get_last_section_number()) { // Stealth section. - global $PAGE; $context = context_course::instance($this->course->id); if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) { $modinfo = get_fast_modinfo($this->course); @@ -218,6 +218,12 @@ public function is_section_visible(section_info $section): bool { } // Don't show. return false; + } else if (!$PAGE->user_is_editing()) { + $sectionformatoptions = $this->get_format_options($section); + if ($sectionformatoptions['sectionhideingrid'] == 2) { // Yes. + // Don't show. + return false; + } } return parent::is_section_visible($section); }