Skip to content

Commit

Permalink
MDL-54800 core_enrol: Return category id in WS get_users_courses
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Jun 15, 2016
1 parent a0a6367 commit 27c7ed0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 18 additions & 7 deletions enrol/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public static function get_users_courses($userid) {
$params = self::validate_parameters(self::get_users_courses_parameters(), array('userid'=>$userid));

$courses = enrol_get_users_courses($params['userid'], true, 'id, shortname, fullname, idnumber, visible,
summary, summaryformat, format, showgrades, lang, enablecompletion');
summary, summaryformat, format, showgrades, lang, enablecompletion, category');
$result = array();

foreach ($courses as $course) {
Expand All @@ -324,11 +324,21 @@ public static function get_users_courses($userid) {
list($course->summary, $course->summaryformat) =
external_format_text($course->summary, $course->summaryformat, $context->id, 'course', 'summary', null);

$result[] = array('id' => $course->id, 'shortname' => $course->shortname, 'fullname' => $course->fullname,
'idnumber' => $course->idnumber, 'visible' => $course->visible, 'enrolledusercount' => $enrolledusercount,
'summary' => $course->summary, 'summaryformat' => $course->summaryformat, 'format' => $course->format,
'showgrades' => $course->showgrades, 'lang' => $course->lang, 'enablecompletion' => $course->enablecompletion
);
$result[] = array(
'id' => $course->id,
'shortname' => $course->shortname,
'fullname' => $course->fullname,
'idnumber' => $course->idnumber,
'visible' => $course->visible,
'enrolledusercount' => $enrolledusercount,
'summary' => $course->summary,
'summaryformat' => $course->summaryformat,
'format' => $course->format,
'showgrades' => $course->showgrades,
'lang' => $course->lang,
'enablecompletion' => $course->enablecompletion,
'category' => $course->category
);
}

return $result;
Expand All @@ -355,7 +365,8 @@ public static function get_users_courses_returns() {
'showgrades' => new external_value(PARAM_BOOL, 'true if grades are shown, otherwise false', VALUE_OPTIONAL),
'lang' => new external_value(PARAM_LANG, 'forced course language', VALUE_OPTIONAL),
'enablecompletion' => new external_value(PARAM_BOOL, 'true if completion is enabled, otherwise false',
VALUE_OPTIONAL)
VALUE_OPTIONAL),
'category' => new external_value(PARAM_INT, 'course category id', VALUE_OPTIONAL),
)
)
);
Expand Down
4 changes: 4 additions & 0 deletions enrol/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
This files describes API changes in /enrol/* - plugins,
information provided here is intended especially for developers.

=== 3.2 ===

* External function core_enrol_external::get_users_courses now return the category id as an additional optional field.

=== 3.1 ===

* core_enrol_external::get_enrolled_users now supports two additional parameters for ordering: sortby and sortdirection.
Expand Down

0 comments on commit 27c7ed0

Please sign in to comment.