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 400 and 401]

This file contains main class for the course format Weeks

Copyright: 2009 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 653 lines (25 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: format_weeks  - X-Ref

Main class for the Weeks course format

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

return: bool

uses_course_index()   X-Ref
No description

uses_indentation()   X-Ref
No description

page_title()   X-Ref
Generate the title for this section page

return: string the page title

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: string Display name that the course format prefers, e.g. "Topic 2"

get_default_section_name($section)   X-Ref
Returns the default section name for the weekly course format.

If the section number is 0, it will use the string with key = section0name from the course format's lang file.
Otherwise, the default format of "[start date] - [end date]" will be returned.

param: stdClass $section Section object from database or just field course_sections section
return: string The default value for the section name.

get_section_highlighted_name()   X-Ref
Returns the name for the highlighted section.

return: string The name for the highlighted section based on the given course format.

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

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

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

return: stdClass

supports_components()   X-Ref
No description

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

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

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

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

Weeks format uses the following options:
- coursedisplay
- hiddensections
- automaticenddate

param: bool $foreditform
return: array of options

create_edit_form_elements(&$mform, $forsection = false)   X-Ref
Adds format options elements to the course/section edit form.

This function is called from {@link course_edit_form::definition_after_data()}.

param: MoodleQuickForm $mform form the elements are added to.
param: bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form.
return: array array of references to the added form elements.

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

In case if course format was changed to 'weeks', we try to copy options
'coursedisplay', 'numsections' and 'hiddensections' from the previous format.
If previous course format did not have 'numsections' option, we populate it with the
current number of sections

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

get_section_dates($section, $startdate = false)   X-Ref
Return the start and end date of the passed section

param: int|stdClass|section_info $section section to get the dates for
param: int $startdate Force course start date, useful when the course is not yet created
return: stdClass property start for startdate, property end for enddate

is_section_current($section)   X-Ref
Returns true if the specified week is current

param: int|stdClass|section_info $section
return: bool

can_delete_section($section)   X-Ref
Whether this format allows to delete sections

Do not call this function directly, instead use {@link course_can_delete_section()}

param: int|stdClass|section_info $section
return: bool

inplace_editable_render_section_name($section, $linkifneeded = true,$editable = null, $edithint = null, $editlabel = null)   X-Ref
Prepares the templateable object to display section name

param: \section_info|\stdClass $section
param: bool $linkifneeded
param: bool $editable
param: null|lang_string|string $edithint
param: null|lang_string|string $editlabel
return: \core\output\inplace_editable

get_default_course_enddate($mform, $fieldnames = array()   X-Ref
Returns the default end date for weeks course format.

param: moodleform $mform
param: array $fieldnames The form - field names mapping.
return: int

supports_news()   X-Ref
Indicates whether the course format supports the creation of a news forum.

return: bool

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

section_action($section, $action, $sr)   X-Ref
No description

update_end_date($courseid)   X-Ref
Updates the end date for a course in weeks format if option automaticenddate is set.

This method is called from event observers and it can not use any modinfo or format caches because
events are triggered before the caches are reset.

param: int $courseid

get_config_for_external()   X-Ref
Return the plugin configs for external functions.

return: array the list of configuration settings

format_weeks_inplace_editable($itemtype, $itemid, $newvalue)   X-Ref
Implements callback inplace_editable() allowing to edit values in-place

param: string $itemtype
param: int $itemid
param: mixed $newvalue
return: \core\output\inplace_editable