mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-56307 course: Support new returned data in WS
This commit is contained in:
parent
65b2669d98
commit
25adfbaa4a
@ -3041,7 +3041,7 @@ class core_course_external extends external_api {
|
||||
'Instances to check'
|
||||
),
|
||||
'filter' => new external_multiple_structure(
|
||||
new external_value(PARAM_ALPHANUM, 'Area name: configuration, fileareas, completion, ratings, comments,
|
||||
new external_value(PARAM_ALPHANUM, 'Area name: configuration, fileareas, completion, ratings, comments,
|
||||
gradeitems, outcomes'),
|
||||
'Check only for updates in these areas', VALUE_DEFAULT, array()
|
||||
)
|
||||
@ -3053,7 +3053,6 @@ class core_course_external extends external_api {
|
||||
* Check if there is updates affecting the user for the given course and contexts.
|
||||
* Right now only modules are supported.
|
||||
* This WS calls mod_check_updates_since for each module to check if there is any update the user should we aware of.
|
||||
* It just returns if there is updates, not specific information.
|
||||
*
|
||||
* @param int $courseid the list of modules to check
|
||||
* @param array $tocheck the list of modules to check
|
||||
@ -3083,17 +3082,28 @@ class core_course_external extends external_api {
|
||||
$instancesformatted = array();
|
||||
foreach ($instances as $instance) {
|
||||
$updates = array();
|
||||
foreach ($instance['updates'] as $name => $updated) {
|
||||
$updates[] = array(
|
||||
foreach ($instance['updates'] as $name => $data) {
|
||||
if (empty($data->updated)) {
|
||||
continue;
|
||||
}
|
||||
$updatedata = array(
|
||||
'name' => $name,
|
||||
'updated' => $updated
|
||||
);
|
||||
if (!empty($data->timeupdated)) {
|
||||
$updatedata['timeupdated'] = $data->timeupdated;
|
||||
}
|
||||
if (!empty($data->itemids)) {
|
||||
$updatedata['itemids'] = $data->itemids;
|
||||
}
|
||||
$updates[] = $updatedata;
|
||||
}
|
||||
if (!empty($updates)) {
|
||||
$instancesformatted[] = array(
|
||||
'contextlevel' => $instance['contextlevel'],
|
||||
'id' => $instance['id'],
|
||||
'updates' => $updates
|
||||
);
|
||||
}
|
||||
$instancesformatted[] = array(
|
||||
'contextlevel' => $instance['contextlevel'],
|
||||
'id' => $instance['id'],
|
||||
'updates' => $updates
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
@ -3120,7 +3130,12 @@ class core_course_external extends external_api {
|
||||
new external_single_structure(
|
||||
array(
|
||||
'name' => new external_value(PARAM_ALPHANUMEXT, 'Name of the area updated.'),
|
||||
'updated' => new external_value(PARAM_BOOL, 'Whether is was updated since the given time.')
|
||||
'timeupdated' => new external_value(PARAM_INT, 'Last time was updated', VALUE_OPTIONAL),
|
||||
'itemids' => new external_multiple_structure(
|
||||
new external_value(PARAM_INT, 'Instance id'),
|
||||
'The ids of the items updated',
|
||||
VALUE_OPTIONAL
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -2076,13 +2076,8 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
|
||||
// Check there is nothing updated because modules are fresh new.
|
||||
$result = core_course_external::check_updates($course->id, $params);
|
||||
$result = external_api::clean_returnvalue(core_course_external::check_updates_returns(), $result);
|
||||
$this->assertCount(16, $result['instances']);
|
||||
$this->assertCount(0, $result['instances']);
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
foreach ($result['instances'] as $module) {
|
||||
foreach ($module['updates'] as $update) {
|
||||
$this->assertFalse($update['updated']);
|
||||
}
|
||||
}
|
||||
|
||||
// Update a module after a second.
|
||||
$this->waitForSecond();
|
||||
@ -2091,15 +2086,12 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
|
||||
$found = false;
|
||||
$result = core_course_external::check_updates($course->id, $params);
|
||||
$result = external_api::clean_returnvalue(core_course_external::check_updates_returns(), $result);
|
||||
$this->assertCount(16, $result['instances']);
|
||||
$this->assertCount(1, $result['instances']);
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
foreach ($result['instances'] as $module) {
|
||||
foreach ($module['updates'] as $update) {
|
||||
if ($module['id'] == $modules['forum']['cm']->id and $update['name'] == 'configuration') {
|
||||
$this->assertTrue($update['updated']);
|
||||
$found = true;
|
||||
} else {
|
||||
$this->assertFalse($update['updated']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2110,15 +2102,8 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
|
||||
$found = false;
|
||||
$result = core_course_external::check_updates($course->id, $params, $filter);
|
||||
$result = external_api::clean_returnvalue(core_course_external::check_updates_returns(), $result);
|
||||
$this->assertCount(16, $result['instances']);
|
||||
$this->assertCount(0, $result['instances']);
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
foreach ($result['instances'] as $module) {
|
||||
foreach ($module['updates'] as $update) {
|
||||
if ($module['id'] == $modules['forum']['cm']->id and $update['name'] == 'configuration') {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assertFalse($found);
|
||||
|
||||
// Add invalid cmid.
|
||||
|
Loading…
x
Reference in New Issue
Block a user