Skip to content

Commit

Permalink
V404.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Sep 22, 2024
1 parent 9c41ffe commit f382d76
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 32 deletions.
8 changes: 8 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Version Information
===================

Version 404.1.1 - 22/09/2024
----------------------------
1. Show section zero if the section has meaningful content.
2. Fix single section page navigation.
3. Compromise with the Course Index that it will always refer to the main course page and the format
implement its own single page access and navigation.
4. Fix single section page navigation visibility.

Version 404.1.0 - 01/07/2024
----------------------------
1. Fix 'Error with Orphaned Sections when editing' - #151.
Expand Down
10 changes: 5 additions & 5 deletions classes/output/courseformat/content/sectionnavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,26 @@ public function export_for_template(\renderer_base $output): \stdClass {

$back = $this->sectionno - 1;
while ($back > 0 && empty($data->previousurl)) {
if ($canviewhidden || $sections[$back]->uservisible) {
if ($canviewhidden || $format->is_section_visible($back)) {
if (!$sections[$back]->visible) {
$data->previoushidden = true;
}
$data->previousname = get_section_name($course, $sections[$back]);
$data->previousurl = course_get_url($course, $back, ['navigation' => true]);
$data->previousurl = $format->get_view_url($back, ['navigation' => false]);
$data->hasprevious = true;
}
$back--;
}

$forward = $this->sectionno + 1;
$numsections = course_get_format($course)->get_last_section_number();
$numsections = $format->get_last_section_number();
while ($forward <= $numsections && empty($data->nexturl)) {
if ($canviewhidden || $sections[$forward]->uservisible) {
if ($canviewhidden || $format->is_section_visible($forward)) {
if (!$sections[$forward]->visible) {
$data->nexthidden = true;
}
$data->nextname = get_section_name($course, $sections[$forward]);
$data->nexturl = course_get_url($course, $forward, ['navigation' => true]);
$data->nexturl = $format->get_view_url($forward, ['navigation' => false]);
$data->hasnext = true;
}
$forward++;
Expand Down
9 changes: 6 additions & 3 deletions classes/output/courseformat/content/sectionselector.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ public function export_for_template(\renderer_base $output): \stdClass {
$numsections = $format->get_last_section_number();
while ($section <= $numsections) {
$thissection = $modinfo->get_section_info($section);
$url = course_get_url($course, $section, ['navigation' => true]);
if ($thissection->uservisible && $url && $section != $data->currentsection) {
$sectionmenu[$url->out(false)] = get_section_name($course, $section);
$url = $format->get_view_url($section, ['navigation' => false]);
if ($url && $section != $data->currentsection) {
if ($format->is_section_visible($thissection)) {
$sectionmenu[$url->out(false)] = get_section_name($course, $section);
}
}
$section++;
}
Expand All @@ -76,6 +78,7 @@ public function export_for_template(\renderer_base $output): \stdClass {
$select->formid = 'sectionmenu';

$data->selector = $output->render($select);

return $data;
}
}
45 changes: 23 additions & 22 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 Expand Up @@ -417,11 +420,9 @@ public function get_view_url($section, $options = []) {
$sectionno = $section;
}
if ((!empty($options['navigation'])) && $sectionno !== null) {
// Display section on separate page.
$sectioninfo = $this->get_section($sectionno);
return new moodle_url('/course/section.php', ['id' => $sectioninfo->id]);
}
if ($this->uses_sections() && $sectionno !== null) {
// Unlike core, navigate to section on course page.
$url->set_anchor('section-'.$sectionno);
} else if ($this->uses_sections() && $sectionno !== null) {
if ($this->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
$url->param('section', $sectionno);
} else {
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
*/
defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024032802;
$plugin->version = 2024032803;
$plugin->maturity = MATURITY_STABLE;
$plugin->requires = 2024042200.00; // 4.4 (Build: 20240422).
$plugin->supported = [404, 404];
$plugin->component = 'format_topcoll';
$plugin->release = '404.1.0';
$plugin->release = '404.1.1';

0 comments on commit f382d76

Please sign in to comment.