|
int const | COURSE_CACHE_LOCK_EXPIRY = 180 |
| Maximum time the course cache building lock can be held.
|
|
int const | COURSE_CACHE_LOCK_WAIT = 60 |
| Time to wait for the course cache building lock before throwing an exception.
|
|
|
static array | $cachedfields |
| List of fields from DB table 'course' that are cached in MUC and are always present in course_modinfo::$course. More...
|
|
◆ __construct()
course_modinfo::__construct |
( |
|
$course, |
|
|
|
$userid |
|
) |
| |
Constructs based on course.
Note: This constructor should not usually be called directly. Use get_fast_modinfo($course) instead as this maintains a cache.
- Parameters
-
stdClass | $course | course object, only property id is required. |
int | $userid | User ID |
- Exceptions
-
◆ __empty()
course_modinfo::__empty |
( |
|
$name | ) |
|
Magic method for function empty()
- Parameters
-
- Return values
-
◆ __get()
course_modinfo::__get |
( |
|
$name | ) |
|
Magic method getter.
- Parameters
-
- Return values
-
◆ __isset()
course_modinfo::__isset |
( |
|
$name | ) |
|
Magic method for function isset()
- Parameters
-
- Return values
-
◆ __set()
course_modinfo::__set |
( |
|
$name, |
|
|
|
$value |
|
) |
| |
Magic method setter.
Will display the developer warning when trying to set/overwrite existing property.
- Parameters
-
◆ build_course_cache()
static course_modinfo::build_course_cache |
( |
|
$course | ) |
|
|
static |
Builds and stores in MUC object containing information about course modules and sections together with cached fields from table course.
- Parameters
-
stdClass | $course | object from DB table course. Must have property 'id' but preferably should have all cached fields. |
- Return values
-
stdClass | object with all cached keys of the course plus fields modinfo and sectioncache. The same object is stored in MUC |
- Exceptions
-
moodle_exception | if course is not found (if $course object misses some of the necessary fields it is re-requested from database) |
◆ build_course_section_cache()
static course_modinfo::build_course_section_cache |
( |
|
$course | ) |
|
|
staticprotected |
Builds a list of information about sections on a course to be stored in the course cache.
(Does not include information that is already cached in some other way.)
- Parameters
-
stdClass | $course | Course object (must contain fields |
- Return values
-
array | Information about sections, indexed by section number (not id) |
◆ build_section_cache()
static course_modinfo::build_section_cache |
( |
|
$courseid | ) |
|
|
static |
◆ clear_instance_cache()
static course_modinfo::clear_instance_cache |
( |
|
$courseorid = null | ) |
|
|
static |
◆ get_cm()
course_modinfo::get_cm |
( |
|
$cmid | ) |
|
Obtains a single course-module object (for a course-module that is on this course).
- Parameters
-
- Return values
-
cm_info | Information about that course-module |
- Exceptions
-
◆ get_cms()
course_modinfo::get_cms |
( |
| ) |
|
- Return values
-
cm_info[] | Array from course-module instance to cm_info object within this course, in order of appearance |
◆ get_course()
course_modinfo::get_course |
( |
| ) |
|
Returns course object that was used in the first get_fast_modinfo() call.
It may not contain all fields from DB table {course} but always has at least the following: id,shortname,fullname,format,enablecompletion,groupmode,groupmodeforce,cacherev
- Return values
-
◆ get_course_cache_lock()
static course_modinfo::get_course_cache_lock |
( |
|
$courseid | ) |
|
|
staticprotected |
Gets a lock for rebuilding the cache of a single course.
Caller must release the returned lock.
This is used to ensure that the cache rebuild doesn't happen multiple times in parallel. This function will wait up to 1 minute for the lock to be obtained. If the lock cannot be obtained, it throws an exception.
- Parameters
-
- Return values
-
- Exceptions
-
◆ get_course_id()
course_modinfo::get_course_id |
( |
| ) |
|
◆ get_groups()
course_modinfo::get_groups |
( |
|
$groupingid = 0 | ) |
|
Returns groups that the current user belongs to on the course.
Note: If not already available, this may make a database query.
- Parameters
-
int | $groupingid | Grouping ID or 0 (default) for all groups |
- Return values
-
int[] | Array of int (group id) => int (same group id again); empty array if none |
◆ get_instances()
course_modinfo::get_instances |
( |
| ) |
|
Obtains all module instances on this course.
- Return values
-
cm_info[][] | Array from module name => array from instance id => cm_info |
◆ get_instances_of()
course_modinfo::get_instances_of |
( |
|
$modname | ) |
|
Obtains all instances of a particular module on this course.
- Parameters
-
$modname | Name of module (not full frankenstyle) e.g. 'label' |
- Return values
-
cm_info[] | Array from instance id => cm_info for modules on this course; empty if none |
◆ get_section_info()
course_modinfo::get_section_info |
( |
|
$sectionnumber, |
|
|
|
$strictness = IGNORE_MISSING |
|
) |
| |
Gets data about specific numbered section.
- Parameters
-
int | $sectionnumber | Number (not id) of section |
int | $strictness | Use MUST_EXIST to throw exception if it doesn't |
- Return values
-
section_info | Information for numbered section or null if not found |
◆ get_section_info_all()
course_modinfo::get_section_info_all |
( |
| ) |
|
Gets all sections as array from section number => data about section.
- Return values
-
section_info[] | Array of section_info objects organised by section number |
◆ get_sections()
course_modinfo::get_sections |
( |
| ) |
|
- Return values
-
array | Array from section number (e.g. 0) to array of course-module IDs in that section; this only includes sections that contain at least one course-module |
◆ get_used_module_names()
course_modinfo::get_used_module_names |
( |
|
$plural = false | ) |
|
Returns array of localised human-readable module names used in this course.
- Parameters
-
bool | $plural | if true returns the plural form of modules names |
- Return values
-
◆ get_user_id()
course_modinfo::get_user_id |
( |
| ) |
|
◆ inner_build_course_cache()
static course_modinfo::inner_build_course_cache |
( |
|
$course, |
|
|
core\lock\lock |
$lock |
|
) |
| |
|
staticprotected |
Called to build course cache when there is already a lock obtained.
- Parameters
-
stdClass | $course | object from DB table course |
core::lock::lock | $lock | Lock object - not actually used, just there to indicate you have a lock |
- Return values
-
stdClass | Course object that has been stored in MUC |
◆ instance()
static course_modinfo::instance |
( |
|
$courseorid, |
|
|
|
$userid = 0 |
|
) |
| |
|
static |
Returns the instance of course_modinfo for the specified course and specified user.
This function uses static cache for the retrieved instances. The cache size is limited by MAX_MODINFO_CACHE_SIZE. If instance is not found in the static cache or it was created for another user or the cacherev validation failed - a new instance is constructed and returned.
Used in get_fast_modinfo()
- Parameters
-
int | stdClass | $courseorid | object from DB table 'course' (must have field 'id' and recommended to have field 'cacherev') or just a course id |
int | $userid | User id to populate 'availble' and 'uservisible' attributes of modules and sections. Set to 0 for current user (default). Set to -1 to avoid calculation of dynamic user-depended data. |
- Return values
-
◆ $cacheaccessed
float [] course_modinfo::$cacheaccessed = array() |
|
staticprotected |
Timestamps (microtime) when the course_modinfo instances were last accessed.
It is used to remove the least recent accessed instances when static cache is full
◆ $cachedfields
array course_modinfo::$cachedfields |
|
static |
Initial value:= array('shortname', 'fullname', 'format',
'enablecompletion', 'groupmode', 'groupmodeforce', 'cacherev')
List of fields from DB table 'course' that are cached in MUC and are always present in course_modinfo::$course.
◆ $instancecache
The documentation for this class was generated from the following file: