Merge branch 'MDL-69065-master' of git://github.com/peterRd/moodle
authorJake Dallimore <jake@moodle.com>
Wed, 24 Jun 2020 01:30:31 +0000 (09:30 +0800)
committerJake Dallimore <jake@moodle.com>
Wed, 24 Jun 2020 02:11:08 +0000 (10:11 +0800)
course/amd/build/activitychooser.min.js
course/amd/build/activitychooser.min.js.map
course/amd/src/activitychooser.js
course/format/renderer.php
course/renderer.php
course/tests/behat/paged_course_navigation.feature

index 27aebcf..b49f3dc 100644 (file)
Binary files a/course/amd/build/activitychooser.min.js and b/course/amd/build/activitychooser.min.js differ
index 055d5ac..a409f76 100644 (file)
Binary files a/course/amd/build/activitychooser.min.js.map and b/course/amd/build/activitychooser.min.js.map differ
index 176ed99..5de0576 100644 (file)
@@ -136,7 +136,7 @@ const registerListenerEvents = (courseId, chooserConfig) => {
                 const data = await fetchModuleData();
 
                 // Apply the section id to all the module instance links.
-                const builtModuleData = sectionIdMapper(data, caller.dataset.sectionid);
+                const builtModuleData = sectionIdMapper(data, caller.dataset.sectionid, caller.dataset.sectionreturnid);
 
                 ChooserDialogue.displayChooser(
                     sectionModal,
@@ -161,13 +161,14 @@ const registerListenerEvents = (courseId, chooserConfig) => {
  * @method sectionIdMapper
  * @param {Object} webServiceData Our original data from the Web service call
  * @param {Number} id The ID of the section we need to append to the links
+ * @param {Number|null} sectionreturnid The ID of the section return we need to append to the links
  * @return {Array} [modules] with URL's built
  */
-const sectionIdMapper = (webServiceData, id) => {
+const sectionIdMapper = (webServiceData, id, sectionreturnid) => {
     // We need to take a fresh deep copy of the original data as an object is a reference type.
     const newData = JSON.parse(JSON.stringify(webServiceData));
     newData.content_items.forEach((module) => {
-        module.link += '&section=' + id;
+        module.link += '&section=' + id + '&sr=' + (sectionreturnid ?? 0);
     });
     return newData.content_items;
 };
index 6fbe141..b5884c3 100644 (file)
@@ -203,7 +203,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
             'class' => 'section main clearfix'.$sectionstyle,
             'role' => 'region',
             'aria-labelledby' => "sectionid-{$section->id}-title",
-            'data-sectionid' => $section->section
+            'data-sectionid' => $section->section,
+            'data-sectionreturnid' => $sectionreturn
         ]);
 
         $leftcontent = $this->section_left_content($section, $course, $onsectionpage);
index bb7b3b9..da82415 100644 (file)
@@ -376,6 +376,7 @@ class core_course_renderer extends plugin_renderer_base {
                     'class' => 'section-modchooser-link btn btn-link',
                     'data-action' => 'open-chooser',
                     'data-sectionid' => $section,
+                    'data-sectionreturnid' => $sectionreturn,
                 ]
             );
             $ajaxcontrol .= html_writer::end_tag('div');
index 92fd475..04b7b15 100644 (file)
@@ -38,6 +38,29 @@ Feature: Course paged mode
       | topics | "Topic 1" | "Topic 2" | "Topic 3" | "Topic 0" | "Topic 4" |
       | weeks | "1 January - 7 January" | "8 January - 14 January" | "15 January - 21 January" | "25 December - 31 December" | "22 January - 28 January" |
 
+  @javascript
+  Scenario Outline: Paged section redirect after creating an activity
+    Given the following "courses" exist:
+      | fullname | shortname | category | format | coursedisplay | numsections | startdate |
+      | Course 1 | C1        | 0        | <courseformat> | 1     | 3           | 0         |
+    And I log in as "admin"
+    And I am on "Course 1" course homepage with editing mode on
+    And I click on <section1> "link" in the <section1> "section"
+    And I should see <section1> in the "div.single-section" "css_element"
+    And I should see <section2> in the ".single-section span.mdl-right" "css_element"
+    And I should not see <prevunexistingsection> in the ".single-section" "css_element"
+    When I add a "Chat" to section "1" and I fill the form with:
+      | Name of this chat room | Chat room |
+      | Description | Chat description |
+    Then I should see <section1> in the "div.single-section" "css_element"
+    And I should see <section2> in the ".single-section span.mdl-right" "css_element"
+    And I should not see <prevunexistingsection> in the ".single-section" "css_element"
+
+    Examples:
+      | courseformat | section1 | section2 | prevunexistingsection |
+      | topics       | "Topic 1" | "Topic 2" | "Topic 0"          |
+      | weeks        | "1 January - 7 January" | "8 January - 14 January" | "25 December - 31 December" |
+
   Scenario Outline: Weekly and topics course formats with Javascript disabled
     Given the following "courses" exist:
       | fullname | shortname | category | format | coursedisplay | numsections | startdate |