Moodle APIs 4.0
Moodle 4.0.11 (Build: 20231009)
Public Member Functions | Protected Member Functions | List of all members
core_courseformat\stateactions Class Reference

Public Member Functions

 cm_move (stateupdates $updates, stdClass $course, array $ids, ?int $targetsectionid=null, ?int $targetcmid=null)
 Move course modules to another location in the same course.
 
 cm_moveleft (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Move course cms to the left.
 
 cm_moveright (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Move course cms to the right.
 
 cm_state (stateupdates $updates, stdClass $course, array $ids, ?int $targetsectionid=null, ?int $targetcmid=null)
 Add the update messages of the updated version of any cm and section related to the cm ids.
 
 course_state (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Add all the update messages from the complete course state.
 
 section_add (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Create a course section.
 
 section_content_collapsed (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Update the course content section collapsed value.
 
 section_delete (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Delete course sections.
 
 section_index_collapsed (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Update the course index section collapsed value.
 
 section_move (stateupdates $updates, stdClass $course, array $ids, ?int $targetsectionid=null, ?int $targetcmid=null)
 Move course sections to another location in the same course.
 
 section_state (stateupdates $updates, stdClass $course, array $ids, ?int $targetsectionid=null, ?int $targetcmid=null)
 Add the update messages of the updated version of any cm and section related to the section ids.
 

Protected Member Functions

 get_cm_info (course_modinfo $modinfo, array $ids)
 Extract several cm_info from the course_modinfo.
 
 get_section_info (course_modinfo $modinfo, array $ids)
 Extract several section_info from the course_modinfo.
 
 set_cm_indentation (stateupdates $updates, stdClass $course, array $ids, int $indent)
 Internal method to define the cm indentation level.
 
 validate_cms (stdClass $course, array $cmids, ?string $info=null)
 Checks related to course modules: all given cm exist.
 
 validate_sections (stdClass $course, array $sectionids, ?string $info=null)
 Checks related to sections: course format support them, all given sections exist and topic 0 is not included.
 

Member Function Documentation

◆ cm_move()

core_courseformat\stateactions::cm_move ( stateupdates  $updates,
stdClass  $course,
array  $ids,
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Move course modules to another location in the same course.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe list of affected course module ids
int$targetsectionidoptional target section id
int$targetcmidoptional target cm id

◆ cm_moveleft()

core_courseformat\stateactions::cm_moveleft ( stateupdates  $updates,
stdClass  $course,
array  $ids = [],
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Move course cms to the left.

Indent = 0.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idscm ids
int$targetsectionidnot used
int$targetcmidnot used

◆ cm_moveright()

core_courseformat\stateactions::cm_moveright ( stateupdates  $updates,
stdClass  $course,
array  $ids = [],
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Move course cms to the right.

Indent = 1.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idscm ids
int$targetsectionidnot used
int$targetcmidnot used

◆ cm_state()

core_courseformat\stateactions::cm_state ( stateupdates  $updates,
stdClass  $course,
array  $ids,
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

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.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe list of affected course module ids
int$targetsectionidoptional target section id
int$targetcmidoptional target cm id

◆ course_state()

core_courseformat\stateactions::course_state ( stateupdates  $updates,
stdClass  $course,
array  $ids = [],
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

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.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe list of affected course module ids (not used)
int$targetsectionidoptional target section id (not used)
int$targetcmidoptional target cm id (not used)

◆ get_cm_info()

core_courseformat\stateactions::get_cm_info ( course_modinfo  $modinfo,
array  $ids 
)
protected

Extract several cm_info from the course_modinfo.

Parameters
course_modinfo$modinfothe course modinfo.
int[]$idsthe course modules $ids
Return values
cm_info[]the extracted cm_info objects

◆ get_section_info()

core_courseformat\stateactions::get_section_info ( course_modinfo  $modinfo,
array  $ids 
)
protected

Extract several section_info from the course_modinfo.

Parameters
course_modinfo$modinfothe course modinfo.
int[]$idsthe course modules $ids
Return values
section_info[]the extracted section_info objects

◆ section_add()

core_courseformat\stateactions::section_add ( stateupdates  $updates,
stdClass  $course,
array  $ids = [],
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Create a course section.

This method follows the same logic as changenumsections.php.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsnot used
int$targetsectionidoptional target section id (if not passed section will be appended)
int$targetcmidnot used

◆ section_content_collapsed()

core_courseformat\stateactions::section_content_collapsed ( stateupdates  $updates,
stdClass  $course,
array  $ids = [],
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Update the course content section collapsed value.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe collapsed section ids
int$targetsectionidnot used
int$targetcmidnot used

◆ section_delete()

core_courseformat\stateactions::section_delete ( stateupdates  $updates,
stdClass  $course,
array  $ids = [],
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Delete course sections.

This method follows the same logic as editsection.php.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idssection ids
int$targetsectionidnot used
int$targetcmidnot used

◆ section_index_collapsed()

core_courseformat\stateactions::section_index_collapsed ( stateupdates  $updates,
stdClass  $course,
array  $ids = [],
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Update the course index section collapsed value.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe collapsed section ids
int$targetsectionidnot used
int$targetcmidnot used

◆ section_move()

core_courseformat\stateactions::section_move ( stateupdates  $updates,
stdClass  $course,
array  $ids,
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

Move course sections to another location in the same course.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe list of affected course module ids
int$targetsectionidoptional target section id
int$targetcmidoptional target cm id

◆ section_state()

core_courseformat\stateactions::section_state ( stateupdates  $updates,
stdClass  $course,
array  $ids,
?int  $targetsectionid = null,
?int  $targetcmid = null 
)

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.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe list of affected course section ids
int$targetsectionidoptional target section id
int$targetcmidoptional target cm id

◆ set_cm_indentation()

core_courseformat\stateactions::set_cm_indentation ( stateupdates  $updates,
stdClass  $course,
array  $ids,
int  $indent 
)
protected

Internal method to define the cm indentation level.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idscm ids
int$indentnew value for indentation

◆ validate_cms()

core_courseformat\stateactions::validate_cms ( stdClass  $course,
array  $cmids,
?string  $info = null 
)
protected

Checks related to course modules: all given cm exist.

Parameters
stdClass$courseThe course where given $cmids belong.
array$cmidsList of course module ids to validate.
string$infoadditional information in case of error.
Exceptions
moodle_exceptionif any id is not valid

◆ validate_sections()

core_courseformat\stateactions::validate_sections ( stdClass  $course,
array  $sectionids,
?string  $info = null 
)
protected

Checks related to sections: course format support them, all given sections exist and topic 0 is not included.

Parameters
stdClass$courseThe course where given $sectionids belong.
array$sectionidsList of sections to validate.
string | null$infoadditional information in case of error (default null).
Exceptions
moodle_exceptionif any id is not valid

The documentation for this class was generated from the following file: