MDL-58333 enrol: Include course progress in course listing WS
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 23 Mar 2017 07:57:45 +0000 (15:57 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 4 Apr 2017 10:01:43 +0000 (11:01 +0100)
Part of MDL-55611 epic.

enrol/externallib.php
version.php

index 711cc69..588fbf9 100644 (file)
@@ -326,6 +326,11 @@ class core_enrol_external extends external_api {
             $course->fullname = external_format_string($course->fullname, $context->id);
             $course->shortname = external_format_string($course->shortname, $context->id);
 
+            $progress = null;
+            if ($course->enablecompletion) {
+                $progress = \core_completion\progress::get_course_progress_percentage($course);
+            }
+
             $result[] = array(
                 'id' => $course->id,
                 'shortname' => $course->shortname,
@@ -339,7 +344,8 @@ class core_enrol_external extends external_api {
                 'showgrades' => $course->showgrades,
                 'lang' => $course->lang,
                 'enablecompletion' => $course->enablecompletion,
-                'category' => $course->category
+                'category' => $course->category,
+                'progress' => $progress,
             );
         }
 
@@ -369,6 +375,7 @@ class core_enrol_external extends external_api {
                     'enablecompletion' => new external_value(PARAM_BOOL, 'true if completion is enabled, otherwise false',
                                                                 VALUE_OPTIONAL),
                     'category' => new external_value(PARAM_INT, 'course category id', VALUE_OPTIONAL),
+                    'progress' => new external_value(PARAM_FLOAT, 'Progress percentage', VALUE_OPTIONAL),
                 )
             )
         );
index 986976f..d37171e 100644 (file)
@@ -29,7 +29,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$version  = 2017040300.10;              // YYYYMMDD      = weekly release date of this DEV branch.
+$version  = 2017040300.11;              // YYYYMMDD      = weekly release date of this DEV branch.
                                         //         RR    = release increments - 00 in DEV branches.
                                         //           .XX = incremental changes.