mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
Merge branch 'MDL-60835-master' of git://github.com/crazyserver/moodle
This commit is contained in:
commit
268e772a8a
2 changed files with 25 additions and 2 deletions
|
@ -265,9 +265,11 @@ class core_completion_external extends external_api {
|
|||
$thisprogress = $userprogress->progress[$activity->id];
|
||||
$state = $thisprogress->completionstate;
|
||||
$timecompleted = $thisprogress->timemodified;
|
||||
$overrideby = $thisprogress->overrideby;
|
||||
} else {
|
||||
$state = COMPLETION_INCOMPLETE;
|
||||
$timecompleted = 0;
|
||||
$overrideby = null;
|
||||
}
|
||||
|
||||
$results[] = array(
|
||||
|
@ -276,7 +278,8 @@ class core_completion_external extends external_api {
|
|||
'instance' => $activity->instance,
|
||||
'state' => $state,
|
||||
'timecompleted' => $timecompleted,
|
||||
'tracking' => $activity->completion
|
||||
'tracking' => $activity->completion,
|
||||
'overrideby' => $overrideby
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -308,6 +311,8 @@ class core_completion_external extends external_api {
|
|||
'timecompleted' => new external_value(PARAM_INT, 'timestamp for completed activity'),
|
||||
'tracking' => new external_value(PARAM_INT, 'type of tracking:
|
||||
0 means none, 1 manual, 2 automatic'),
|
||||
'overrideby' => new external_value(PARAM_INT, 'The user id who has overriden the status, or null',
|
||||
VALUE_OPTIONAL),
|
||||
), 'Activity'
|
||||
), 'List of activities status'
|
||||
),
|
||||
|
|
|
@ -164,7 +164,25 @@ class core_completion_externallib_testcase extends externallib_advanced_testcase
|
|||
// We added 4 activities, but only 3 with completion enabled and one of those is hidden.
|
||||
$this->assertCount(3, $result['statuses']);
|
||||
|
||||
// Change teacher role capabilities (disable access al goups).
|
||||
// Override status by teacher.
|
||||
$completion->update_state($cmforum, COMPLETION_INCOMPLETE, $student->id, true);
|
||||
|
||||
$result = core_completion_external::get_activities_completion_status($course->id, $student->id);
|
||||
// We need to execute the return values cleaning process to simulate the web service server.
|
||||
$result = external_api::clean_returnvalue(
|
||||
core_completion_external::get_activities_completion_status_returns(), $result);
|
||||
|
||||
// Check forum has been overriden by the teacher.
|
||||
foreach ($result['statuses'] as $status) {
|
||||
if ($status['cmid'] == $forum->cmid) {
|
||||
$this->assertEquals(COMPLETION_INCOMPLETE, $status['state']);
|
||||
$this->assertEquals(COMPLETION_TRACKING_MANUAL, $status['tracking']);
|
||||
$this->assertEquals($teacher->id, $status['overrideby']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Change teacher role capabilities (disable access all groups).
|
||||
$context = context_course::instance($course->id);
|
||||
assign_capability('moodle/site:accessallgroups', CAP_PROHIBIT, $teacherrole->id, $context);
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue