Saltar al contenido principal

Function: setUserRoles()

function setUserRoles(
context,
siteUrl,
courseId,
userId,
roleIds
): Promise<{
changed: string;
roleIds: number[];
}>;

Defined in: areas/participants/enrolments.ts:238

Sets a user's roles in a course, as the participants page's roles column does: gives the roles in roleIds the person may assign, and takes away the others the person may assign. Roles the person can't assign that the user already holds, and those from elsewhere (a category, an enrolment that protects them), stay. Returns the user's roles afterwards, as that column shows them. Throws EnrolmentError with Moodle's reason for a role the person can't assign or a user not enrolled.

Parameters​

ParameterType
contextBrowserContext
siteUrlstring
courseIdnumber
userIdnumber
roleIdsnumber[]

Returns​

Promise<{ changed: string; roleIds: number[]; }>