Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_courseformat\stateactions Class Reference
Inheritance diagram for core_courseformat\stateactions:
format_topics\courseformat\stateactions

Public Member Functions

 cm_delete (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Delete course cms.
 
 cm_duplicate (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Duplicate a course modules instances into the same course.
 
 cm_hide (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Hide course cms.
 
 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_show (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Show course cms.
 
 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.
 
 cm_stealth (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Stealth course cms.
 
 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 state to collapse.
 
 section_content_expanded (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null,)
 Update the course content section state to expand.
 
 section_delete (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Delete course sections.
 
 section_hide (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Hide course sections.
 
 section_index_collapsed (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null,)
 Update the course index section state to collapse.
 
 section_index_expanded (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null,)
 Update the course index section state to expand.
 
 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_move_after (stateupdates $updates, stdClass $course, array $ids, ?int $targetsectionid=null, ?int $targetcmid=null)
 Move course sections after to another location in the same course.
 
 section_show (stateupdates $updates, stdClass $course, array $ids=[], ?int $targetsectionid=null, ?int $targetcmid=null)
 Show course sections.
 
 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.
 
 set_cm_visibility (stateupdates $updates, stdClass $course, array $ids, int $visible, int $coursevisible)
 Internal method to define the cm visibility.
 
 set_section_visibility (stateupdates $updates, stdClass $course, array $ids, int $visible)
 Show course sections.
 
 sort_cm_ids_by_course_position (stdClass $course, array $cmids, bool $descending=false)
 Sort the cm ids list depending on the course position.
 
 sort_section_ids_by_section_number (stdClass $course, array $sectionids, bool $descending=false)
 Sort the sections ids depending on the section number.
 
 validate_cms (stdClass $course, array $cmids, ?string $info=null, array $capabilities=[])
 Checks related to course modules: all given cm exist and the user has the required capabilities.
 
 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_delete()

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

Delete course cms.

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

◆ cm_duplicate()

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

Duplicate a course modules instances into the same course.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idscourse modules ids to duplicate
int | null$targetsectionidoptional target section id destination
int | null$targetcmidoptional target before cm id destination

◆ cm_hide()

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

Hide course cms.

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

◆ 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_show()

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

Show course cms.

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

◆ cm_stealth()

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

Stealth course cms.

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

◆ 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 state to collapse.

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

◆ section_content_expanded()

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

Update the course content section state to expand.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idsthe collapsed section ids
int | null$targetsectionidnot used
int | null$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_hide()

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

Hide course sections.

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 state to collapse.

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

◆ section_index_expanded()

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

Update the course index section state to expand.

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

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

Move course sections after 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_show()

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

Show course sections.

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

◆ 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

◆ set_cm_visibility()

core_courseformat\stateactions::set_cm_visibility ( stateupdates $updates,
stdClass $course,
array $ids,
int $visible,
int $coursevisible )
protected

Internal method to define the cm visibility.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idscm ids
int$visiblethe new visible value
int$coursevisiblethe new course visible value

◆ set_section_visibility()

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

Show course sections.

Parameters
stateupdates$updatesthe affected course elements track
stdClass$coursethe course object
int[]$idssection ids
int$visiblethe new visible value

◆ sort_cm_ids_by_course_position()

core_courseformat\stateactions::sort_cm_ids_by_course_position ( stdClass $course,
array $cmids,
bool $descending = false )
protected

Sort the cm ids list depending on the course position.

Some actions like move should be done in an specific order.

Parameters
stdClass$coursethe course object
int[]$cmidsthe array of section $ids
bool$descendingif the sort order must be descending instead of ascending
Return values
int[]the array of section ids sorted by section number

◆ sort_section_ids_by_section_number()

core_courseformat\stateactions::sort_section_ids_by_section_number ( stdClass $course,
array $sectionids,
bool $descending = false )
protected

Sort the sections ids depending on the section number.

Some actions like move should be done in an specific order.

Parameters
stdClass$coursethe course object
int[]$sectionidsthe array of section $ids
bool$descendingif the sort order must be descending instead of ascending
Return values
int[]the array of section ids sorted by section number

◆ validate_cms()

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

Checks related to course modules: all given cm exist and the user has the required capabilities.

Parameters
stdClass$courseThe course where given $cmids belong.
array$cmidsList of course module ids to validate.
string$infoadditional information in case of error.
array$capabilitiesoptional capabilities checks per each cm context.
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: