diff --git a/Changes.md b/Changes.md index 3c05e28..679c3f5 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,11 @@ Version Information =================== +Version 4.5.0.3 +----------------------------- +1. Section 0 (General) is now automatically hidden when it has no summary content and no visible modules. + Based on the approach used by format_topcoll (Collapsed Topics). See LS-3490. + Version 4.5.0.2 ----------------------------- 1. Sub-section support. diff --git a/Readme.md b/Readme.md index 82d13c0..b524988 100644 --- a/Readme.md +++ b/Readme.md @@ -40,6 +40,8 @@ Notes section (section 0), as to prevent accidental deletion of the 'news' forum upon which the format relies. If it is deleted, then a page refresh will recreate the forum but all previous posts will be lost. 2. Any title and summary that has been previously set for the general section will not be shown. +3. Section 0 (General) is automatically hidden when it has no summary content and no visible modules. + This is consistent with the approach used by format_topcoll (Collapsed Topics). Additional classes Section name = 'vsf-sectionname'. diff --git a/lib.php b/lib.php index c3ca51b..a464235 100644 --- a/lib.php +++ b/lib.php @@ -215,6 +215,38 @@ public function extend_course_navigation($navigation, navigation_node $node) { } } + /** + * Determines whether a section is visible. + * + * Section 0 is hidden when it has no summary content and no visible modules, + * consistent with the approach used by format_topcoll. + * + * @param \section_info $section The section to check. + * @return bool True if the section should be displayed. + */ + public function is_section_visible(\section_info $section): bool { + $shown = parent::is_section_visible($section); + if ($shown && $section->sectionnum == 0) { + // Show section 0 only if summary has content (text or images). + if (empty(strip_tags($section->summary, ['img']))) { + // No summary — check if there are visible modules. + $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()) { + $modshown = true; + break; + } + } + } + $shown = $modshown; + } + } + return $shown; + } + /** * Custom action after section has been moved in AJAX mode * diff --git a/version.php b/version.php index b81595d..79ec22a 100644 --- a/version.php +++ b/version.php @@ -25,9 +25,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 202501150100; +$plugin->version = 202604130100; $plugin->maturity = MATURITY_BETA; $plugin->requires = 2024100700.00; // 4.5 (Build: 20241007). phpcs:ignore Squiz.PHP.CommentedOutCode.Found $plugin->supported = [405, 405]; $plugin->component = 'format_vsf'; -$plugin->release = '4.5.0.2'; +$plugin->release = '4.5.0.3';