diff --git a/course/externallib.php b/course/externallib.php index 8b9aeb8db6d..73370acc2db 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -2248,6 +2248,7 @@ class core_course_external extends external_api { $coursereturns['overviewfiles'] = $files; $coursereturns['contacts'] = $coursecontacts; $coursereturns['enrollmentmethods'] = $enroltypes; + $coursereturns['sortorder'] = $course->sortorder; return $coursereturns; } @@ -2361,6 +2362,7 @@ class core_course_external extends external_api { 'shortname' => new external_value(PARAM_TEXT, 'course short name'), 'categoryid' => new external_value(PARAM_INT, 'category id'), 'categoryname' => new external_value(PARAM_TEXT, 'category name'), + 'sortorder' => new external_value(PARAM_INT, 'Sort order in the category', VALUE_OPTIONAL), 'summary' => new external_value(PARAM_RAW, 'summary'), 'summaryformat' => new external_format_value('summary'), 'summaryfiles' => new external_files('summary files in the summary field', VALUE_OPTIONAL), @@ -2397,7 +2399,6 @@ class core_course_external extends external_api { 'completionnotify' => new external_value(PARAM_INT, '1: yes 0: no', VALUE_OPTIONAL), 'lang' => new external_value(PARAM_SAFEDIR, 'Forced course language', VALUE_OPTIONAL), 'theme' => new external_value(PARAM_PLUGIN, 'Fame of the forced theme', VALUE_OPTIONAL), - 'sortorder' => new external_value(PARAM_INT, 'Sort order in the category', VALUE_OPTIONAL), 'marker' => new external_value(PARAM_INT, 'Current course marker', VALUE_OPTIONAL), 'legacyfiles' => new external_value(PARAM_INT, 'If legacy files are enabled', VALUE_OPTIONAL), 'calendartype' => new external_value(PARAM_PLUGIN, 'Calendar type', VALUE_OPTIONAL), @@ -3002,7 +3003,7 @@ class core_course_external extends external_api { // Return information for any user that can access the course. $coursefields = array('format', 'showgrades', 'newsitems', 'startdate', 'maxbytes', 'showreports', 'visible', 'groupmode', 'groupmodeforce', 'defaultgroupingid', 'enablecompletion', 'completionnotify', 'lang', 'theme', - 'sortorder', 'marker'); + 'marker'); // Course filters. $coursesdata[$course->id]['filters'] = filter_get_available_in_context($context); diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index cc232a00d8f..9616ca2bf15 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -2081,14 +2081,14 @@ class core_course_externallib_testcase extends externallib_advanced_testcase { $result = external_api::clean_returnvalue(core_course_external::get_courses_by_field_returns(), $result); $this->assertCount(2, $result['courses']); $this->assertCount(29, $result['courses'][0]); // Site course. - $this->assertCount(12, $result['courses'][1]); // Only public information, not enrolled. + $this->assertCount(13, $result['courses'][1]); // Only public information, not enrolled. $result = core_course_external::get_courses_by_field('id', $course1->id); $result = external_api::clean_returnvalue(core_course_external::get_courses_by_field_returns(), $result); $this->assertCount(1, $result['courses']); $this->assertEquals($course1->id, $result['courses'][0]['id']); // Expect to receive all the files that a authenticated can see. - $this->assertCount(12, $result['courses'][0]); + $this->assertCount(13, $result['courses'][0]); // Course 2 is not visible. $result = core_course_external::get_courses_by_field('id', $course2->id); diff --git a/lib/upgrade.txt b/lib/upgrade.txt index dace105d897..7a342024f81 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -53,6 +53,7 @@ information provided here is intended especially for developers. * get_user_capability_course() now has an additional parameter 'limit'. This can be used to return a set number of records with the submitted capability. The parameter 'fieldsexceptid' will now accept context fields which can be used for preloading. * The caching option 'immutable' has been added to send_stored_file() and send_file(). +* Webservices core_course_search_courses and core_course_get_courses_by_field will always return the sortorder field. === 3.2 ===