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

Fix redirect to course/section in paged mode

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide
      1. Edit a course and set it to 'one section per page'
      2. Enable editing mode on the index page of the section
      3. Add a resource and an activity
      4. Make sure that if you cancel, you're redirected back where you were.
      5. Make sure that if you 'Save and return to course', you're redirected back where you were.
      6. Go to a section page, and repeat steps 3, 4, 5
      Show
      Edit a course and set it to 'one section per page' Enable editing mode on the index page of the section Add a resource and an activity Make sure that if you cancel, you're redirected back where you were. Make sure that if you 'Save and return to course', you're redirected back where you were. Go to a section page, and repeat steps 3, 4, 5
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-33775-master-integration

      Description

      When in paged mode, viewing the index page with editing on:

      • Adding a resource/activity does not redirect to course main page, but section
      • Same behaviour when cancelling cancel
      • Same behaviour when editing an existing resource/activity

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              phalacee Jason Fowler added a comment -

              looks good Fred

              Show
              phalacee Jason Fowler added a comment - looks good Fred
              Hide
              poltawski Dan Poltawski added a comment -

              If it was me, I wouldn't have added $sectionreturnlink as it makes the diff more obvious, but thats very trivial

              Show
              poltawski Dan Poltawski added a comment - If it was me, I wouldn't have added $sectionreturnlink as it makes the diff more obvious, but thats very trivial
              Hide
              poltawski Dan Poltawski added a comment -

              Sorry fred, but it doesn't seem to be working on single section page mode.

              Url is:
              http://dan.moodle.local/integration/course/modedit.php?add=lesson&type=&course=4&section=3&return=0&sr=0

              Show
              poltawski Dan Poltawski added a comment - Sorry fred, but it doesn't seem to be working on single section page mode. Url is: http://dan.moodle.local/integration/course/modedit.php?add=lesson&type=&course=4&section=3&return=0&sr=0
              Hide
              fred Frédéric Massart added a comment -

              Did you try to add in the default section? If yes, it is a know issue linked to MDL-33767.
              The default section always gets 0 as the section return.

              Show
              fred Frédéric Massart added a comment - Did you try to add in the default section? If yes, it is a know issue linked to MDL-33767 . The default section always gets 0 as the section return.
              Hide
              poltawski Dan Poltawski added a comment -

              No, that was section 3 (see url)

              Show
              poltawski Dan Poltawski added a comment - No, that was section 3 (see url)
              Hide
              fred Frédéric Massart added a comment -

              Fixed and updated. Submitting for integration straight away, and to facilitate integrator's lifes, this was the diff introduced.

              diff --git a/course/lib.php b/course/lib.php
              index c6ea7db..75bba78 100644
              --- a/course/lib.php
              +++ b/course/lib.php
              @@ -1887,10 +1887,11 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
                * @param object $course The Course
                * @param array $modnames An array containing the list of modules and their
                * names
              + * @param int $sectionreturn The section to return to
                * @return array A list of stdClass objects containing metadata about each
                * module
                */
              -function get_module_metadata($course, $modnames) {
              +function get_module_metadata($course, $modnames, $sectionreturn = 0) {
                   global $CFG, $OUTPUT;
               
                   // get_module_metadata will be called once per section on the page and courses may show
              @@ -1901,7 +1902,7 @@ function get_module_metadata($course, $modnames) {
                   }
               
                   $return = array();
              -    $urlbase = "/course/mod.php?id=$course->id&sesskey=".sesskey().'&add=';
              +    $urlbase = "/course/mod.php?id=$course->id&sesskey=".sesskey().'&sr='.$sectionreturn.'&add=';
                   foreach($modnames as $modname => $modnamestr) {
                       if (!course_allowed_module($course, $modname)) {
                           continue;
              diff --git a/course/view.php b/course/view.php
              index e0f295b..e4a18cd 100644
              --- a/course/view.php
              +++ b/course/view.php
              @@ -270,7 +270,7 @@
                   if (include_course_ajax($course, $modnamesused)) {
                       // Add the module chooser
                       $renderer = $PAGE->get_renderer('core', 'course');
              -        echo $renderer->course_modchooser(get_module_metadata($course, $modnames), $course);
              +        echo $renderer->course_modchooser(get_module_metadata($course, $modnames, $displaysection), $course);
                   }
               
                   echo $OUTPUT->footer();

              Show
              fred Frédéric Massart added a comment - Fixed and updated. Submitting for integration straight away, and to facilitate integrator's lifes, this was the diff introduced. diff --git a/course/lib.php b/course/lib.php index c6ea7db..75bba78 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1887,10 +1887,11 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false, * @param object $course The Course * @param array $modnames An array containing the list of modules and their * names + * @param int $sectionreturn The section to return to * @return array A list of stdClass objects containing metadata about each * module */ -function get_module_metadata($course, $modnames) { +function get_module_metadata($course, $modnames, $sectionreturn = 0) { global $CFG, $OUTPUT; // get_module_metadata will be called once per section on the page and courses may show @@ -1901,7 +1902,7 @@ function get_module_metadata($course, $modnames) { } $return = array(); - $urlbase = "/course/mod.php?id=$course->id&sesskey=".sesskey().'&add='; + $urlbase = "/course/mod.php?id=$course->id&sesskey=".sesskey().'&sr='.$sectionreturn.'&add='; foreach($modnames as $modname => $modnamestr) { if (!course_allowed_module($course, $modname)) { continue; diff --git a/course/view.php b/course/view.php index e0f295b..e4a18cd 100644 --- a/course/view.php +++ b/course/view.php @@ -270,7 +270,7 @@ if (include_course_ajax($course, $modnamesused)) { // Add the module chooser $renderer = $PAGE->get_renderer('core', 'course'); - echo $renderer->course_modchooser(get_module_metadata($course, $modnames), $course); + echo $renderer->course_modchooser(get_module_metadata($course, $modnames, $displaysection), $course); } echo $OUTPUT->footer();
              Hide
              poltawski Dan Poltawski added a comment -

              Thanks Fred, integrated now.

              Show
              poltawski Dan Poltawski added a comment - Thanks Fred, integrated now.
              Hide
              poltawski Dan Poltawski added a comment -

              Tested and passed!

              Show
              poltawski Dan Poltawski added a comment - Tested and passed!
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              And this has been spread to every git and cvs repository out there, just in time to roll Moodle 2.3beta!

              Thanks! Closing, ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - And this has been spread to every git and cvs repository out there, just in time to roll Moodle 2.3beta! Thanks! Closing, ciao

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    25/Jun/12