Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

(no description)

File Size: 609 lines (22 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

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.

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

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

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

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.