@@ -122,7 +122,14 @@ public function export_for_template(\renderer_base $output) {
122122
123123 // If the tabsectionbackground is not defined in the section check the parent section.
124124 if ($ currentsection != $ activetab ->section ) {
125- $ formatoptionssub = course_get_format ($ course )->get_format_options ($ currentsection );
125+ $ activesubtab = $ activetab ->get_childs ()->get_active ();
126+
127+ if ($ activesubtab ) {
128+ $ formatoptionssub = course_get_format ($ course )->get_format_options ($ activesubtab ->section );
129+ } else {
130+ $ formatoptionssub = course_get_format ($ course )->get_format_options ($ currentsection );
131+ }
132+
126133 $ subtabsectionbackground = $ formatoptionssub ['tabsectionbackground ' ] ?? '' ;
127134
128135 if (!empty ($ subtabsectionbackground )) {
@@ -243,6 +250,23 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
243250 // Can we view the section in question?
244251 if ((!$ thissection ->uservisible && $ course ->hiddensections == 1 ) || !empty ($ thissection ->component )) {
245252 $ localsection ++;
253+
254+ if (!empty ($ thissection ->component ) && $ thissection ->section == $ displaysection ) {
255+ $ subsectioncm = \mod_subsection \manager::create_from_id ($ course ->id , $ thissection ->itemid );
256+ $ cm = $ subsectioncm ->get_coursemodule ();
257+
258+ // Find the tab.
259+ $ childtab = $ tabs ->get_childbysection ($ cm ->sectionnum );
260+ if ($ childtab ) {
261+ $ childtab ->selected = true ;
262+ $ childtab ->cssstyles = 'color: red; ' ;
263+
264+ if ($ childtab ->parenttab ) {
265+ $ childtab ->parenttab ->selected = true ;
266+ }
267+ }
268+ }
269+
246270 continue ;
247271 }
248272
@@ -483,11 +507,11 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
483507 $ insertposition = $ displaysection + 1 ;
484508
485509 $ paramstotabs = [
486- 'courseid ' => $ course ->id ,
487- 'increase ' => true ,
488- 'sesskey ' => sesskey (),
489- 'insertsection ' => $ insertposition ,
490- ];
510+ 'courseid ' => $ course ->id ,
511+ 'increase ' => true ,
512+ 'sesskey ' => sesskey (),
513+ 'insertsection ' => $ insertposition ,
514+ ];
491515
492516 // Define if subtabs are displayed (a subtab is selected or the selected tab has subtabs).
493517 $ selectedsubtabs = $ selectedparent ? $ tabs ->get_tab ($ selectedparent ->index ) : null ;
0 commit comments