Skip to content
Permalink
Browse files

MDL-53149 mod_data: update backup and webservices for timemodified

Amended to add support for standard restore apply_date_offset().
  • Loading branch information...
danpoltawski authored and stronk7 committed Mar 3, 2016
1 parent b174e9e commit 4539892cda288e501a250263d71695da09f1cd39
@@ -45,7 +45,7 @@ protected function define_structure() {
'addtemplate', 'rsstemplate', 'rsstitletemplate', 'csstemplate',
'jstemplate', 'asearchtemplate', 'approval', 'manageapproved', 'scale',
'assessed', 'assesstimestart', 'assesstimefinish', 'defaultsort',
'defaultsortdir', 'editany', 'notification'));
'defaultsortdir', 'editany', 'notification', 'timemodified'));
$fields = new backup_nested_element('fields');
@@ -61,6 +61,8 @@ protected function process_data($data) {
$data->timeviewto = $this->apply_date_offset($data->timeviewto);
$data->assesstimestart = $this->apply_date_offset($data->assesstimestart);
$data->assesstimefinish = $this->apply_date_offset($data->assesstimefinish);
// Added in 3.1, hence conditional.
$data->timemodified = isset($data->timemodified) ? $this->apply_date_offset($data->timemodified) : time();
if ($data->scale < 0) { // scale found, get mapping
$data->scale = -($this->get_mappingid('scale', abs($data->scale)));
@@ -128,7 +128,7 @@ public static function get_databases_by_courses($courseids = array()) {
$additionalfields = array('maxentries', 'rssarticles', 'singletemplate', 'listtemplate',
'listtemplateheader', 'listtemplatefooter', 'addtemplate', 'rsstemplate', 'rsstitletemplate',
'csstemplate', 'jstemplate', 'asearchtemplate', 'approval', 'manageapproved', 'scale', 'assessed', 'assesstimestart',
'assesstimefinish', 'defaultsort', 'defaultsortdir', 'editany', 'notification');
'assesstimefinish', 'defaultsort', 'defaultsortdir', 'editany', 'notification', 'timemodified');
// This is for avoid a long repetitive list.
foreach ($additionalfields as $field) {
@@ -195,7 +195,8 @@ public static function get_databases_by_courses_returns() {
'defaultsort' => new external_value(PARAM_INT, 'defaultsort field', VALUE_OPTIONAL),
'defaultsortdir' => new external_value(PARAM_INT, 'defaultsortdir field', VALUE_OPTIONAL),
'editany' => new external_value(PARAM_BOOL, 'editany field', VALUE_OPTIONAL),
'notification' => new external_value(PARAM_INT, 'notification field', VALUE_OPTIONAL)
'notification' => new external_value(PARAM_INT, 'notification field', VALUE_OPTIONAL),
'timemodified' => new external_value(PARAM_INT, 'Time modified', VALUE_OPTIONAL)
), 'Database'
)
),
@@ -141,7 +141,7 @@ public function test_mod_data_get_databases_by_courses() {
// Now, try as a teacher for getting all the additional fields.
self::setUser($teacher);
$additionalfields = array('maxentries', 'rssarticles', 'singletemplate', 'listtemplate',
$additionalfields = array('maxentries', 'rssarticles', 'singletemplate', 'listtemplate', 'timemodified',
'listtemplateheader', 'listtemplatefooter', 'addtemplate', 'rsstemplate', 'rsstitletemplate',
'csstemplate', 'jstemplate', 'asearchtemplate', 'approval', 'scale', 'assessed', 'assesstimestart',
'assesstimefinish', 'defaultsort', 'defaultsortdir', 'editany', 'notification', 'manageapproved');

0 comments on commit 4539892

Please sign in to comment.
You can’t perform that action at this time.