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]

Course format class to allow plugins developed for Moodle 2.3 to work in the new API

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

Defines 1 class


Class: format_legacy  - X-Ref

Course format class to allow plugins developed for Moodle 2.3 to work in the new API

uses_sections()   X-Ref
Returns true if this course format uses sections

This function calls function callback_FORMATNAME_uses_sections() if it exists

return: bool

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

This function calls function callback_FORMATNAME_get_section_name() if it exists

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

get_view_url($section, $options = array()   X-Ref
The URL to use for the specified course (with section)

This function calls function callback_FORMATNAME_get_section_url() if it exists

param: int|stdClass $section Section object from database or just field course_sections.section
param: array $options options for view URL. At the moment core uses:
return: null|moodle_url

supports_ajax()   X-Ref
Returns the information about the ajax support in the given source format

This function calls function callback_FORMATNAME_ajax_support() if it exists

The returned object's property (boolean)capable indicates that
the course format supports Moodle course ajax features.

return: stdClass

extend_course_navigation($navigation, navigation_node $node)   X-Ref
Loads all of the course sections into the navigation

First this function calls callback_FORMATNAME_display_content() if it exists to check
if the navigation should be extended at all

Then it calls function callback_FORMATNAME_load_content() if it exists to actually extend
navigation

By default the parent method is called

param: global_navigation $navigation
param: navigation_node $node The course node within the navigation

ajax_section_move()   X-Ref
Custom action after section has been moved in AJAX mode

Used in course/rest.php

This function calls function callback_FORMATNAME_ajax_section_move() if it exists

return: array This will be passed in ajax respose

get_default_blocks()   X-Ref
Returns the list of blocks to be automatically added for the newly created course

This function checks the existence of the file config.php in the course format folder.
If file exists and contains the code
$format['defaultblocks'] = 'leftblock1,leftblock2:rightblock1,rightblock2';
these blocks are used, otherwise parent function is called

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 this course format uses for course

By default course formats have the options that existed in Moodle 2.3:
- coursedisplay
- numsections
- hiddensections

param: bool $foreditform
return: array of options

update_course_format_options($data, $oldcourse = null)   X-Ref
Updates format options for a course

Legacy course formats may assume that course format options
('coursedisplay', 'numsections' and 'hiddensections') are shared between formats.
Therefore we make sure to copy them from the previous format

param: stdClass|array $data return value from {@link moodleform::get_data()} or array with data
param: stdClass $oldcourse if this function is called from {@link update_course()}
return: bool whether there were any changes to the options values