Skip to content

Commit

Permalink
MDL-57990 course: Add sortorder as public field
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Mar 3, 2017
1 parent 3c45d26 commit fb41d2f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions course/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,7 @@ protected static function get_course_public_information(course_in_list $course,
$coursereturns['overviewfiles'] = $files;
$coursereturns['contacts'] = $coursecontacts;
$coursereturns['enrollmentmethods'] = $enroltypes;
$coursereturns['sortorder'] = $course->sortorder;
return $coursereturns;
}

Expand Down Expand Up @@ -2361,6 +2362,7 @@ protected static function get_course_structure($onlypublicdata = true) {
'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),
Expand Down Expand Up @@ -2397,7 +2399,6 @@ protected static function get_course_structure($onlypublicdata = true) {
'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),
Expand Down Expand Up @@ -3002,7 +3003,7 @@ public static function get_courses_by_field($field = '', $value = '') {
// 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);
Expand Down
4 changes: 2 additions & 2 deletions course/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2081,14 +2081,14 @@ public function test_get_courses_by_field() {
$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);
Expand Down
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===

Expand Down

0 comments on commit fb41d2f

Please sign in to comment.