Skip to content
Permalink
Browse files
Merge branch 'MDL-65211-master' of git://github.com/jleyva/moodle
  • Loading branch information
David Monllaó authored and stronk7 committed Apr 23, 2019
2 parents 1986293 + dfcf834 commit 6dbe565998f94a882083bb1f729dc3dc57939f72
Showing with 10 additions and 0 deletions.
  1. +4 −0 enrol/externallib.php
  2. +4 −0 enrol/tests/externallib_test.php
  3. +2 −0 enrol/upgrade.txt
@@ -366,13 +366,15 @@ function($favourite) {
$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)) {
if ($course->enablecompletion) {
$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 @@ function($favourite) {
'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 @@ public static function get_users_courses_returns() {
'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 @@ public function test_get_users_courses() {
$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 @@ public function test_get_users_courses() {
$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 @@ public function test_get_users_courses() {
$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 ===

0 comments on commit 6dbe565

Please sign in to comment.