MDL-40600 core_courseformat: duplicate a named section with copy

When a named section is duplicated, the name must have a (copy) particle
to make visible what section is the original and what is the copy.
This commit is contained in:
Ferran Recio 2023-02-01 11:03:58 +01:00 committed by Alex Morris
parent f1c4cc73df
commit 01d6ba02a3
No known key found for this signature in database
GPG key ID: 0501031386C92557
4 changed files with 18 additions and 2 deletions

View file

@ -1752,7 +1752,11 @@ abstract class base {
$oldsectioninfo = get_fast_modinfo($course)->get_section_info($originalsection->section); $oldsectioninfo = get_fast_modinfo($course)->get_section_info($originalsection->section);
$newsection = course_create_section($course, $oldsectioninfo->section + 1); // Place new section after existing one. $newsection = course_create_section($course, $oldsectioninfo->section + 1); // Place new section after existing one.
$newsection->name = $originalsection->name; if (!empty($originalsection->name)) {
$newsection->name = get_string('duplicatedsection', 'moodle', $originalsection->name);
} else {
$newsection->name = $originalsection->name;
}
$newsection->summary = $originalsection->summary; $newsection->summary = $originalsection->summary;
$newsection->summaryformat = $originalsection->summaryformat; $newsection->summaryformat = $originalsection->summaryformat;
$newsection->visible = $originalsection->visible; $newsection->visible = $originalsection->visible;

View file

@ -22,5 +22,13 @@ Feature: Duplicate a section
@javascript @javascript
Scenario: Duplicate section Scenario: Duplicate section
Given I open section "1" edit menu Given I open section "1" edit menu
And I click on "Duplicate" "link" in the "Topic 1" "section" When I click on "Duplicate" "link" in the "Topic 1" "section"
Then I should see "Activity sample 2" in the "Topic 2" "section" Then I should see "Activity sample 2" in the "Topic 2" "section"
@javascript
Scenario: Duplicate a named section
Given I set the field "Edit topic name" in the "Topic 1" "section" to "New name"
And I should see "New name" in the "New name" "section"
When I open section "1" edit menu
And I click on "Duplicate" "link" in the "New name" "section"
Then I should see "Activity sample 2" in the "New name (copy)" "section"

View file

@ -4,6 +4,9 @@ information provided here is intended especially for developers.
=== 4.2 === === 4.2 ===
* course/mod.php now accepts parameter beforemod for adding course modules. It contains the course module id * course/mod.php now accepts parameter beforemod for adding course modules. It contains the course module id
of an existing course module. The new module is inserted before this module. of an existing course module. The new module is inserted before this module.
* The function duplicate_module() now has two new optional parameters:
- $sectionid to specify section the duplicated course module is placed in
- $changename to disable changing the name of the course module using the 'duplicatedmodule' lang string
=== 4.1 === === 4.1 ===
* The function course_modchooser() has been finally deprecated and can not be used anymore. Please use * The function course_modchooser() has been finally deprecated and can not be used anymore. Please use

View file

@ -583,6 +583,7 @@ $string['doyouagree'] = 'Have you read these conditions and understood them?';
$string['droptoupload'] = 'Drop files here to upload'; $string['droptoupload'] = 'Drop files here to upload';
$string['duplicate'] = 'Duplicate'; $string['duplicate'] = 'Duplicate';
$string['duplicatedmodule'] = '{$a} (copy)'; $string['duplicatedmodule'] = '{$a} (copy)';
$string['duplicatedsection'] = '{$a} (copy)';
$string['edhelpaspellpath'] = 'To use spell-checking within the editor, you MUST have <strong>aspell 0.50</strong> or later installed on your server, and you must specify the correct path to access the aspell binary. On Unix/Linux systems, this path is usually <strong>/usr/bin/aspell</strong>, but it might be something else.'; $string['edhelpaspellpath'] = 'To use spell-checking within the editor, you MUST have <strong>aspell 0.50</strong> or later installed on your server, and you must specify the correct path to access the aspell binary. On Unix/Linux systems, this path is usually <strong>/usr/bin/aspell</strong>, but it might be something else.';
$string['edhelpbgcolor'] = 'Define the edit area\'s background color.<br />Valid values are, for example: #FFFFFF or white'; $string['edhelpbgcolor'] = 'Define the edit area\'s background color.<br />Valid values are, for example: #FFFFFF or white';
$string['edhelpcleanword'] = 'This setting enables or disables Word-specific format filtering.'; $string['edhelpcleanword'] = 'This setting enables or disables Word-specific format filtering.';