Merge branch 'MDL-84416-405' of https://github.com/sarjona/moodle into MOODLE_405_STABLE
This commit is contained in:
@@ -459,6 +459,12 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock(
|
||||
'backup/backup_import_badges',
|
||||
new lang_string('generalbadges', 'backup'),
|
||||
new lang_string('configgeneralbadges', 'backup'),
|
||||
['value' => 0, 'locked' => 0],
|
||||
));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_calendarevents', new lang_string('generalcalendarevents','backup'), new lang_string('configgeneralcalendarevents','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_groups',
|
||||
|
||||
@@ -585,6 +585,7 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
'backup_import_activities' => 'activities',
|
||||
'backup_import_blocks' => 'blocks',
|
||||
'backup_import_filters' => 'filters',
|
||||
'backup_import_badges' => 'badges',
|
||||
'backup_import_calendarevents' => 'calendarevents',
|
||||
'backup_import_permissions' => 'permissions',
|
||||
'backup_import_questionbank' => 'questionbank',
|
||||
@@ -605,6 +606,8 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
'questionbank'
|
||||
);
|
||||
self::force_enable_settings($controller, $settings);
|
||||
// Badges are not included by default when duplicating activities.
|
||||
self::force_settings($controller, ['badges'], false);
|
||||
}
|
||||
break;
|
||||
case backup::MODE_AUTOMATED:
|
||||
@@ -645,9 +648,19 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
* @param array $settings a map from admin config names to setting names (Config name => Setting name)
|
||||
*/
|
||||
private static function force_enable_settings(backup_controller $controller, array $settings) {
|
||||
self::force_settings($controller, $settings, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set these settings to the given $value. No defaults from admin settings.
|
||||
*
|
||||
* @param backup_controller $controller The backup controller.
|
||||
* @param array $settings a map from admin config names to setting names (Config name => Setting name).
|
||||
* @param mixed $value the value to set the settings to.
|
||||
*/
|
||||
private static function force_settings(backup_controller $controller, array $settings, $value) {
|
||||
$plan = $controller->get_plan();
|
||||
foreach ($settings as $config => $settingname) {
|
||||
$value = true;
|
||||
if ($plan->setting_exists($settingname)) {
|
||||
$setting = $plan->get_setting($settingname);
|
||||
// We do not allow this setting to be locked for a duplicate function.
|
||||
|
||||
@@ -21,6 +21,12 @@ Feature: Duplicate activities
|
||||
| data | Test database name | Test database description | C1 | database1 | 1 |
|
||||
And the following config values are set as admin:
|
||||
| backup_import_activities | 0 | backup |
|
||||
And the following "core_badges > Badges" exist:
|
||||
| name | course | description | image | status | type |
|
||||
| My course badge | C1 | Badge description | badges/tests/behat/badge.png | active | 2 |
|
||||
And the following "core_badges > Criterias" exist:
|
||||
| badge | role |
|
||||
| My course badge | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I duplicate "Test database name" activity
|
||||
@@ -38,3 +44,8 @@ Feature: Duplicate activities
|
||||
Then I should see "Original database name" in the "Section 1" "section"
|
||||
And I should see "Duplicated database name" in the "Section 1" "section"
|
||||
And "Original database name" "link" should appear before "Duplicated database name" "link"
|
||||
# Check that badges are not duplicated. If they are duplicated, they will appear as "Not available".
|
||||
And I navigate to "Badges" in current page administration
|
||||
And the following should not exist in the "reportbuilder-table" table:
|
||||
| Name | Badge status |
|
||||
| My course badge | Not available |
|
||||
|
||||
@@ -68,7 +68,7 @@ Feature: Import course's contents into another course
|
||||
| Published course badge | editingteacher |
|
||||
| Unpublished course badge | editingteacher |
|
||||
When I import "Course 1" course into "Course 2" course using this options:
|
||||
| Settings | Include badges | 1 |
|
||||
| Initial | Include badges | 1 |
|
||||
And I navigate to "Badges" in current page administration
|
||||
Then I should see "Published course badge"
|
||||
And I should see "Unpublished course badge"
|
||||
@@ -77,3 +77,16 @@ Feature: Import course's contents into another course
|
||||
And I should not see "Criteria for this badge have not been set up yet" in the "Published course badge" "table_row"
|
||||
And I should not see "Criteria for this badge have not been set up yet" in the "Unpublished course badge" "table_row"
|
||||
And I should see "Criteria for this badge have not been set up yet" in the "Unpublished without criteria course badge" "table_row"
|
||||
|
||||
Scenario: Import process should not include badges by default
|
||||
Given I log in as "teacher1"
|
||||
And the following "core_badges > Badges" exist:
|
||||
| name | course | description | image | status | type |
|
||||
| Published course badge | C1 | Badge description | badges/tests/behat/badge.png | active | 2 |
|
||||
And the following "core_badges > Criterias" exist:
|
||||
| badge | role |
|
||||
| Published course badge | editingteacher |
|
||||
When I import "Course 1" course into "Course 2" course using this options:
|
||||
| Initial | Include badges | 0 |
|
||||
And I navigate to "Badges" in current page administration
|
||||
Then I should not see "Published course badge"
|
||||
|
||||
Reference in New Issue
Block a user