Skip to content

Commit

Permalink
Show section zero if the section has meaningful content.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Jul 25, 2024
1 parent ff1d9ca commit 26b58b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------
Expand Down
37 changes: 20 additions & 17 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 26b58b2

Please sign in to comment.