course_support
class course_support
| internal |
Utility functions for Moodle courses.
Methods
Retrieves a course entity by its ID.
Retrieves visible course options as an options list [courseid => label].
Retrieves course options indexed by context ID.
Retrieves visible course modules within a specific section.
Retrieves courses belonging to a category.
Retrieves a course entity by its context ID.
Retrieves the course context for a given course ID.
Retrieves the URL to view a course.
Checks if a course is currently visible.
Retrieves all course modules for a specific course.
Retrieves completion information for a specific course.
Retrieves the count of enrolled users in a course.
Retrieves the category entity for a specific course.
Checks if a specific user is enrolled in a course.
Retrieves the course format identifier (e.g., 'topics', 'weeks', 'social').
Retrieves the URL for the course group view tool.
Details
at line 48
static course|null
get_course(int|null $courseid, int $strictness = IGNORE_MISSING)
Retrieves a course entity by its ID.
at line 75
static array
get_courses_options()
Retrieves visible course options as an options list [courseid => label].
Uses a single query with JOIN on categories to reduce overhead and avoid multiple calls to core_course_category::get().
at line 105
static array
get_course_with_contextid_options()
Retrieves course options indexed by context ID.
at line 127
static array
get_cms_by_section(int $courseid, int $sectionnumber)
Retrieves visible course modules within a specific section.
at line 180
static array
get_courses_from_categoryid(int $categoryid, bool $includesub = true)
Retrieves courses belonging to a category.
at line 218
static course|null
get_course_by_contextid(int $contextid, int $strictness = IGNORE_MISSING)
Retrieves a course entity by its context ID.
This is useful when you have a context ID and need to find the associated course.
at line 257
static context_course|null
get_course_context(int $courseid)
Retrieves the course context for a given course ID.
at line 281
static moodle_url
get_course_url(int $courseid, int|null $sectionid = null, string|null $anchor = null)
Retrieves the URL to view a course.
at line 305
static bool
is_course_visible(int $courseid)
Checks if a course is currently visible.
at line 324
static array
get_course_modules(int $courseid, string|null $modname = null)
Retrieves all course modules for a specific course.
at line 357
static completion_info|null
get_course_completion_info(int $courseid)
Retrieves completion information for a specific course.
at line 383
static int
get_enrolled_users_count(int $courseid, bool|null $activeonly = true, int|null $groupid = null)
Retrieves the count of enrolled users in a course.
at line 433
static category|null
get_course_category(int $courseid)
Retrieves the category entity for a specific course.
at line 462
static bool
is_user_enrolled(int $courseid, int $userid)
Checks if a specific user is enrolled in a course.
at line 486
static string|null
get_course_format(int $courseid)
Retrieves the course format identifier (e.g., 'topics', 'weeks', 'social').
at line 502
static moodle_url
course_group_viewurl()
Retrieves the URL for the course group view tool.