Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_courseformat\local\sectionactions Class Reference
Inheritance diagram for core_courseformat\local\sectionactions:
core_courseformat\local\baseactions

Public Member Functions

 create (int $position=0, bool $skipcheck=false)
 Creates a course section and adds it to the specified position.
 
 create_delegated (string $component, ?int $itemid=null, ?stdClass $fields=null)
 Create a delegated section.
 
 create_if_missing (array $sectionnums)
 Create course sections if they are not created yet.
 
 delete (section_info $sectioninfo, bool $forcedeleteifnotempty=true, bool $async=false)
 Delete a course section.
 
 update (section_info $sectioninfo, array|stdClass $fields)
 Update a course section.
 

Protected Member Functions

 create_from_object (stdClass $fields, bool $skipcheck=false)
 Create a course section using a record object.
 
 delete_async (section_info $sectioninfo, bool $forcedeleteifnotempty=true)
 Course section deletion, using an adhoc task for deletion of the modules it contains.
 
 delete_format_data (section_info $sectioninfo, bool $forcedeleteifnotempty, course_section_deleted $event)
 Delete a course section.
 
 get_cm_info ($cmid)
 Get the cm info.
 
 get_course ()
 Get the course.
 
 get_delete_event (section_info $sectioninfo)
 Get the event to trigger when deleting a section.
 
 get_format ()
 Get the course format.
 
 get_last_section_number (bool $includedelegated=true)
 Get the last section number in the course.
 
 get_section_info ($sectionid, int $strictness=IGNORE_MISSING)
 Get the section info.
 
 preprocess_delegated_section_fields (section_info $sectioninfo, array $fields)
 Preprocess the section fields before updating a delegated section.
 
 transfer_visibility_to_cms (section_info $sectioninfo, bool $visibility)
 Transfer the visibility of the section to the course modules.
 

Protected Attributes

stdClass stdClass $course
 the course object.
 

Member Function Documentation

◆ create()

core_courseformat\local\sectionactions::create ( int $position = 0,
bool $skipcheck = false )

Creates a course section and adds it to the specified position.

This method returns a section record, not a section_info object. This prevents the regeneration of the modinfo object each time we create a section.

If position is greater than number of existing sections, the section is added to the end. This will become sectionnum of the new section. All existing sections at this or bigger position will be shifted down.

Parameters
int$positionThe position to add to, 0 means to the end.
bool$skipcheckthe check has already been made and we know that the section with this position does not exist
Return values
stdClasscreated section object)

◆ create_delegated()

core_courseformat\local\sectionactions::create_delegated ( string $component,
?int $itemid = null,
?stdClass $fields = null )

Create a delegated section.

Parameters
string$componentthe name of the plugin
int | null$itemidthe id of the delegated section
stdClass | null$fieldsthe fields to set on the section
Return values
section_infothe created section

◆ create_from_object()

core_courseformat\local\sectionactions::create_from_object ( stdClass $fields,
bool $skipcheck = false )
protected

Create a course section using a record object.

If $fields->section is not set, the section is added to the end of the course.

Parameters
stdClass$fieldsthe fields to set on the section
bool$skipcheckthe position check has already been made and we know it can be used
Return values
stdClassthe created section record

◆ create_if_missing()

core_courseformat\local\sectionactions::create_if_missing ( array $sectionnums)

Create course sections if they are not created yet.

The calculations will ignore sections delegated to components. If the section is created, all delegated sections will be pushed down.

Parameters
int[]$sectionnumsthe section numbers to create
Return values
boolwhether any section was created

◆ delete()

core_courseformat\local\sectionactions::delete ( section_info $sectioninfo,
bool $forcedeleteifnotempty = true,
bool $async = false )

Delete a course section.

Parameters
section_info$sectioninfothe section to delete.
bool$forcedeleteifnotemptywhether to force section deletion if it contains modules.
bool$asyncwhether or not to try to delete the section using an adhoc task. Async also depends on a plugin hook.
Return values
boolwhether section was deleted

◆ delete_async()

core_courseformat\local\sectionactions::delete_async ( section_info $sectioninfo,
bool $forcedeleteifnotempty = true )
protected

Course section deletion, using an adhoc task for deletion of the modules it contains.

  1. Schedule all modules within the section for adhoc removal.
  2. Move all modules to course section 0.
  3. Delete the resulting empty section.
Parameters
section_info$sectioninfothe section to schedule for deletion.
bool$forcedeleteifnotemptywhether to force section deletion if it contains modules.
Return values
booltrue if the section was scheduled for deletion, false otherwise.

◆ delete_format_data()

core_courseformat\local\sectionactions::delete_format_data ( section_info $sectioninfo,
bool $forcedeleteifnotempty,
course_section_deleted $event )
protected

Delete a course section.

Parameters
section_info$sectioninfothe section to delete.
bool$forcedeleteifnotemptywhether to force section deletion if it contains modules.
course_section_deleted$eventthe event to trigger
Return values
boolwhether section was deleted

◆ get_cm_info()

core_courseformat\local\baseactions::get_cm_info ( $cmid)
protectedinherited

Get the cm info.

Parameters
int$cmidthe cm id.
Return values
cm_info|nullInformation for numbered cm or null if not found

◆ get_course()

core_courseformat\local\baseactions::get_course ( )
protectedinherited

Get the course.

Return values
stdClassthe course object.

◆ get_delete_event()

core_courseformat\local\sectionactions::get_delete_event ( section_info $sectioninfo)
protected

Get the event to trigger when deleting a section.

Parameters
section_info$sectioninfothe section to delete.
Return values
course_section_deletedthe event to trigger

◆ get_format()

core_courseformat\local\baseactions::get_format ( )
protectedinherited

Get the course format.

Return values
course_formatthe course format.

◆ get_last_section_number()

core_courseformat\local\sectionactions::get_last_section_number ( bool $includedelegated = true)
protected

Get the last section number in the course.

Parameters
bool$includedelegatedwhether to include delegated sections
Return values
int

◆ get_section_info()

core_courseformat\local\baseactions::get_section_info ( $sectionid,
int $strictness = IGNORE_MISSING )
protectedinherited

Get the section info.

Parameters
int$sectionidthe section id.
int$strictnessUse MUST_EXIST to throw exception if it doesn't
Return values
section_info|nullInformation for numbered section or null if not found

◆ preprocess_delegated_section_fields()

core_courseformat\local\sectionactions::preprocess_delegated_section_fields ( section_info $sectioninfo,
array $fields )
protected

Preprocess the section fields before updating a delegated section.

Parameters
section_info$sectioninfothe section info or database record to update.
array$fieldsthe fields to update.
Return values
arraythe updated fields

◆ transfer_visibility_to_cms()

core_courseformat\local\sectionactions::transfer_visibility_to_cms ( section_info $sectioninfo,
bool $visibility )
protected

Transfer the visibility of the section to the course modules.

Parameters
section_info$sectioninfothe section info or database record to update.
bool$visibilitythe new visibility of the section.

◆ update()

core_courseformat\local\sectionactions::update ( section_info $sectioninfo,
array|stdClass $fields )

Update a course section.

Parameters
section_info$sectioninfothe section info or database record to update.
array | stdClass$fieldsthe fields to update.
Return values
boolwhether section was updated

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