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 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 777 lines (28 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: stateactions  - X-Ref

Contains the core course state actions.

The methods from this class should be executed via "core_courseformat_edit" web service.

Each format plugin could extend this class to provide new actions to the editor.
Extended classes should be locate in "format_XXX\course" namespace and
extends core_courseformat\stateactions.

cm_move(stateupdates $updates,stdClass $course,array $ids,?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Move course modules to another location in the same course.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids the list of affected course module ids
param: int $targetsectionid optional target section id
param: int $targetcmid optional target cm id

section_move(stateupdates $updates,stdClass $course,array $ids,?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Move course sections to another location in the same course.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids the list of affected course module ids
param: int $targetsectionid optional target section id
param: int $targetcmid optional target cm id

section_add(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Create a course section.

This method follows the same logic as changenumsections.php.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids not used
param: int $targetsectionid optional target section id (if not passed section will be appended)
param: int $targetcmid not used

section_delete(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Delete course sections.

This method follows the same logic as editsection.php.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids section ids
param: int $targetsectionid not used
param: int $targetcmid not used

section_hide(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Hide course sections.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids section ids
param: int $targetsectionid not used
param: int $targetcmid not used

section_show(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Show course sections.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids section ids
param: int $targetsectionid not used
param: int $targetcmid not used

set_section_visibility(stateupdates $updates,stdClass $course,array $ids,int $visible)   X-Ref
Show course sections.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids section ids
param: int $visible the new visible value

cm_show(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Show course cms.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids cm ids
param: int $targetsectionid not used
param: int $targetcmid not used

cm_hide(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Hide course cms.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids cm ids
param: int $targetsectionid not used
param: int $targetcmid not used

cm_stealth(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Stealth course cms.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids cm ids
param: int $targetsectionid not used
param: int $targetcmid not used

set_cm_visibility(stateupdates $updates,stdClass $course,array $ids,int $visible,int $coursevisible)   X-Ref
Internal method to define the cm visibility.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids cm ids
param: int $visible the new visible value
param: int $coursevisible the new course visible value

cm_moveright(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Move course cms to the right. Indent = 1.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids cm ids
param: int $targetsectionid not used
param: int $targetcmid not used

cm_moveleft(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Move course cms to the left. Indent = 0.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids cm ids
param: int $targetsectionid not used
param: int $targetcmid not used

set_cm_indentation(stateupdates $updates,stdClass $course,array $ids,int $indent)   X-Ref
Internal method to define the cm indentation level.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids cm ids
param: int $indent new value for indentation

get_cm_info(course_modinfo $modinfo, array $ids)   X-Ref
Extract several cm_info from the course_modinfo.

param: course_modinfo $modinfo the course modinfo.
param: int[] $ids the course modules $ids
return: cm_info[] the extracted cm_info objects

get_section_info(course_modinfo $modinfo, array $ids)   X-Ref
Extract several section_info from the course_modinfo.

param: course_modinfo $modinfo the course modinfo.
param: int[] $ids the course modules $ids
return: section_info[] the extracted section_info objects

section_content_collapsed(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Update the course content section collapsed value.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids the collapsed section ids
param: int $targetsectionid not used
param: int $targetcmid not used

section_index_collapsed(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Update the course index section collapsed value.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids the collapsed section ids
param: int $targetsectionid not used
param: int $targetcmid not used

cm_state(stateupdates $updates,stdClass $course,array $ids,?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Add the update messages of the updated version of any cm and section related to the cm ids.

This action is mainly used by legacy actions to partially update the course state when the
result of core_course_edit_module is not enough to generate the correct state data.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids the list of affected course module ids
param: int $targetsectionid optional target section id
param: int $targetcmid optional target cm id

section_state(stateupdates $updates,stdClass $course,array $ids,?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Add the update messages of the updated version of any cm and section related to the section ids.

This action is mainly used by legacy actions to partially update the course state when the
result of core_course_edit_module is not enough to generate the correct state data.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids the list of affected course section ids
param: int $targetsectionid optional target section id
param: int $targetcmid optional target cm id

course_state(stateupdates $updates,stdClass $course,array $ids = [],?int $targetsectionid = null,?int $targetcmid = null)   X-Ref
Add all the update messages from the complete course state.

This action is mainly used by legacy actions to partially update the course state when the
result of core_course_edit_module is not enough to generate the correct state data.

param: stateupdates $updates the affected course elements track
param: stdClass $course the course object
param: int[] $ids the list of affected course module ids (not used)
param: int $targetsectionid optional target section id (not used)
param: int $targetcmid optional target cm id (not used)

validate_sections(stdClass $course, array $sectionids, ?string $info = null)   X-Ref
Checks related to sections: course format support them, all given sections exist and topic 0 is not included.

param: stdClass $course The course where given $sectionids belong.
param: array $sectionids List of sections to validate.
param: string|null $info additional information in case of error (default null).

validate_cms(stdClass $course, array $cmids, ?string $info = null)   X-Ref
Checks related to course modules: all given cm exist.

param: stdClass $course The course where given $cmids belong.
param: array $cmids List of course module ids to validate.
param: string $info additional information in case of error.