role_support
class role_support
| internal |
Utility functions for Moodle roles and assignments.
Methods
static array
get_role_options(context|null $coursecontext = null, array $excluderoles = ['guest'])
Retrieves assignable roles as an options list [roleid => label].
static array
get_roles_options()
Retrieves roles options for the current course.
static bool
isteacher(int $userid)
Checks if a user has a teacher role in any enrolled course.
static bool|stdClass
get_teacher(int $courseid)
Retrieves a teacher user record for a specific course.
Details
at line 44
static array
get_role_options(context|null $coursecontext = null, array $excluderoles = ['guest'])
Retrieves assignable roles as an options list [roleid => label].
at line 68
static array
get_roles_options()
Retrieves roles options for the current course.
at line 86
static bool
isteacher(int $userid)
Checks if a user has a teacher role in any enrolled course.
at line 123
static bool|stdClass
get_teacher(int $courseid)
Retrieves a teacher user record for a specific course.
Tries to find role by shortname prioritizing 'editingteacher' and, if not found, falls back to 'teacher'. Avoids using numeric indexes from get_all_roles() as they can vary between installations.