Merge branch 'MDL-69065-master' of git://github.com/peterRd/moodle

This commit is contained in:
Jake Dallimore 2020-06-24 09:30:31 +08:00
commit c7d5af7d6e
6 changed files with 32 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View 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;
};

View 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);

View 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');

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