mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-53974 backup: Add option to backup course competencies
This commit is contained in:
parent
11ee4f71a4
commit
45b9207d7e
@ -163,5 +163,10 @@ class backup_root_task extends backup_task {
|
||||
$groups = new backup_groups_setting('groups', base_setting::IS_BOOLEAN, true);
|
||||
$groups->set_ui(new backup_setting_ui_checkbox($groups, get_string('rootsettinggroups', 'backup')));
|
||||
$this->add_setting($groups);
|
||||
|
||||
// Define competencies inclusion setting if competencies are enabled.
|
||||
$competencies = new backup_competencies_setting();
|
||||
$competencies->set_ui(new backup_setting_ui_checkbox($competencies, get_string('rootsettingcompetencies', 'backup')));
|
||||
$this->add_setting($competencies);
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +130,27 @@ class backup_calendarevents_setting extends backup_anonymize_setting {}
|
||||
*/
|
||||
class backup_userscompletion_setting extends backup_anonymize_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if backup will include competencies or not.
|
||||
*/
|
||||
class backup_competencies_setting extends backup_generic_setting {
|
||||
|
||||
/**
|
||||
* backup_competencies_setting constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$defaultvalue = false;
|
||||
$visibility = base_setting::HIDDEN;
|
||||
$status = base_setting::LOCKED_BY_CONFIG;
|
||||
if (\core_competency\api::is_enabled()) {
|
||||
$defaultvalue = true;
|
||||
$visibility = base_setting::VISIBLE;
|
||||
$status = base_setting::NOT_LOCKED;
|
||||
}
|
||||
parent::__construct('competencies', base_setting::IS_BOOLEAN, $defaultvalue, $visibility, $status);
|
||||
}
|
||||
}
|
||||
|
||||
// Section backup settings
|
||||
|
||||
/**
|
||||
|
@ -1585,6 +1585,21 @@ class backup_course_competencies_structure_step extends backup_structure_step {
|
||||
|
||||
return $wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute conditions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function execute_condition() {
|
||||
|
||||
// Do not execute if competencies are not included.
|
||||
if (!$this->get_setting_value('competencies')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1612,6 +1627,21 @@ class backup_activity_competencies_structure_step extends backup_structure_step
|
||||
|
||||
return $wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute conditions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function execute_condition() {
|
||||
|
||||
// Do not execute if competencies are not included.
|
||||
if (!$this->get_setting_value('competencies')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,5 +266,11 @@ class restore_root_task extends restore_task {
|
||||
$groups->set_ui(new backup_setting_ui_checkbox($groups, get_string('rootsettinggroups', 'backup')));
|
||||
$groups->get_ui()->set_changeable($changeable);
|
||||
$this->add_setting($groups);
|
||||
|
||||
// Competencies restore setting. Show when competencies is enabled and the setting is available.
|
||||
$hascompetencies = !empty($rootsettings['competencies']);
|
||||
$competencies = new restore_competencies_setting($hascompetencies);
|
||||
$competencies->set_ui(new backup_setting_ui_checkbox($competencies, get_string('rootsettingcompetencies', 'backup')));
|
||||
$this->add_setting($competencies);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,30 @@ class restore_comments_setting extends restore_role_assignments_setting {}
|
||||
*/
|
||||
class restore_badges_setting extends restore_generic_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if competencies will also be restored.
|
||||
*/
|
||||
class restore_competencies_setting extends restore_generic_setting {
|
||||
|
||||
/**
|
||||
* restore_competencies_setting constructor.
|
||||
* @param bool $hascompetencies Flag whether to set the restore setting as checked and unlocked.
|
||||
*/
|
||||
public function __construct($hascompetencies) {
|
||||
$defaultvalue = false;
|
||||
$visibility = base_setting::HIDDEN;
|
||||
$status = base_setting::LOCKED_BY_CONFIG;
|
||||
if (\core_competency\api::is_enabled()) {
|
||||
$visibility = base_setting::VISIBLE;
|
||||
if ($hascompetencies) {
|
||||
$defaultvalue = true;
|
||||
$status = base_setting::NOT_LOCKED;
|
||||
}
|
||||
}
|
||||
parent::__construct('competencies', base_setting::IS_BOOLEAN, $defaultvalue, $visibility, $status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* root setting to control if restore will create
|
||||
* events or no, depends of @restore_users_setting
|
||||
|
@ -3213,8 +3213,8 @@ class restore_course_competencies_structure_step extends restore_structure_step
|
||||
*/
|
||||
protected function execute_condition() {
|
||||
|
||||
// Do not restore when competencies are disabled.
|
||||
if (!\core_competency\api::is_enabled()) {
|
||||
// Do not execute if competencies are not included.
|
||||
if (!$this->get_setting_value('competencies')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3288,8 +3288,8 @@ class restore_activity_competencies_structure_step extends restore_structure_ste
|
||||
*/
|
||||
protected function execute_condition() {
|
||||
|
||||
// Do not restore when competencies are disabled.
|
||||
if (!\core_competency\api::is_enabled()) {
|
||||
// Do not execute if competencies are not included.
|
||||
if (!$this->get_setting_value('competencies')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -237,6 +237,7 @@ $string['rootsettingroleassignments'] = 'Include user role assignments';
|
||||
$string['rootsettingactivities'] = 'Include activities and resources';
|
||||
$string['rootsettingbadges'] = 'Include badges';
|
||||
$string['rootsettingblocks'] = 'Include blocks';
|
||||
$string['rootsettingcompetencies'] = 'Include competencies';
|
||||
$string['rootsettingfilters'] = 'Include filters';
|
||||
$string['rootsettingcomments'] = 'Include comments';
|
||||
$string['rootsettingcalendarevents'] = 'Include calendar events';
|
||||
|
Loading…
x
Reference in New Issue
Block a user