mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-35768 Backup and restore of section format-specific options
This commit is contained in:
parent
aea2e3c30d
commit
0360443020
@ -394,6 +394,11 @@ class backup_section_structure_step extends backup_structure_step {
|
|||||||
$section->add_child($avail);
|
$section->add_child($avail);
|
||||||
$section->add_child($availfield);
|
$section->add_child($availfield);
|
||||||
|
|
||||||
|
// Add nested elements for course_format_options table
|
||||||
|
$formatoptions = new backup_nested_element('course_format_options', array('id'), array(
|
||||||
|
'format', 'name', 'value'));
|
||||||
|
$section->add_child($formatoptions);
|
||||||
|
|
||||||
// Define sources
|
// Define sources
|
||||||
$section->set_source_table('course_sections', array('id' => backup::VAR_SECTIONID));
|
$section->set_source_table('course_sections', array('id' => backup::VAR_SECTIONID));
|
||||||
$avail->set_source_table('course_sections_availability', array('coursesectionid' => backup::VAR_SECTIONID));
|
$avail->set_source_table('course_sections_availability', array('coursesectionid' => backup::VAR_SECTIONID));
|
||||||
@ -402,6 +407,10 @@ class backup_section_structure_step extends backup_structure_step {
|
|||||||
FROM {course_sections_avail_fields} csaf
|
FROM {course_sections_avail_fields} csaf
|
||||||
LEFT JOIN {user_info_field} uif ON uif.id = csaf.customfieldid
|
LEFT JOIN {user_info_field} uif ON uif.id = csaf.customfieldid
|
||||||
WHERE csaf.coursesectionid = ?', array(backup::VAR_SECTIONID));
|
WHERE csaf.coursesectionid = ?', array(backup::VAR_SECTIONID));
|
||||||
|
$formatoptions->set_source_sql('SELECT cfo.id, cfo.format, cfo.name, cfo.value
|
||||||
|
FROM {course_format_options} cfo, {course} c
|
||||||
|
WHERE cfo.sectionid = ? AND cfo.courseid = c.id AND cfo.format = c.format',
|
||||||
|
array(backup::VAR_SECTIONID));
|
||||||
|
|
||||||
// Aliases
|
// Aliases
|
||||||
$section->set_source_alias('section', 'number');
|
$section->set_source_alias('section', 'number');
|
||||||
|
@ -1100,6 +1100,7 @@ class restore_section_structure_step extends restore_structure_step {
|
|||||||
$paths[] = new restore_path_element('availability', '/section/availability');
|
$paths[] = new restore_path_element('availability', '/section/availability');
|
||||||
$paths[] = new restore_path_element('availability_field', '/section/availability_field');
|
$paths[] = new restore_path_element('availability_field', '/section/availability_field');
|
||||||
}
|
}
|
||||||
|
$paths[] = new restore_path_element('course_format_options', '/section/course_format_options');
|
||||||
|
|
||||||
// Apply for 'format' plugins optional paths at section level
|
// Apply for 'format' plugins optional paths at section level
|
||||||
$this->add_plugin_structure('format', $section);
|
$this->add_plugin_structure('format', $section);
|
||||||
@ -1233,6 +1234,14 @@ class restore_section_structure_step extends restore_structure_step {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function process_course_format_options($data) {
|
||||||
|
global $DB;
|
||||||
|
$data = (object)$data;
|
||||||
|
$data->sectionid = $this->task->get_sectionid();
|
||||||
|
$data->courseid = $this->get_courseid();
|
||||||
|
$newid = $DB->insert_record('course_format_options', $data);
|
||||||
|
}
|
||||||
|
|
||||||
protected function after_execute() {
|
protected function after_execute() {
|
||||||
// Add section related files, with 'course_section' itemid to match
|
// Add section related files, with 'course_section' itemid to match
|
||||||
$this->add_related_files('course', 'section', 'course_section');
|
$this->add_related_files('course', 'section', 'course_section');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user