Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-83107

$PAGE->set_secondary_active_tab is unreliable

XMLWordPrintable

      Description

      To replicate:

      1. Create a single activity format course (any activity is fine)
      2. Click "Course" > "Content bank"
      3. Click "Course" again
      4. Observe there is no tick next to "Content bank"

      Analysis

      MDL-72396 added the ability to set a secondary active tab. The content bank makes use of this feature.

      Firstly, contentbank/index.php calls a helper function, core_contentbank::get_page_ready which sets the active tab to contentbank. This is a bit odd because the correct nodes should automatically activate without the need to use $PAGE->set_secondary_active_tab. However index.php then sets the active url to be course/index.php and that is not the current page URL, so the node would never activate - perhaps this is why get_page_ready sets the tab. But then mysteriously, index.php also sets the secondary active tab to "contentbank".

      Despite all this, in a single activity format course, the node never gets activated because there is code in core's secondary navigation view implementation which forces the active tab, overwriting what the contentbank previously did. See:

      It's not clear why secondary navigation would do this for a single activity course, as there is existing code that exists to properly reactive the nodes associated with the tabs (as per the requirements laid out in the "Navigation overhaul" section of the parent epic) . By setting the active tab in the secondary navigation view class, it makes it impossible to any other code to change the active tab (not just the content bank), rendering $PAGE->set_secondary_active_tab useless when in a single activity format course.

      The only explanation I can think of for forcing the tabs to be active, is that there may exist "orphaned" pages that are somehow not in secondary navigation, yet still lead to the course? And in this case the correct tab wouldn't activate? I've not found any evidence to support that hypothesis though.

            Unassigned Unassigned
            cameron1729 cameron1729
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.