Merge branch 'MDL-61312-34' of git://github.com/jleyva/moodle into MOODLE_34_STABLE
This commit is contained in:
@@ -249,8 +249,6 @@ class core_completion_external extends external_api {
|
||||
|
||||
$completion = new completion_info($course);
|
||||
$activities = $completion->get_activities();
|
||||
$progresses = $completion->get_progress_all('u.id = :uid', ['uid' => $params['userid']]);
|
||||
$userprogress = $progresses[$user->id];
|
||||
|
||||
$results = array();
|
||||
foreach ($activities as $activity) {
|
||||
@@ -260,26 +258,17 @@ class core_completion_external extends external_api {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get progress information and state.
|
||||
if (array_key_exists($activity->id, $userprogress->progress)) {
|
||||
$thisprogress = $userprogress->progress[$activity->id];
|
||||
$state = $thisprogress->completionstate;
|
||||
$timecompleted = $thisprogress->timemodified;
|
||||
$overrideby = $thisprogress->overrideby;
|
||||
} else {
|
||||
$state = COMPLETION_INCOMPLETE;
|
||||
$timecompleted = 0;
|
||||
$overrideby = null;
|
||||
}
|
||||
// Get progress information and state (we must use get_data because it works for all user roles in course).
|
||||
$activitycompletiondata = $completion->get_data($activity, true, $user->id);
|
||||
|
||||
$results[] = array(
|
||||
'cmid' => $activity->id,
|
||||
'modname' => $activity->modname,
|
||||
'instance' => $activity->instance,
|
||||
'state' => $state,
|
||||
'timecompleted' => $timecompleted,
|
||||
'state' => $activitycompletiondata->completionstate,
|
||||
'timecompleted' => $activitycompletiondata->timemodified,
|
||||
'tracking' => $activity->completion,
|
||||
'overrideby' => $overrideby
|
||||
'overrideby' => $activitycompletiondata->overrideby
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,34 @@ class core_completion_externallib_testcase extends externallib_advanced_testcase
|
||||
}
|
||||
}
|
||||
|
||||
// Teacher should see his own completion status.
|
||||
|
||||
// Forum complete for teacher.
|
||||
$completion = new completion_info($course);
|
||||
$completion->update_state($cmforum, COMPLETION_COMPLETE);
|
||||
|
||||
$result = core_completion_external::get_activities_completion_status($course->id, $teacher->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);
|
||||
|
||||
// We added 4 activities, but only 3 with completion enabled (one of those is hidden but the teacher can see it).
|
||||
$this->assertCount(3, $result['statuses']);
|
||||
|
||||
$activitiesfound = 0;
|
||||
foreach ($result['statuses'] as $status) {
|
||||
if ($status['cmid'] == $forum->cmid and $status['modname'] == 'forum' and $status['instance'] == $forum->id) {
|
||||
$activitiesfound++;
|
||||
$this->assertEquals(COMPLETION_COMPLETE, $status['state']);
|
||||
$this->assertEquals(COMPLETION_TRACKING_MANUAL, $status['tracking']);
|
||||
} else {
|
||||
$activitiesfound++;
|
||||
$this->assertEquals(COMPLETION_INCOMPLETE, $status['state']);
|
||||
$this->assertEquals(COMPLETION_TRACKING_MANUAL, $status['tracking']);
|
||||
}
|
||||
}
|
||||
$this->assertEquals(3, $activitiesfound);
|
||||
|
||||
// Change teacher role capabilities (disable access all groups).
|
||||
$context = context_course::instance($course->id);
|
||||
assign_capability('moodle/site:accessallgroups', CAP_PROHIBIT, $teacherrole->id, $context);
|
||||
|
||||
Reference in New Issue
Block a user