/** * Returns description of method result value * * @return external_description * @since Moodle 3.1 */ public static function get_participant_returns() { $userdescription = core_user_external::user_description(); $userdescription->default = []; $userdescription->required = VALUE_OPTIONAL; return new external_single_structure(array('id' => new external_value(PARAM_INT, 'ID of the user'), 'fullname' => new external_value(PARAM_NOTAGS, 'The fullname of the user'), 'submitted' => new external_value(PARAM_BOOL, 'have they submitted their assignment'), 'requiregrading' => new external_value(PARAM_BOOL, 'is their submission waiting for grading'), 'blindmarking' => new external_value(PARAM_BOOL, 'is blind marking enabled for this assignment'), 'groupid' => new external_value(PARAM_INT, 'for group assignments this is the group id', VALUE_OPTIONAL), 'groupname' => new external_value(PARAM_NOTAGS, 'for group assignments this is the group name', VALUE_OPTIONAL), 'user' => $userdescription)); }
/** * Test for the type of the user-related properties in mod_assign_external::list_participants_returns(). */ public function test_list_participants_returns_user_property_types() { // Get user properties. $userdesc = core_user_external::user_description(); $this->assertTrue(isset($userdesc->keys)); $userproperties = array_keys($userdesc->keys); // Get returns description for mod_assign_external::list_participants_returns(). $listreturns = mod_assign_external::list_participants_returns(); $this->assertTrue(isset($listreturns->content)); $listreturnsdesc = $listreturns->content->keys; // Iterate over list returns description's keys. foreach ($listreturnsdesc as $key => $desc) { // Check if key exists in user properties and the description has a type attribute. if (in_array($key, $userproperties) && isset($desc->type)) { try { // The core_user::get_property_type() method might throw a coding_exception since // core_user_external::user_description() might contain properties that are not yet included in // core_user's $propertiescache. $propertytype = core_user::get_property_type($key); // Assert that user-related property types match those of the defined in core_user. $this->assertEquals($propertytype, $desc->type); } catch (coding_exception $e) { // All good. } } } }