diff --git a/lib/externallib.php b/lib/externallib.php index 0c6e44dbc04..abde8a28e47 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -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'), diff --git a/mod/assign/externallib.php b/mod/assign/externallib.php index a7a2e80014e..07de54fbaf6 100644 --- a/mod/assign/externallib.php +++ b/mod/assign/externallib.php @@ -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)') ) ); }