Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
32 changes: 32 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Loading