Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
backup_activity_task Class Reference

Provides all the settings and steps to perform one complete backup of the activity. More...

Inheritance diagram for backup_activity_task:
backup_task base_task checksumable executable loggable backup_assign_activity_task backup_bigbluebuttonbn_activity_task backup_book_activity_task backup_choice_activity_task backup_data_activity_task backup_feedback_activity_task backup_folder_activity_task backup_forum_activity_task backup_glossary_activity_task backup_h5pactivity_activity_task backup_imscp_activity_task backup_label_activity_task backup_lesson_activity_task backup_lti_activity_task backup_page_activity_task backup_qbank_activity_task backup_quiz_activity_task backup_resource_activity_task backup_scorm_activity_task backup_subsection_activity_task backup_url_activity_task backup_wiki_activity_task backup_workshop_activity_task

Public Member Functions

 __construct ($name, $moduleid, $plan=null)
 Constructor - instantiates one object of this class.
 
 add_result ($result)
 Add the given info to the current plan's results.
 
 add_setting ($setting)
 Add a setting to the task.
 
 add_step ($step)
 
 build ()
 Create all the steps that will be part of this task.
 
 calculate_checksum ()
 This function will return one unique and stable checksum for one instance of the class implementing it.
 
 destroy ()
 Destroy all circular references.
 
 execute ()
 Exceptionally override the execute method, so, based in the activity_included setting, we are able to skip the execution of one task completely.
 
 get_activityid ()
 
 get_backupid ()
 
 get_basepath ()
 
 get_contextid ()
 
 get_courseid ()
 
 get_kept_roles ()
 Get the user roles that should be kept in the destination course for a course copy operation.
 
 get_logger ()
 
 get_moduleid ()
 
 get_modulename ()
 
 get_name ()
 
 get_progress ()
 Gets the progress reporter, which can be used to report progress within the backup or restore process.
 
 get_results ()
 Return the current plan's results.
 
 get_sectionid ()
 
 get_setting ($name)
 Tries to look for the instance specific setting value, task specific setting value or the common plan setting value - in that order.
 
 get_setting_value ($name)
 
 get_settings ()
 
 get_steps ()
 
 get_taskbasepath ()
 
 get_weight ()
 Returns the weight of this task, an approximation of the amount of time it will take.
 
 is_checksum_correct ($checksum)
 Given one checksum, returns if matches object's checksum (true) or no (false)
 
 is_excluding_activities ()
 
 is_in_subsection ()
 Return if the activity is inside a subsection.
 
 log ($message, $level, $a=null, $depth=null, $display=false)
 This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.
 
 set_plan ($plan)
 
 setting_exists ($name)
 Check if a setting with the given name exists.
 

Static Public Member Functions

static encode_content_links ($content)
 Encodes URLs to the activity instance's scripts into a site-independent form.
 

Protected Member Functions

 add_activity_included_setting (string $settingprefix)
 Add the section include setting to the task.
 
 add_activity_userinfo_setting (string $settingprefix, activity_backup_setting $includefield)
 Add the section userinfo setting to the task.
 
 add_section_setting (int|string $identifier, string $type, string|int $value)
 Add a setting to the task.
 
 define_my_settings ()
 Defines activity specific settings to be added to the common ones.
 
 define_my_steps ()
 Defines activity specific steps for this task.
 
 define_settings ()
 Defines the common setting that any backup activity will have.
 

Protected Attributes

 $activityid
 
bool $built
 
 $contextid
 
bool $executed
 
 $moduleid
 
 $modulename
 
string $name
 
backup_plan restore_plan $plan
 
stdClass $section
 the section object
 
 $sectionid
 
base_setting[] $settings
 
base_step[] $steps
 

Detailed Description

Provides all the settings and steps to perform one complete backup of the activity.

Activities are supposed to provide the subclass of this class in their file mod/MODULENAME/backup/moodle2/backup_MODULENAME_activity_task.class.php The expected name of the subclass is backup_MODULENAME_activity_task

Constructor & Destructor Documentation

◆ __construct()

backup_activity_task::__construct ( $name,
$moduleid,
$plan = null )

Constructor - instantiates one object of this class.

Parameters
string$namethe task identifier
int$moduleidcourse module id (id in course_modules table)
backup_plan | null$planthe backup plan instance this task is part of

Member Function Documentation

◆ add_activity_included_setting()

backup_activity_task::add_activity_included_setting ( string $settingprefix)
protected

Add the section include setting to the task.

Parameters
string$settingprefixthe identifier of the setting
Return values
activity_backup_settingthe setting added

◆ add_activity_userinfo_setting()

backup_activity_task::add_activity_userinfo_setting ( string $settingprefix,
activity_backup_setting $includefield )
protected

Add the section userinfo setting to the task.

Parameters
string$settingprefixthe identifier of the setting
activity_backup_setting$includefieldthe setting to depend on
Return values
activity_backup_settingthe setting added

◆ add_result()

base_task::add_result ( $result)
inherited

Add the given info to the current plan's results.

See also
base_plan\add_result()
Parameters
array$resultassociative array describing a result of a task/step

◆ add_section_setting()

backup_activity_task::add_section_setting ( int|string $identifier,
string $type,
string|int $value )
protected

