MDL-37143 External_warnings: developer should be able to modify the item/itemid/errorcode description

This commit is contained in:
Jerome Mouneyrac 2012-12-13 11:15:50 +08:00
parent 4bd6f71bad
commit 8118dbd02f
2 changed files with 11 additions and 7 deletions

View File

@ -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'),

View File

@ -184,7 +184,9 @@ class mod_assign_external extends external_api {
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 @@ class mod_assign_external extends external_api {
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)')
)
);
}