diff --git a/docs/apis/plugintypes/format/index.md b/docs/apis/plugintypes/format/index.md index 37dbd3c82..def14dca9 100644 --- a/docs/apis/plugintypes/format/index.md +++ b/docs/apis/plugintypes/format/index.md @@ -237,7 +237,7 @@ Webservices expect course format options to be passed in additional entities but | `core_courseformat\base` Overridable method | Description | |---|---| -| `course_format_options()` | By overriding this method course format specifies which additional options it has for course. It can also be used to inject linear navigation defaults using `\core_courseformat\local\linearnavigationsettings::get_course_format_options_default()`. | +| `course_format_options()` | By overriding this method course format specifies which additional options it has for course | | `section_format_options()` | By overriding this method course format specifies which additional options it has for course section. Note that since section information is cached you may want to cache some additional options as well. See PHPdocs for more information | | `get_format_options()` | (usually no need to override) low level function to retrieve course format options values. It is more convenient to use methods get_course() and get_section() | | `create_edit_form_elements()` | This function is called to alter course edit form and standard section edit form. The default implementation creates simple form elements for each option defined in either `course_format_options()` or `section_format_options()`. Overwrite it if you want to have more comprehensive form elements or if you do not want options to appear in edit forms, etc. | diff --git a/docs/apis/plugintypes/format/linear_navigation.md b/docs/apis/plugintypes/format/linear_navigation.md index 020916e6a..7215afb1f 100644 --- a/docs/apis/plugintypes/format/linear_navigation.md +++ b/docs/apis/plugintypes/format/linear_navigation.md @@ -34,70 +34,25 @@ class format_mycustomformat extends \core_courseformat\base { } ``` -## Adding format-level configuration +## Adding an administration setting -If your course format requires configuration at the course settings level (similar to how `format_topics` and `format_weeks` handle it), you should integrate it into your format's native settings framework (`course_format_options`). - -```php title="course/format/mycustomformat/lib.php" - /** - * Define the format options for a course. - * - * @param bool $foreditform True if it's being requested for the course edit form. - * @return array Array of options. - */ - public function course_format_options($foreditform = false) { - static $courseformatoptions = false; - // Initialise the course format options array if it hasn't been done yet with the default values. - if ($courseformatoptions === false) { - // Get course format's settings. - $courseformatoptions = []; - - // Add linear navigation settings if enabled for the format. - $courseformatoptions = array_merge( - \core_courseformat\local\linearnavigationsettings::get_course_format_options_default(self::get_format()), - $courseformatoptions, - ); - - } - - if ($foreditform) { - // Get the edit form options for the format. - $courseformatoptionsedit = []; - - // Add course format settings. - - // Append your format's explicit linear navigation setting override if desired, - // or rely on the core 'enablelinearnav' setting configuration. - $courseformatoptions = array_merge_recursive( - $courseformatoptionsedit, - \core_courseformat\local\linearnavigationsettings::get_course_format_options_edit_form(self::get_format()), - ); - } - return $courseformatoptions; - } -``` - -:::info[Adding site-wide administration settings] - -To allow administrators to enable, disable, or define the default state for linear navigation within your custom format, add the configuration option to your plugin's settings.php file. +Linear navigation is controlled by an `enablelinearnav` setting in each course format's own component. A format which does not define the setting has linear navigation enabled. ```php title="course/format/mycustomformat/settings.php" - $options = [ - 1 => get_string('yes'), - 0 => get_string('no'), - ]; - - $settings->add(new admin_setting_configselect( - 'format_mycustomformat/enablelinearnav', - new lang_string('linearnavigationsettings', 'core_courseformat'), - new lang_string('linearnavigationsettings_help', 'core_courseformat'), - 1, - $options - )); +$options = [ + 1 => get_string('yes'), + 0 => get_string('no'), +]; + +$settings->add(new admin_setting_configselect( + 'format_mycustomformat/enablelinearnav', + new lang_string('linearnavigationsettings', 'core_courseformat'), + new lang_string('linearnavigationsettings_help', 'core_courseformat'), + 1, + $options, +)); ``` -::: - ## Controlling the page state rendering The core output requirements verify format capabilities during execution. If you need to programmatically suppress or alter the navigation footer layout from specific views or custom renderers inside your format, utilise the page output control methods: @@ -117,7 +72,7 @@ if (\core_courseformat\local\linearnavigationsettings::show_navigation_footer($P } // Check if linear navigation is enabled for the course. -// It only checks the course format and the linear navigation format option, regardless of any +// It only checks the course format and the site-level setting for that format, regardless of any // page-level state. It is useful for activities that need to adapt their output (for example, // hiding navigation controls of their own) when linear navigation is enabled. $linearnavigationenabled = \core_courseformat\local\linearnavigationsettings::is_linear_navigation_enabled($course);