MDL-55548 backup: changes after review

1) There is no need to store the 'timemodified' value of
the section when backing up a course module, they do
not refer to the same time.
2) When creating a new course section during restore use
the current time.
3) Added timemodified value to more places when updating
the 'course_sections' table.
This commit is contained in:
Mark Nelson
2017-06-12 15:52:54 +08:00
parent 4ddf7c6025
commit b75ff47441
4 changed files with 31 additions and 19 deletions
+6 -2
View File
@@ -62,8 +62,12 @@ class info_section extends info {
protected function set_in_database($availability) {
global $DB;
$DB->set_field('course_sections', 'availability', $availability,
array('id' => $this->section->id));
$section = new \stdClass();
$section->id = $this->section->id;
$section->availability = $availability;
$section->timemodified = time();
$DB->update_record('course_sections', $section);
}
/**
@@ -287,8 +287,12 @@ class condition extends \core_availability\condition {
// Save the updated course module.
if ($changed) {
$DB->set_field('course_sections', 'availability', json_encode($tree->save()),
array('id' => $section->id));
$updatesection = new \stdClass();
$updatesection->id = $section->id;
$updatesection->availability = json_encode($tree->save());
$updatesection->timemodified = time();
$DB->update_record('course_sections', $updatesection);
$anychanged = true;
}
}