mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-65211 enrol: Return if user is being completion tracked
This commit is contained in:
parent
0920f35ed9
commit
dfcf8342fb
@ -366,6 +366,7 @@ class core_enrol_external extends external_api {
|
||||
$progress = null;
|
||||
$completed = null;
|
||||
$completionhascriteria = false;
|
||||
$completionusertracked = false;
|
||||
|
||||
// Return only private information if the user should be able to see it.
|
||||
if ($sameuser || completion_can_view_data($userid, $course)) {
|
||||
@ -373,6 +374,7 @@ class core_enrol_external extends external_api {
|
||||
$completion = new completion_info($course);
|
||||
$completed = $completion->is_course_complete($userid);
|
||||
$completionhascriteria = $completion->has_criteria();
|
||||
$completionusertracked = $completion->is_tracked_user($userid);
|
||||
$progress = \core_completion\progress::get_course_progress_percentage($course, $userid);
|
||||
}
|
||||
}
|
||||
@ -425,6 +427,7 @@ class core_enrol_external extends external_api {
|
||||
'lang' => clean_param($course->lang, PARAM_LANG),
|
||||
'enablecompletion' => $course->enablecompletion,
|
||||
'completionhascriteria' => $completionhascriteria,
|
||||
'completionusertracked' => $completionusertracked,
|
||||
'category' => $course->category,
|
||||
'progress' => $progress,
|
||||
'completed' => $completed,
|
||||
@ -470,6 +473,7 @@ class core_enrol_external extends external_api {
|
||||
'enablecompletion' => new external_value(PARAM_BOOL, 'true if completion is enabled, otherwise false',
|
||||
VALUE_OPTIONAL),
|
||||
'completionhascriteria' => new external_value(PARAM_BOOL, 'If completion criteria is set.', VALUE_OPTIONAL),
|
||||
'completionusertracked' => new external_value(PARAM_BOOL, 'If the user is completion tracked.', VALUE_OPTIONAL),
|
||||
'category' => new external_value(PARAM_INT, 'course category id', VALUE_OPTIONAL),
|
||||
'progress' => new external_value(PARAM_FLOAT, 'Progress percentage', VALUE_OPTIONAL),
|
||||
'completed' => new external_value(PARAM_BOOL, 'Whether the course is completed.', VALUE_OPTIONAL),
|
||||
|
@ -453,6 +453,7 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(100.0, $courseenrol['progress']);
|
||||
$this->assertEquals(true, $courseenrol['completed']);
|
||||
$this->assertTrue($courseenrol['completionhascriteria']);
|
||||
$this->assertTrue($courseenrol['completionusertracked']);
|
||||
$this->assertTrue($courseenrol['hidden']);
|
||||
$this->assertTrue($courseenrol['isfavourite']);
|
||||
$this->assertEquals(2, $courseenrol['enrolledusercount']);
|
||||
@ -465,6 +466,7 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(0, $courseenrol['progress']);
|
||||
$this->assertEquals(false, $courseenrol['completed']);
|
||||
$this->assertFalse($courseenrol['completionhascriteria']);
|
||||
$this->assertFalse($courseenrol['completionusertracked']);
|
||||
$this->assertFalse($courseenrol['hidden']);
|
||||
$this->assertFalse($courseenrol['isfavourite']);
|
||||
$this->assertEquals(1, $courseenrol['enrolledusercount']);
|
||||
@ -489,11 +491,13 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals($timenow, $courseenrol['lastaccess']);
|
||||
$this->assertEquals(100.0, $courseenrol['progress']);
|
||||
$this->assertTrue($courseenrol['completionhascriteria']);
|
||||
$this->assertTrue($courseenrol['completionusertracked']);
|
||||
$this->assertFalse($courseenrol['isfavourite']); // This always false.
|
||||
$this->assertFalse($courseenrol['hidden']); // This always false.
|
||||
} else {
|
||||
$this->assertEquals(0, $courseenrol['progress']);
|
||||
$this->assertFalse($courseenrol['completionhascriteria']);
|
||||
$this->assertFalse($courseenrol['completionusertracked']);
|
||||
$this->assertFalse($courseenrol['isfavourite']); // This always false.
|
||||
$this->assertFalse($courseenrol['hidden']); // This always false.
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ information provided here is intended especially for developers.
|
||||
- totalusers: Number users matching the search. (This element only exists if the function is called with $returnexactcount param set to true).
|
||||
* enrolledusercount is now optional in the return value of get_users_courses() for performance reasons. This is controlled with the new
|
||||
optional returnusercount parameter (default true).
|
||||
* External function core_enrol_external::get_users_courses now returns a new field "completionusertracked" that indicates if the
|
||||
given user is being tracked for completion.
|
||||
|
||||
=== 3.6 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user