return new external_multiple_structure(
new external_single_structure(
array(
- 'id' => new external_value(PARAM_NUMBER, 'ID of the cohort'),
+ 'id' => new external_value(PARAM_INT, 'ID of the cohort'),
'name' => new external_value(PARAM_RAW, 'cohort name'),
'idnumber' => new external_value(PARAM_RAW, 'cohort idnumber'),
'description' => new external_value(PARAM_RAW, 'cohort description'),
'cohorts' => new external_multiple_structure(
new external_single_structure(
array(
- 'id' => new external_value(PARAM_NUMBER, 'ID of the cohort'),
+ 'id' => new external_value(PARAM_INT, 'ID of the cohort'),
'categorytype' => new external_single_structure(
array(
'type' => new external_value(PARAM_TEXT, 'the name of the field: id (numeric value
core_cohort_external::update_cohorts(array($cohort1));
}
+ /**
+ * Verify handling of 'id' param.
+ */
+ public function test_update_cohorts_invalid_id_param() {
+ $this->resetAfterTest(true);
+ $cohort = self::getDataGenerator()->create_cohort();
+
+ $cohort1 = array(
+ 'id' => 'THIS IS NOT AN ID',
+ 'name' => 'Changed cohort name',
+ 'categorytype' => array('type' => 'id', 'value' => '1'),
+ 'idnumber' => $cohort->idnumber,
+ );
+
+ try {
+ core_cohort_external::update_cohorts(array($cohort1));
+ $this->fail('Expecting invalid_parameter_exception exception, none occured');
+ } catch (invalid_parameter_exception $e1) {
+ $this->assertContains('Invalid external api parameter: the value is "THIS IS NOT AN ID"', $e1->debuginfo);
+ }
+
+ $cohort1['id'] = 9.999; // Also not a valid id of a cohort.
+ try {
+ core_cohort_external::update_cohorts(array($cohort1));
+ $this->fail('Expecting invalid_parameter_exception exception, none occured');
+ } catch (invalid_parameter_exception $e2) {
+ $this->assertContains('Invalid external api parameter: the value is "9.999"', $e2->debuginfo);
+ }
+ }
+
/**
* Test update_cohorts without permission on the dest category.
*/
--- /dev/null
+This files describes API changes in /cohort/ information provided here is intended
+especially for developers.
+
+=== 2.6 ===
+* Webservice core_cohort_update_cohorts was incorrectly specifiying float as the parameter type
+ for cohort id. This field is actually int and input is now reported and processed as such.
+* Webservice core_cohort_get_cohorts was incorrectly specifiying float as the return
+ type for cohort id. The actual return type is int and is now reported as such.
+
'users' => new external_multiple_structure(
new external_single_structure(
array(
- 'id' => new external_value(PARAM_NUMBER, 'ID of the user'),
+ 'id' => new external_value(PARAM_INT, 'ID of the user'),
'username' => new external_value(PARAM_RAW, 'Username', VALUE_OPTIONAL),
'firstname' => new external_value(PARAM_NOTAGS, 'The first name(s) of the user', VALUE_OPTIONAL),
'lastname' => new external_value(PARAM_NOTAGS, 'The family name of the user', VALUE_OPTIONAL),
* Enrolment plugin which supports self enrolment should implement can_self_enrol()
* Enrolment plugin should implement get_enrol_info() to expose instance information
with webservice or external interface.
+* Webservice core_enrol_get_enrolled_users_with_capability was incorrectly specifing
+ float as the return type for user id. int is the actual returned type and is now
+ reported as such.
=== 2.5 ===