Skip to main content

Function: enrolUsers()

function enrolUsers(
context,
siteUrl,
courseId,
userIds,
__namedParameters?
): Promise<{
changed: string;
count: number;
roleId?: number;
}>;

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

Enrols users in a course by manual enrolment, as the participants page's "Enrol users" dialog does: with roleId or the enrolment's default role, from start (now, unless given) until end (the enrolment's default duration, unless given). Users already enrolled keep their enrolment, with the new dates. Throws EnrolmentError with Moodle's reason when it refuses (a role the person can't assign, no manual enrolment).

Parameters​

ParameterType
contextBrowserContext
siteUrlstring
courseIdnumber
userIdsnumber[]
__namedParameters{ end?: Date; roleId?: number; start?: Date; }
__namedParameters.end?Date
__namedParameters.roleId?number
__namedParameters.start?Date

Returns​

Promise<{ changed: string; count: number; roleId?: number; }>