Merge branch 'MDL-60835-master' of git://github.com/crazyserver/moodle

This commit is contained in:
Jake Dallimore 2017-11-20 11:27:46 +08:00
commit 268e772a8a
2 changed files with 25 additions and 2 deletions

View file

@ -265,9 +265,11 @@ class core_completion_external extends external_api {
$thisprogress = $userprogress->progress[$activity->id]; $thisprogress = $userprogress->progress[$activity->id];
$state = $thisprogress->completionstate; $state = $thisprogress->completionstate;
$timecompleted = $thisprogress->timemodified; $timecompleted = $thisprogress->timemodified;
$overrideby = $thisprogress->overrideby;
} else { } else {
$state = COMPLETION_INCOMPLETE; $state = COMPLETION_INCOMPLETE;
$timecompleted = 0; $timecompleted = 0;
$overrideby = null;
} }
$results[] = array( $results[] = array(
@ -276,7 +278,8 @@ class core_completion_external extends external_api {
'instance' => $activity->instance, 'instance' => $activity->instance,
'state' => $state, 'state' => $state,
'timecompleted' => $timecompleted, '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'), 'timecompleted' => new external_value(PARAM_INT, 'timestamp for completed activity'),
'tracking' => new external_value(PARAM_INT, 'type of tracking: 'tracking' => new external_value(PARAM_INT, 'type of tracking:
0 means none, 1 manual, 2 automatic'), 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' ), 'Activity'
), 'List of activities status' ), 'List of activities status'
), ),

View file

@ -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. // We added 4 activities, but only 3 with completion enabled and one of those is hidden.
$this->assertCount(3, $result['statuses']); $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); $context = context_course::instance($course->id);
assign_capability('moodle/site:accessallgroups', CAP_PROHIBIT, $teacherrole->id, $context); assign_capability('moodle/site:accessallgroups', CAP_PROHIBIT, $teacherrole->id, $context);
accesslib_clear_all_caches_for_unit_testing(); accesslib_clear_all_caches_for_unit_testing();