Commit ef83fc2a authored by Juan Leyva's avatar Juan Leyva
Browse files

MDL-58659 course: Add missing enddate field in get_courses_by_field

parent 6d14355c
......@@ -2398,6 +2398,7 @@ class core_course_external extends external_api {
'showgrades' => new external_value(PARAM_INT, '1 if grades are shown, otherwise 0', VALUE_OPTIONAL),
'newsitems' => new external_value(PARAM_INT, 'Number of recent items appearing on the course page', VALUE_OPTIONAL),
'startdate' => new external_value(PARAM_INT, 'Timestamp when the course start', VALUE_OPTIONAL),
'enddate' => new external_value(PARAM_INT, 'Timestamp when the course end', VALUE_OPTIONAL),
'maxbytes' => new external_value(PARAM_INT, 'Largest size of file that can be uploaded into', VALUE_OPTIONAL),
'showreports' => new external_value(PARAM_INT, 'Are activity report shown (yes = 1, no =0)', VALUE_OPTIONAL),
'visible' => new external_value(PARAM_INT, '1: available to student, 0:not available', VALUE_OPTIONAL),
......@@ -3025,7 +3026,7 @@ class core_course_external extends external_api {
continue;
}
// Return information for any user that can access the course.
$coursefields = array('format', 'showgrades', 'newsitems', 'startdate', 'maxbytes', 'showreports', 'visible',
$coursefields = array('format', 'showgrades', 'newsitems', 'startdate', 'enddate', 'maxbytes', 'showreports', 'visible',
'groupmode', 'groupmodeforce', 'defaultgroupingid', 'enablecompletion', 'completionnotify', 'lang', 'theme',
'marker');
......
......@@ -2001,16 +2001,16 @@ 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(3, $result['courses']);
// Expect to receive all the fields.
$this->assertCount(36, $result['courses'][0]);
$this->assertCount(36, $result['courses'][1]);
$this->assertCount(36, $result['courses'][2]);
$this->assertCount(37, $result['courses'][0]);
$this->assertCount(37, $result['courses'][1]);
$this->assertCount(37, $result['courses'][2]);
$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 fields.
$this->assertCount(36, $result['courses'][0]);
$this->assertCount(37, $result['courses'][0]);
$result = core_course_external::get_courses_by_field('id', $course2->id);
$result = external_api::clean_returnvalue(core_course_external::get_courses_by_field_returns(), $result);
......@@ -2052,15 +2052,15 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$result = core_course_external::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]);
$this->assertCount(29, $result['courses'][1]);
$this->assertCount(30, $result['courses'][0]);
$this->assertCount(30, $result['courses'][1]);
$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 student can see.
$this->assertCount(29, $result['courses'][0]);
$this->assertCount(30, $result['courses'][0]);
// Check default filters.
$filters = $result['courses'][0]['filters'];
......@@ -2105,7 +2105,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$result = core_course_external::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(30, $result['courses'][0]); // Site course.
$this->assertCount(13, $result['courses'][1]); // Only public information, not enrolled.
$result = core_course_external::get_courses_by_field('id', $course1->id);
......
......@@ -4,6 +4,7 @@ information provided here is intended especially for developers.
=== 3.3 ===
* External function core_course_external::get_courses_by_field now returns the course filters list and status.
* External function core_course_external::get_courses_by_field now returns the end date of the course.
* External function core_course_external::get_course_contents now return the following additional file fields:
- mimetype (the file mime type)
- isexternalfile (if is a file reference to a external repository)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment