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

Section return issues

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.4.4, 4.5, 5.0
    • Course
    • MOODLE_404_STABLE, MOODLE_405_STABLE, MOODLE_500_STABLE
    • mdl-83307_405
    • mdl-83307_500
    • mdl-83307_main
    • Hide
      1. Comment out the course/format/topics/lib.php function get_view_url() (so anchors are generated–since anchors aren't generated now in the Custom sections format, many of these fixes wouldn't show there, but would show in course format plugins that still generate anchors)
      2. Under Site admin > Plugins > Activity modules > Manage activities, ensure Subsection is enabled (Moodle 4.5).
      3. Create a new Custom sections format course with 1 section (besides the General section).
      4. Add a new subsection to the section.
      5. Disable JavaScript in the browser.  (In Firefox: Open a new tab, enter about:config in the URL bar, click Accept, type javascript in the search bar, and click the toggle button next to javascript.enabled.  In Chrome for Windows: F12 to open the dev console, Ctrl + Shift + P to open the command tool, type 'disable javascript' and hit Enter.)
      6. Reload the page.
      7. Choose the View option for the section.
      8. Hide the section.
      9. Verify there is no anchor in the URL (fails before the change in Moodle 4.5).
      10. Unhide the section
      11. Highlight the section.
      12. Verify there is no anchor in the URL (fails before the change in Moodle 4.5).
      13. Choose the View option for the subsection.
      14. Hide the subsection.
      15. Verify you remain on the subsection page (fails before the change in Moodle 4.5).

      Re-enable JavaScript in the browser.

      Show
      Comment out the course/format/topics/lib.php function get_view_url() (so anchors are generated–since anchors aren't generated now in the Custom sections format, many of these fixes wouldn't show there, but would show in course format plugins that still generate anchors) Under Site admin > Plugins > Activity modules > Manage activities, ensure Subsection is enabled (Moodle 4.5). Create a new Custom sections format course with 1 section (besides the General section). Add a new subsection to the section. Disable JavaScript in the browser.  (In Firefox: Open a new tab, enter about:config in the URL bar, click Accept, type javascript in the search bar, and click the toggle button next to javascript.enabled.  In Chrome for Windows: F12 to open the dev console, Ctrl + Shift + P to open the command tool, type 'disable javascript' and hit Enter.) Reload the page. Choose the View option for the section. Hide the section. Verify there is no anchor in the URL (fails before the change in Moodle 4.5). Unhide the section Highlight the section. Verify there is no anchor in the URL (fails before the change in Moodle 4.5). Choose the View option for the subsection. Hide the subsection. Verify you remain on the subsection page (fails before the change in Moodle 4.5). Re-enable JavaScript in the browser.
    • Hide

      Code verified against automated checks.

      Checked MDL-83307 using repository: https://github.com/james-cnz/moodle

      More information about this report

      Built on: Tue May 27 04:18:34 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-83307 using repository: https://github.com/james-cnz/moodle MOODLE_405_STABLE (0 errors / 0 warnings) [branch: mdl-83307_405 | CI Job ] MOODLE_500_STABLE (0 errors / 0 warnings) [branch: mdl-83307_500 | CI Job ] main (0 errors / 0 warnings) [branch: mdl-83307_main | CI Job ] More information about this report Built on: Tue May 27 04:18:34 UTC 2025

      Fixes for some section return issues, which I noticed while working on MDL-83224.

       

       

      Explanation of the fixes:

       

      course/format/classes/output/local/content/cm/delegatedcontrolmenu.php

       

      -       $baseurl = course_get_url($course, $sectionreturn);
      +       $baseurl = course_get_url($course);
      +       if (!is_null($sectionreturn)) {
      +           $baseurl->param('sectionid', $format->get_sectionid());

      Old behaviour was for course_get_url to put the passed section number in a section URL parameter.  view.php uses that section number as the return section (except in options that appropriate it for another purpose).  New behaviour is to put the put the passed section into a URL anchor, which is no use.  We instead need to put the section number in a section URL parameter, or the section ID in a sectionid parameter manually.  Using the section number is prone to error if sections are reordered, so section ID is better.

       

      -           if (!is_null($sectionreturn)) {
      -               $url->param('sr', $format->get_sectionid());

      The view.php code doesn't use an sr parameter.  As above, it uses the section or sectionid parameters for this purpose instead sometimes.  And it's now set.

       

      course/format/classes/output/local/content/section/controlmenu.php

       

      -       $baseurl = course_get_url($course, $sectionreturn);
      +       $baseurl = course_get_url($course);
      +       if (!is_null($sectionreturn)) {
      +           $baseurl->param('sectionid', $format->get_sectionid());

      Same reason as in delegatedcontrolmenu.php .

       

      -           if (!is_null($sectionreturn)) {
      -               $url->param('sectionid', $format->get_sectionid());

      We don't need to do this for specific options, because it's now in the base URL.

       

      -                       $url->param('section', $section->section);
      +                       $url->param('sectionid', $section->id);

      (Three places.)  Using the section number is prone to error if sections are reordered.  And since I've used section ID above, we need to override that anyway, because it takes precedence.

       

      course/format/topics/classes/output/courseformat/content/section/controlmenu.php

       

      -       if ($sectionreturn) {
      -           $url = course_get_url($course, $section->section);
      -       } else {
      -           $url = course_get_url($course);
      +       $url = course_get_url($course);
      +       if (!is_null($sectionreturn)) {
      +           $url->param('sectionid', $format->get_sectionid());

      Same reason as delegatedcontrolmenu.php

            james-cnz James E. Calder
            james-cnz James E. Calder
            Jayce Birrell Jayce Birrell
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 18 minutes
                2h 18m

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