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
| Parameter | Type |
|---|---|
context | BrowserContext |
siteUrl | string |
courseId | number |
userId | number |
roleIds | number[] |
Returns
Promise<{
changed: string;
roleIds: number[];
}>