MDL-64123 webservices: Add valueused to completion data

This commit is contained in:
Mark Johnson 2018-11-21 10:27:33 +00:00
parent 33a388eff7
commit 7672471236
6 changed files with 42 additions and 6 deletions

View file

@ -268,7 +268,8 @@ class core_completion_external extends external_api {
'state' => $activitycompletiondata->completionstate,
'timecompleted' => $activitycompletiondata->timemodified,
'tracking' => $activity->completion,
'overrideby' => $activitycompletiondata->overrideby
'overrideby' => $activitycompletiondata->overrideby,
'valueused' => core_availability\info::completion_value_used($course, $activity->id)
);
}
@ -302,6 +303,8 @@ class core_completion_external extends external_api {
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),
'valueused' => new external_value(PARAM_BOOL, 'Whether the completion status affects the availability
of another activity.', VALUE_OPTIONAL),
), 'Activity'
), 'List of activities status'
),

View file

@ -103,12 +103,14 @@ class core_completion_externallib_testcase extends externallib_advanced_testcase
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1,
'groupmode' => SEPARATEGROUPS,
'groupmodeforce' => 1));
availability_completion\condition::wipe_static_cache();
$data = $this->getDataGenerator()->create_module('data', array('course' => $course->id),
array('completion' => 1));
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id),
array('completion' => 1));
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course->id));
$availability = '{"op":"&","c":[{"type":"completion","cm":' . $forum->cmid .',"e":1}],"showc":[true]}';
$assign = $this->getDataGenerator()->create_module('assign', ['course' => $course->id], ['availability' => $availability]);
$page = $this->getDataGenerator()->create_module('page', array('course' => $course->id),
array('completion' => 1, 'visible' => 0));
@ -146,10 +148,12 @@ class core_completion_externallib_testcase extends externallib_advanced_testcase
$activitiesfound++;
$this->assertEquals(COMPLETION_COMPLETE, $status['state']);
$this->assertEquals(COMPLETION_TRACKING_MANUAL, $status['tracking']);
$this->assertTrue($status['valueused']);
} else if ($status['cmid'] == $data->cmid and $status['modname'] == 'data' and $status['instance'] == $data->id) {
$activitiesfound++;
$this->assertEquals(COMPLETION_INCOMPLETE, $status['state']);
$this->assertEquals(COMPLETION_TRACKING_MANUAL, $status['tracking']);
$this->assertFalse($status['valueused']);
}
}
$this->assertEquals(2, $activitiesfound);

View file

@ -1,6 +1,10 @@
This files describes API changes in /completion/* - completion,
information provided here is intended especially for developers.
=== 3.7 ===
* External function core_completion_external::get_activities_completion_status new returns the following additional field:
- valueused (indicates whether the completion state affects the availability of other content)
=== 2.9 ===
* A completed and failed activity counts as a completed activity for