Commit 01c26702 authored by Juan Leyva's avatar Juan Leyva
Browse files

MDL-58659 enroll: Add start and end date fields required by overview

Those fields are required to display the courses overview for final
users.
parent ef83fc2a
...@@ -300,7 +300,7 @@ class core_enrol_external extends external_api { ...@@ -300,7 +300,7 @@ class core_enrol_external extends external_api {
$params = self::validate_parameters(self::get_users_courses_parameters(), array('userid'=>$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, $courses = enrol_get_users_courses($params['userid'], true, 'id, shortname, fullname, idnumber, visible,
summary, summaryformat, format, showgrades, lang, enablecompletion, category'); summary, summaryformat, format, showgrades, lang, enablecompletion, category, startdate, enddate');
$result = array(); $result = array();
foreach ($courses as $course) { foreach ($courses as $course) {
...@@ -346,6 +346,8 @@ class core_enrol_external extends external_api { ...@@ -346,6 +346,8 @@ class core_enrol_external extends external_api {
'enablecompletion' => $course->enablecompletion, 'enablecompletion' => $course->enablecompletion,
'category' => $course->category, 'category' => $course->category,
'progress' => $progress, 'progress' => $progress,
'startdate' => $course->startdate,
'enddate' => $course->enddate,
); );
} }
...@@ -376,6 +378,8 @@ class core_enrol_external extends external_api { ...@@ -376,6 +378,8 @@ class core_enrol_external extends external_api {
VALUE_OPTIONAL), VALUE_OPTIONAL),
'category' => new external_value(PARAM_INT, 'course category id', VALUE_OPTIONAL), 'category' => new external_value(PARAM_INT, 'course category id', VALUE_OPTIONAL),
'progress' => new external_value(PARAM_FLOAT, 'Progress percentage', VALUE_OPTIONAL), 'progress' => new external_value(PARAM_FLOAT, 'Progress percentage', 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),
) )
) )
); );
......
...@@ -363,6 +363,7 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase { ...@@ -363,6 +363,7 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$timenow = time();
$coursedata1 = array( $coursedata1 = array(
'fullname' => '<b>Course 1</b>', // Adding tags here to check that external_format_string works. 'fullname' => '<b>Course 1</b>', // Adding tags here to check that external_format_string works.
'shortname' => '<b>Course 1</b>', // Adding tags here to check that external_format_string works. 'shortname' => '<b>Course 1</b>', // Adding tags here to check that external_format_string works.
...@@ -370,7 +371,9 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase { ...@@ -370,7 +371,9 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
'summaryformat' => FORMAT_MOODLE, 'summaryformat' => FORMAT_MOODLE,
'lang' => 'en', 'lang' => 'en',
'enablecompletion' => true, 'enablecompletion' => true,
'showgrades' => true 'showgrades' => true,
'startdate' => $timenow,
'enddate' => $timenow + WEEKSECS
); );
$course1 = self::getDataGenerator()->create_course($coursedata1); $course1 = self::getDataGenerator()->create_course($coursedata1);
......
This files describes API changes in /enrol/* - plugins, This files describes API changes in /enrol/* - plugins,
information provided here is intended especially for developers. information provided here is intended especially for developers.
=== 3.3 ===
* External function core_enrol_external::get_users_courses now return the user progress, start and the end course dates.
=== 3.2 === === 3.2 ===
* External function core_enrol_external::get_users_courses now return the category id as an additional optional field. * External function core_enrol_external::get_users_courses now return the category id as an additional optional field.
......
Supports Markdown
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