Skip to content

Commit 528864b

Browse files
committed
Fix subsection navigation nodes (MDL-82845) WIP 5
1 parent 3c5b060 commit 528864b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

classes/global_navigation_wrapper.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
193193
|| (
194194
!$this->innershowemptysections
195195
&& !$section->hasactivites && !$sectionextra->hassubsections
196-
&& ($this->innerincludesectionid !== $section->id)
196+
&& ($this->inner->includesectionnum != $section->section)
197+
&& ($this->innerincludesectionid != $section->id)
197198
)
198199
) {
199200
// CHANGED ABOVE: Use sanitised visibility, check for subsections, and use section ID.
@@ -239,8 +240,9 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
239240
}
240241

241242
if (
242-
isset($this->innerincludesectionid) && ($this->innerincludesectionid == $section->id)
243-
|| $sectionextra->hassubsections // TODO: Replace with is_section_in_breadcrumbs?
243+
($this->inner->includesectionnum == $section->section)
244+
|| ($this->innerincludesectionid == $section->id) // TODO: Replace with is_section_in_breadcrumbs?
245+
|| $sectionextra->hassubsections
244246
// CHANGED ABOVE: Use section ID.
245247
// Also check for subsections, because activities might not get loaded otherwise.
246248
) {
@@ -260,7 +262,7 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
260262
*
261263
* @param navigation_node $sectionnode
262264
* @param section_info $section
263-
* @param stdClass[] $activitiesdata An array of activites as returned by see global_navigation::generate_sections_and_activities()
265+
* @param stdClass[] $activitiesdata Array of objects containing activities data indexed by cmid.
264266
* @return stdClass[] Array of activity nodes
265267
*/
266268
protected function load_section_activities_navigation(

lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,12 @@ public function extend_course_navigation($navigation, navigation_node $node) {
858858
$navigationwrapper = new \format_multitopic\global_navigation_wrapper($navigation, $PAGE); // ADDED.
859859

860860
// If section is specified in course/view.php, make sure it is expanded in navigation.
861-
if ($navigationwrapper->innerincludesectionid === null) {
861+
if ($navigation->includesectionnum === false) {
862862
// CHANGED.
863863
$selectedsectionid = optional_param('sectionid', null, PARAM_INT);
864864
if (
865865
($selectedsectionid !== null) && (!defined('AJAX_SCRIPT') || (AJAX_SCRIPT == '0'))
866-
&& $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)
866+
&& ($PAGE->context->contextlevel == CONTEXT_COURSE)
867867
) {
868868
$navigationwrapper->innerincludesectionid = $selectedsectionid;
869869
}

0 commit comments

Comments
 (0)