@@ -111,7 +111,7 @@ protected function generate_sections_and_activities(\stdClass $course): array {
111111 }
112112 foreach ($ modinfo ->sections [$ section ->section ] as $ cmid ) {
113113 $ cm = $ modinfo ->cms [$ cmid ];
114- $ activity = new \stdClass ;
114+ $ activity = new \stdClass () ;
115115 $ activity ->id = $ cm ->id ;
116116 $ activity ->course = $ course ->id ;
117117 $ activity ->sectionid = $ section ->id ; // CHANGED: Use section ID instead of number.
@@ -154,15 +154,18 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node
154154 global $ CFG , $ SITE ; // CHANGED: Removed $DB and $USER.
155155 require_once ($ CFG ->dirroot . '/course/lib.php ' );
156156
157- list ( $ sections , $ activities) = $ this ->generate_sections_and_activities ($ course );
157+ [ $ sections , $ activities] = $ this ->generate_sections_and_activities ($ course );
158158
159159 $ navigationsections = [];
160160 // ADDED.
161161 // Navigation node at level n.
162162 // This is a list of the navigation nodes currently at each level,
163163 // from the node for the course, down to the node we're currently working on.
164- $ nodeln = array_fill (FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT ,
165- FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC - FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT + 1 , $ coursenode );
164+ $ nodeln = array_fill (
165+ FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT ,
166+ FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC - FORMAT_MULTITOPIC_SECTION_LEVEL_ROOT + 1 ,
167+ $ coursenode
168+ );
166169 // The navigation node we're currently working on.
167170 $ sectionnode = $ coursenode ;
168171 // Extra navigation node ID counter.
@@ -172,7 +175,6 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node
172175 $ extraid = -1 ;
173176 // END ADDED.
174177 foreach ($ sections as $ sectionid => $ section ) {
175-
176178 // Delegated sections should be added from the activity node.
177179 if (isset ($ section ->component ) && $ section ->component ) {
178180 continue ;
@@ -183,11 +185,13 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node
183185 if ($ course ->id == $ SITE ->id ) {
184186 $ this ->load_section_activities ($ coursenode , $ section , $ activities ); // CHANGED: Pass section info rather than num.
185187 } else {
186- if (!(($ section ->section == 0 ) || $ section ->uservisible && course_get_format ($ course )->is_section_visible ($ section ))
187- || (!$ this ->innershowemptysections &&
188- !$ section ->hasactivites && !$ sectionextra ->hassubsections
188+ if (
189+ !(($ section ->section == 0 ) || $ section ->uservisible && course_get_format ($ course )->is_section_visible ($ section ))
190+ || (!$ this ->innershowemptysections
191+ && !$ section ->hasactivites && !$ sectionextra ->hassubsections
189192 && $ this ->inner ->includesectionnum !== $ section ->section // TODO: Remove?
190- && $ this ->innerincludesectionid !== $ section ->id )) {
193+ && $ this ->innerincludesectionid !== $ section ->id )
194+ ) {
191195 // CHANGED ABOVE: Use sanitised visibility, check for subsections, and use section ID.
192196 continue ;
193197 }
@@ -207,10 +211,17 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node
207211 for ($ level = $ firstlevel ; $ level <= $ lastlevel ; $ level ++) {
208212 $ parentnode = $ nodeln [$ level - 1 ]; // ADDED.
209213 $ nodeid = ($ level == $ lastlevel ) ? $ sectionid : $ extraid --; // ADDED.
210- $ sectionnode = $ parentnode ->add ($ sectionname , $ url , \navigation_node::TYPE_SECTION ,
211- null , $ nodeid ,
212- new \pix_icon ($ sectionextra ->levelsan < FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC ? 'i/section '
213- : 'e/bullet_list ' , '' ));
214+ $ sectionnode = $ parentnode ->add (
215+ $ sectionname ,
216+ $ url ,
217+ \navigation_node::TYPE_SECTION ,
218+ null ,
219+ $ nodeid ,
220+ new \pix_icon (
221+ $ sectionextra ->levelsan < FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC ? 'i/section ' : 'e/bullet_list ' ,
222+ ''
223+ )
224+ );
214225 // CHANGED ABOVE: Attach to parentnode with nodeid as defined above, and use a list icon for topic sections.
215226 $ sectionnode ->nodetype = \navigation_node::NODETYPE_BRANCH ;
216227 $ sectionnode ->hidden = (!$ section ->visible || !$ section ->available ) && ($ section ->section != 0 );
@@ -223,16 +234,17 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node
223234 $ nodeln [$ level ] = $ sectionnode ;
224235 }
225236
226- if ($ this ->inner ->includesectionnum !== false && $ this ->inner ->includesectionnum == $ section ->section
227- || isset ($ this ->innerincludesectionid ) && $ this ->innerincludesectionid == $ section ->id
228- || $ sectionextra ->hassubsections ) {
237+ if (
238+ $ this ->inner ->includesectionnum !== false && $ this ->inner ->includesectionnum == $ section ->section
239+ || isset ($ this ->innerincludesectionid ) && $ this ->innerincludesectionid == $ section ->id
240+ || $ sectionextra ->hassubsections
241+ ) {
229242 // CHANGED ABOVE: Use section ID.
230243 // Also check for subsections, because activities might not get loaded otherwise.
231244 $ this ->load_section_activities ($ sectionnode , $ section , $ activities );
232245 }
233246 $ navigationsections [$ sectionid ] = $ section ;
234247 // END CHANGED.
235-
236248 }
237249 }
238250 return $ navigationsections ;
@@ -247,8 +259,12 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node
247259 * @param \stdClass|null $course The course object the section and activities relate to.
248260 * @return array Array of activity nodes
249261 */
250- protected function load_section_activities (\navigation_node $ sectionnode , \section_info $ section , array $ activities ,
251- ?\stdClass $ course = null ): array {
262+ protected function load_section_activities (
263+ \navigation_node $ sectionnode ,
264+ \section_info $ section ,
265+ array $ activities ,
266+ ?\stdClass $ course = null
267+ ): array {
252268 // CHANGED ABOVE: Use section info instead of number.
253269 global $ CFG , $ SITE ;
254270 // A static counter for JS function naming.
@@ -315,7 +331,6 @@ protected function load_section_activities(\navigation_node $sectionnode, \secti
315331 }
316332
317333 // REMOVED function load_stealth_activity - class end .
318-
319334}
320335
321336// REMOVED class global_navigation_for_ajax - end .
0 commit comments