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 singleactivity

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

Defines 1 class


Class: format_singleactivity  - X-Ref

Main class for the singleactivity course format

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

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

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

navigation_add_activity(navigation_node $node, $cm)   X-Ref
Adds a course module to the navigation node

This is basically copied from function global_navigation::load_section_activities()
because it is not accessible from outside.

param: navigation_node $node
param: cm_info $cm
return: null|navigation_node

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

Singleactivity course format uses one option 'activitytype'

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()}

Format singleactivity adds a warning when format of the course is about to be changed.

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

reorder_activities()   X-Ref
Make sure that current active activity is in section 0

All other activities are moved to section 1 that will be displayed as 'Orphaned'.
It may be needed after the course format was changed or activitytype in
course settings has been changed.

return: null|cm_info current activity

get_activitytype()   X-Ref
Returns the name of activity type used for this course

return: string|null

get_activity()   X-Ref
Returns the current activity if exists

return: null|cm_info

get_supported_activities()   X-Ref
Get the activities supported by the format.

Here we ignore the modules that do not have a page of their own, like the label.

return: array array($module => $name of the module).

can_add_activity()   X-Ref
Checks if the current user can add the activity of the specified type to this course.

return: bool

activity_has_subtypes()   X-Ref
Checks if the activity type has multiple items in the activity chooser.

return: bool|null (null if the check is not possible)

page_set_course(moodle_page $page)   X-Ref
Allows course format to execute code on moodle_page::set_course()

This function is executed before the output starts.

If everything is configured correctly, user is redirected from the
default course view page to the activity view page.

"Section 1" is the administrative page to manage orphaned activities

If user is on course view page and there is no module added to the course
and the user has 'moodle/course:manageactivities' capability, redirect to create module
form.

param: moodle_page $page instance of page calling set_course

page_set_cm(moodle_page $page)   X-Ref
Allows course format to execute code on moodle_page::set_cm()

If we are inside the main module for this course, remove extra node level
from navigation: substitute course node with activity node, move all children

param: moodle_page $page instance of page calling set_cm

has_view_page()   X-Ref
Returns true if the course has a front page.

return: boolean false

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

return: array the list of configuration settings