Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

Base class for course format plugins

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

Defines 1 class

Defines 10 functions


Class: format_site  - X-Ref

Pseudo course format used for the site main page

get_section_name($section)   X-Ref
Returns the display name of the given section that the course prefers.

param: int|stdClass $section Section object from database or just field section.section
return: Display name that the course format prefers, e.g. "Topic 2"

get_view_url($section, $options = array()   X-Ref
For this fake course referring to the whole site, the site homepage is always returned
regardless of arguments

param: int|stdClass $section
param: array $options
return: null|moodle_url

get_default_blocks()   X-Ref
Returns the list of blocks to be automatically added on the site frontpage when moodle is installed

return: array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT

course_format_options($foreditform = false)   X-Ref
Definitions of the additional options that site uses

param: bool $foreditform
return: array of options

allow_stealth_module_visibility($cm, $section)   X-Ref
Returns whether this course format allows the activity to
have "triple visibility state" - visible always, hidden on course page but available, hidden.

param: stdClass|cm_info $cm course module (may be null if we are displaying a form for adding a module)
param: stdClass|section_info $section section where this module is located or will be added to
return: bool

get_renderer(moodle_page $page)   X-Ref
Returns instance of page renderer used by the site page

param: moodle_page $page the current page
return: renderer_base

get_section_number()   X-Ref
Site format uses only section 1.

return: int

contract_value(array &$dest, array $source, array $option, string $optionname)   X-Ref
'Converts' a value from what is stored in the database into what is used by edit forms.

param: array $dest The destination array
param: array $source The source array
param: array $option The definition structure of the option.
param: string $optionname The name of the option, as provided in the definition.

clean_param_if_not_null($param, string $type = PARAM_RAW)   X-Ref
Cleans the given param, unless it is null.

param: mixed $param The variable we are cleaning.
param: string $type Expected format of param after cleaning.
return: mixed Null if $param is null, otherwise the cleaned value.

expand_value(array &$dest, array $source, array $option, string $optionname)   X-Ref
'Converts' a value from what is used in edit forms into a value(s) to be stored in the database.

param: array $dest The destination array
param: array $source The source array
param: array $option The definition structure of the option.
param: string $optionname The name of the option, as provided in the definition.

Functions that are not part of a class:

course_get_format($courseorid)   X-Ref
Returns an instance of format class (extending course_format) for given course

param: int|stdClass $courseorid either course id or
return: course_format