Permalink
Browse files

MDL-37143 External_warnings: developer should be able to modify the i…

…tem/itemid/errorcode description
  • Loading branch information...
1 parent 4bd6f71 commit 8118dbd02febd66fd14901f912327a7d8764bef4 @mouneyrac mouneyrac committed Dec 13, 2012
Showing with 11 additions and 7 deletions.
  1. +5 −5 lib/externallib.php
  2. +6 −2 mod/assign/externallib.php
View
@@ -598,15 +598,15 @@ class external_warnings extends external_multiple_structure {
*
* @since Moodle 2.3
*/
- public function __construct() {
+ public function __construct($itemdesc = 'item', $itemiddesc = 'item id',
+ $warningcodedesc = 'the warning code can be used by the client app to implement specific behaviour') {
parent::__construct(
new external_single_structure(
array(
- 'item' => new external_value(PARAM_TEXT, 'item', VALUE_OPTIONAL),
- 'itemid' => new external_value(PARAM_INT, 'item id', VALUE_OPTIONAL),
- 'warningcode' => new external_value(PARAM_ALPHANUM,
- 'the warning code can be used by the client app to implement specific behaviour'),
+ 'item' => new external_value(PARAM_TEXT, $itemdesc, VALUE_OPTIONAL),
+ 'itemid' => new external_value(PARAM_INT, $itemiddesc, VALUE_OPTIONAL),
+ 'warningcode' => new external_value(PARAM_ALPHANUM, $warningcodedesc),
'message' => new external_value(PARAM_TEXT,
'untranslated english message to explain the warning')
), 'warning'),
@@ -184,7 +184,9 @@ public static function get_grades_returns() {
return new external_single_structure(
array(
'assignments' => new external_multiple_structure(self::assign_grades(), 'list of assignment grade information'),
- 'warnings' => new external_warnings()
+ 'warnings' => new external_warnings('item is always \'assignment\'',
+ 'when errorcode is 3 then itemid is an assignment id. When errorcode is 1, itemid is a course module instance id',
+ 'errorcode can be 3 (no grades found) or 1 (no permission to get grades)')
)
);
}
@@ -425,7 +427,9 @@ public static function get_assignments_returns() {
return new external_single_structure(
array(
'courses' => new external_multiple_structure(self::get_assignments_course_structure(), 'list of courses'),
- 'warnings' => new external_warnings()
+ 'warnings' => new external_warnings('item can be \'course\' (errorcode 1 or 2) or \'module\' (errorcode 1)',
+ 'When item is a course then itemid is a course id. When the item is a module then itemid is a module id',
+ 'errorcode can be 1 (no access rights) or 2 (not enrolled or no permissions)')
)
);
}

0 comments on commit 8118dbd

Please sign in to comment.