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_404
    • mdl-83307_405
    • mdl-83307_main
    • Hide

      You might need to use Firefox.  I don't know if JavaScript can be disabled in Chrome?

      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. Create a new Custom sections format course with 1 section (besides the General section).
      3. Add a new subsection to the section (Moodle 4.5 and main only).
      4. 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.)
      5. Reload the page.
      6. Choose the View option for the section.
      7. Hide the section.
      8. Verify there is no anchor in the URL (fails before the change).
      9. Unhide the section
      10. Highlight the section.
      11. Verify there is no anchor in the URL (fails before the change).

       

      (Moodle 4.5 and main only)

      1. Choose the View option for the subsection.
      2. Hide the subsection.
      3. Verify the subsection page is still shown (fails before the change).

      Re-enable JavaScript in the browser.

      Show
      You might need to use Firefox.  I don't know if JavaScript can be disabled in Chrome? 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) Create a new Custom sections format course with 1 section (besides the General section). Add a new subsection to the section (Moodle 4.5 and main only). 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.) 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). Unhide the section Highlight the section. Verify there is no anchor in the URL (fails before the change).   (Moodle 4.5 and main only) Choose the View option for the subsection. Hide the subsection. Verify the subsection page is still shown (fails before the change). 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 10 Dec 2024 10:23:12 PM UTC

      Show
      Code verified against automated checks. Checked MDL-83307 using repository: https://github.com/james-cnz/moodle MOODLE_404_STABLE (0 errors / 0 warnings) [branch: mdl-83307_404 | CI Job ] MOODLE_405_STABLE (0 errors / 0 warnings) [branch: mdl-83307_405 | CI Job ] main (0 errors / 0 warnings) [branch: mdl-83307_main | CI Job ] More information about this report Built on: Tue 10 Dec 2024 10:23:12 PM UTC

      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 (4.5 and main only)

       

      -       $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

       

       

      mod/lti/locallib.php

       

      - function lti_get_configured_types($courseid, $sectionreturn = 0) {
      + function lti_get_configured_types($courseid, $sectionreturn = null) {

      A section return of 0 now actually displays the section 0 page, instead of the course main page.

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

              Created:
              Updated:

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