mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-71455 core_backup: fix course completion options when backup/restore
This commit is contained in:
parent
a5f0b354e7
commit
2935cb508d
@ -391,6 +391,8 @@ class backup_course_structure_step extends backup_structure_step {
|
||||
'defaultgroupingid', 'lang', 'theme',
|
||||
'timecreated', 'timemodified',
|
||||
'requested',
|
||||
'showactivitydates',
|
||||
'showcompletionconditions',
|
||||
'enablecompletion', 'completionstartonenrol', 'completionnotify'));
|
||||
|
||||
$category = new backup_nested_element('category', array('id'), array(
|
||||
|
@ -1914,11 +1914,23 @@ class restore_course_structure_step extends restore_structure_step {
|
||||
if ($data->defaultgroupingid) {
|
||||
$data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);
|
||||
}
|
||||
|
||||
$courseconfig = get_config('moodlecourse');
|
||||
|
||||
if (empty($CFG->enablecompletion)) {
|
||||
// Completion is disabled globally.
|
||||
$data->enablecompletion = 0;
|
||||
$data->completionstartonenrol = 0;
|
||||
$data->completionnotify = 0;
|
||||
$data->showcompletionconditions = null;
|
||||
} else {
|
||||
$showcompletionconditionsdefault = ($courseconfig->showcompletionconditions ?? null);
|
||||
$data->showcompletionconditions = $data->showcompletionconditions ?? $showcompletionconditionsdefault;
|
||||
}
|
||||
|
||||
$showactivitydatesdefault = ($courseconfig->showactivitydates ?? null);
|
||||
$data->showactivitydates = $data->showactivitydates ?? $showactivitydatesdefault;
|
||||
|
||||
$languages = get_string_manager()->get_list_of_translations(); // Get languages for quick search
|
||||
if (isset($data->lang) && !array_key_exists($data->lang, $languages)) {
|
||||
$data->lang = '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user