Add a setting to the task.

This method is used to add a setting to the task

Parameters
int | string$identifierthe identifier of the setting
string$typethe type of the setting
string | int$valuethe value of the setting
Return values
section_backup_settingthe setting added

◆ add_setting()

base_task::add_setting ( $setting)
inherited

Add a setting to the task.

Parameters
base_setting$setting
Return values
void

◆ build()

backup_activity_task::build ( )

Create all the steps that will be part of this task.

Reimplemented from base_task.

◆ calculate_checksum()

base_task::calculate_checksum ( )
inherited

This function will return one unique and stable checksum for one instance of the class implementing it.

It's each implementation responsibility to do it recursively if needed and use optional store (caching) of the checksum if necessary/possible

Implements checksumable.

◆ define_my_settings()

backup_activity_task::define_my_settings ( )
abstractprotected

◆ define_my_steps()

◆ define_settings()

backup_activity_task::define_settings ( )
protected

Defines the common setting that any backup activity will have.

Reimplemented from base_task.

◆ destroy()

base_task::destroy ( )
inherited

Destroy all circular references.

It helps PHP 5.2 a lot!

◆ encode_content_links()

static backup_activity_task::encode_content_links ( $content)
static

Encodes URLs to the activity instance's scripts into a site-independent form.

The current instance of the activity may be referenced from other places in the course by URLs like http://my.moodle.site/mod/workshop/view.php?id=42 Obvisouly, such URLs are not valid any more once the course is restored elsewhere. For this reason the backup file does not store the original URLs but encodes them into a transportable form. During the restore, the reverse process is applied and the encoded URLs are replaced with the new ones valid for the target site.

Every plugin must override this method in its subclass.

See also
backup_xml_transformer class that actually runs the transformation
Parameters
string$contentsome HTML text that eventually contains URLs to the activity instance scripts
Return values
stringthe content with the URLs encoded

Reimplemented in backup_assign_activity_task, backup_bigbluebuttonbn_activity_task, backup_book_activity_task, backup_choice_activity_task, backup_data_activity_task, backup_feedback_activity_task, backup_folder_activity_task, backup_forum_activity_task, backup_glossary_activity_task, backup_h5pactivity_activity_task, backup_imscp_activity_task, backup_label_activity_task, backup_lesson_activity_task, backup_lti_activity_task, backup_page_activity_task, backup_qbank_activity_task, backup_quiz_activity_task, backup_resource_activity_task, backup_scorm_activity_task, backup_subsection_activity_task, backup_url_activity_task, backup_wiki_activity_task, and backup_workshop_activity_task.

◆ execute()

backup_activity_task::execute ( )

Exceptionally override the execute method, so, based in the activity_included setting, we are able to skip the execution of one task completely.

Reimplemented from base_task.

◆ get_activityid()

backup_activity_task::get_activityid ( )
Return values
intthe id of the activity instance (id in the activity's instances table)

◆ get_contextid()

backup_activity_task::get_contextid ( )
Return values
intthe id of the associated CONTEXT_MODULE instance

◆ get_kept_roles()

backup_task::get_kept_roles ( )
inherited

Get the user roles that should be kept in the destination course for a course copy operation.

Return values
array

◆ get_moduleid()

backup_activity_task::get_moduleid ( )
Return values
intthe course module id (id in the course_modules table)

◆ get_modulename()

backup_activity_task::get_modulename ( )
Return values
stringthe name of the module, eg 'workshop' (from the modules table)

◆ get_progress()

base_task::get_progress ( )
inherited

Gets the progress reporter, which can be used to report progress within the backup or restore process.

Return values
core\progress\baseProgress reporting object

◆ get_results()

base_task::get_results ( )
inherited

Return the current plan's results.

Return values
array|null

◆ get_sectionid()

backup_activity_task::get_sectionid ( )
Return values
intthe course section id (id in the course_sections table)

◆ get_setting()

backup_activity_task::get_setting ( $name)

Tries to look for the instance specific setting value, task specific setting value or the common plan setting value - in that order.

Parameters
string$namethe name of the setting
Return values
mixed|nullthe value of the setting or null if not found

Reimplemented from base_task.

◆ get_taskbasepath()

backup_activity_task::get_taskbasepath ( )
Return values
stringfull path to the directory where this task writes its files

Reimplemented from base_task.

◆ get_weight()

base_task::get_weight ( )
inherited

Returns the weight of this task, an approximation of the amount of time it will take.

By default this value is 1. It can be increased for longer tasks.

Return values
intWeight

Reimplemented in backup_final_task.

◆ is_checksum_correct()

base_task::is_checksum_correct ( $checksum)
inherited

Given one checksum, returns if matches object's checksum (true) or no (false)

Implements checksumable.

◆ is_in_subsection()

backup_activity_task::is_in_subsection ( )

Return if the activity is inside a subsection.

Return values
bool

◆ log()

base_task::log ( $message,
$level,
$a = null,
$depth = null,
$display = false )
inherited

This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.

Implements loggable.

◆ setting_exists()

base_task::setting_exists ( $name)
inherited

Check if a setting with the given name exists.

This method find first in the current settings and then in the plan settings.

Parameters
string$nameSetting name
Return values
bool

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