Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

Contains class core_course_list_element

Copyright: 2018 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 481 lines (17 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: core_course_list_element  - X-Ref

Class to store information about one course in a list of courses

Not all information may be retrieved when object is created but
it will be retrieved on demand when appropriate property or method is
called.

Instances of this class are usually returned by functions
{@link core_course_category::search_courses()}
and
{@link core_course_category::get_courses()}

__construct(stdClass $record)   X-Ref
Creates an instance of the class from record

param: stdClass $record except fields from course table it may contain

has_summary()   X-Ref
Indicates if the course has non-empty summary field

return: bool

has_course_contacts()   X-Ref
Indicates if the course have course contacts to display

return: bool

get_course_contacts()   X-Ref
Returns list of course contacts (usually teachers) to display in course link

Roles to display are set up in $CFG->coursecontact

The result is the list of users where user id is the key and the value
is an array with elements:
- 'user' - object containing basic user information
- 'role' - object containing basic role information (id, name, shortname, coursealias)
- 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS)
- 'username' => fullname($user, $canviewfullnames)

return: array

get_custom_fields()   X-Ref
Returns custom fields data for this course

return: \core_customfield\data_controller[]

has_custom_fields()   X-Ref
Does this course have custom fields

return: bool

has_course_overviewfiles()   X-Ref
Checks if course has any associated overview files

return: bool

get_course_overviewfiles()   X-Ref
Returns all course overview files

return: array array of stored_file objects

__isset($name)   X-Ref
Magic method to check if property is set

param: string $name
return: bool

__get($name)   X-Ref
Magic method to get a course property

Returns any field from table course (retrieves it from DB if it was not retrieved before)

param: string $name
return: mixed

__unset($name)   X-Ref
All properties are read only, sorry.

param: string $name

__set($name, $value)   X-Ref
Magic setter method, we do not want anybody to modify properties from the outside

param: string $name
param: mixed $value

getIterator()   X-Ref
Create an iterator because magic vars can't be seen by 'foreach'.
Exclude context fields

Implementing method from interface IteratorAggregate

return: ArrayIterator

get_formatted_name()   X-Ref
Returns the name of this course as it should be displayed within a list.

return: string

get_formatted_fullname()   X-Ref
Returns the formatted fullname for this course.

return: string

get_formatted_shortname()   X-Ref
Returns the formatted shortname for this course.

return: string

can_access()   X-Ref
Returns true if the current user can access this course.

return: bool

can_edit()   X-Ref
Returns true if the user can edit this courses settings.

Note: this function does not check that the current user can access the course.
To do that please call require_login with the course, or if not possible call
{@link core_course_list_element::can_access()}

return: bool

can_change_visibility()   X-Ref
Returns true if the user can change the visibility of this course.

Note: this function does not check that the current user can access the course.
To do that please call require_login with the course, or if not possible call
{@link core_course_list_element::can_access()}

return: bool

get_context()   X-Ref
Returns the context for this course.

return: context_course

can_review_enrolments()   X-Ref
Returns true if the current user can review enrolments for this course.

Note: this function does not check that the current user can access the course.
To do that please call require_login with the course, or if not possible call
{@link core_course_list_element::can_access()}

return: bool

can_delete()   X-Ref
Returns true if the current user can delete this course.

Note: this function does not check that the current user can access the course.
To do that please call require_login with the course, or if not possible call
{@link core_course_list_element::can_access()}

return: bool

can_backup()   X-Ref
Returns true if the current user can backup this course.

Note: this function does not check that the current user can access the course.
To do that please call require_login with the course, or if not possible call
{@link core_course_list_element::can_access()}

return: bool

can_restore()   X-Ref
Returns true if the current user can restore this course.

Note: this function does not check that the current user can access the course.
To do that please call require_login with the course, or if not possible call
{@link core_course_list_element::can_access()}

return: bool