diff --git a/Changes.md b/Changes.md index 77eb8fd..a2d5982 100644 --- a/Changes.md +++ b/Changes.md @@ -3,6 +3,7 @@ Version 404.1.1 - Development started ---------------------------- +1. Show section zero if the section has meaningful content. Version 404.1.0 - 01/07/2024 ---------------------------- diff --git a/lib.php b/lib.php index 64725e8..3fb16e2 100644 --- a/lib.php +++ b/lib.php @@ -270,26 +270,29 @@ public function is_section_visible(section_info $section): bool { } $shown = parent::is_section_visible($section); if (($shown) && ($section->sectionnum == 0)) { - // Don't show section zero if no modules or all modules unavailable to user. - $showmovehere = ismoving($this->course->id); - if (!$showmovehere) { - global $PAGE; - $context = context_course::instance($this->course->id); - if (!($PAGE->user_is_editing() && has_capability('moodle/course:update', $context))) { - $modshown = false; - $modinfo = get_fast_modinfo($this->course); - - if (!empty($modinfo->sections[$section->section])) { - foreach ($modinfo->sections[$section->section] as $modnumber) { - $mod = $modinfo->cms[$modnumber]; - if ($mod->is_visible_on_course_page()) { - // At least one is. - $modshown = true; - break; + // Show section zero if summary has content, otherwise check modules. + if (empty(strip_tags($section->summary))) { + // Don't show section zero if no modules or all modules unavailable to user. + $showmovehere = ismoving($this->course->id); + if (!$showmovehere) { + global $PAGE; + $context = context_course::instance($this->course->id); + if (!($PAGE->user_is_editing() && has_capability('moodle/course:update', $context))) { + $modshown = false; + $modinfo = get_fast_modinfo($this->course); + + if (!empty($modinfo->sections[$section->section])) { + foreach ($modinfo->sections[$section->section] as $modnumber) { + $mod = $modinfo->cms[$modnumber]; + if ($mod->is_visible_on_course_page()) { + // At least one is. + $modshown = true; + break; + } } } + $shown = $modshown; } - $shown = $modshown; } } }