* @throws invalid_parameter_exception
*/
public static function get_enrolled_users_by_cmid(int $cmid) {
+ global $PAGE;
$warnings = [];
[
$enrolledusers = get_enrolled_users($coursecontext);
- $users = array_map(function ($user) {
+ $users = array_map(function ($user) use ($PAGE) {
$user->fullname = fullname($user);
+ $userpicture = new user_picture($user);
+ $userpicture->size = 1;
+ $user->profileimage = $userpicture->get_url($PAGE)->out(false);
return $user;
}, $enrolledusers);
sort($users);
public static function user_description() {
$userfields = array(
'id' => new external_value(core_user::get_property_type('id'), 'ID of the user'),
+ 'profileimage' => new external_value(PARAM_URL, 'The location of the users larger image', VALUE_OPTIONAL),
'fullname' => new external_value(PARAM_TEXT, 'The full name of the user', VALUE_OPTIONAL),
'firstname' => new external_value(
core_user::get_property_type('firstname'),
* Test get enrolled users by cmid function.
*/
public function test_get_enrolled_users_by_cmid() {
+ global $PAGE;
$this->resetAfterTest(true);
$user1 = self::getDataGenerator()->create_user();
$user2 = self::getDataGenerator()->create_user();
+ $user1picture = new user_picture($user1);
+ $user1picture->size = 1;
+ $user1->profileimage = $user1picture->get_url($PAGE)->out(false);
+
+ $user2picture = new user_picture($user2);
+ $user2picture->size = 1;
+ $user2->profileimage = $user2picture->get_url($PAGE)->out(false);
+
// Set the first created user to the test user.
self::setUser($user1);
'fullname' => fullname($user1),
'firstname' => $user1->firstname,
'lastname' => $user1->lastname,
+ 'profileimage' => $user1->profileimage,
];
$expectedusers['users'][1] = [
'id' => $user2->id,
'fullname' => fullname($user2),
'firstname' => $user2->firstname,
'lastname' => $user2->lastname,
+ 'profileimage' => $user2->profileimage,
];
// Test getting the users in a given context.