Restore plugin class that provides the necessary information needed to restore one match qtype plugin.
More...
|
static | convert_backup_to_questiondata (array $backupdata) |
| Convert the backup structure of this question type into a structure matching its question data.
|
|
static | define_decode_contents () |
| Return the contents of this qtype to be processed by the links decoder.
|
|
static | define_plugin_decode_contents () |
| Return the contents of the questions stuff that must be processed by the links decoder.
|
|
static | get_restore_decode_contents ($plugintype) |
| Returns one array with all the decode contents to be processed by the links decoder.
|
|
static | remove_excluded_question_data (stdClass $questiondata, array $excludefields=[]) |
| Remove excluded fields from the questiondata structure.
|
|
|
| add_question_datasets (&$paths) |
| Add to $paths the restore_path_elements needed to handle question_datasets (defs and items) for a given question Used by various qtypes (calculated, numerical)
|
|
| add_question_numerical_options (&$paths) |
| Add to $paths the restore_path_elements needed to handle question_numerical_options for a given question Used by various qtypes (calculated, numerical)
|
|
| add_question_numerical_units (&$paths) |
| Add to $paths the restore_path_elements needed to handle question_numerical_units for a given question Used by various qtypes (calculated, numerical)
|
|
| add_question_question_answers (&$paths) |
| Add to $paths the restore_path_elements needed to handle question_answers for a given question Used by various qtypes (calculated, essay, multianswer, multichoice, numerical, shortanswer, truefalse)
|
|
| add_related_files ($component, $filearea, $mappingitemname, $filesctxid=null, $olditemid=null) |
| Add all the existing file, given their component and filearea and one backup_ids itemname to match with.
|
|
| apply_date_offset ($value) |
| Apply course startdate offset based in original course startdate and course_offset_startdate setting Note we are using one static cache here, but by restoreid, so it's ok for concurrence/multiple executions in the same request.
|
|
| define_excluded_identity_hash_fields () |
| Return a list of paths to fields to be removed from questiondata before creating an identity hash.
|
|
| define_question_plugin_structure () |
| Returns the paths to be handled by the plugin at question level.
|
|
| get_mapping ($itemname, $oldid) |
| Return the complete mapping from the given itemname, itemid.
|
|
| get_mappingid ($itemname, $oldid, $ifnotfound=false) |
| Return the new id of a mapping for the given itemname.
|
|
| get_namefor ($name='') |
| Simple helper function that returns the name for the restore_path_element It's not mandatory to use it but recommended ;-)
|
|
| get_new_parentid ($itemname) |
| Returns the latest (parent) new id mapped by one pathelement.
|
|
| get_old_parentid ($itemname) |
| Returns the latest (parent) old id mapped by one pathelement.
|
|
| get_pathfor ($path='') |
| Simple helper function that returns the base (prefix) of the path for the restore_path_element Useful if we used get_recommended_name() in backup.
|
|
| get_restoreid () |
|
| get_setting_value ($name) |
| Returns the value of one (task/plan) setting.
|
|
| get_task () |
| Get the task we are part of.
|
|
| recode_match_sub_order ($order) |
| Recode the choice order as stored in the response.
|
|
| set_mapping ($itemname, $oldid, $newid, $restorefiles=false, $filesctxid=null, $parentid=null) |
| To send ids pairs to backup_ids_table and to store them into paths.
|
|
Restore plugin class that provides the necessary information needed to restore one match qtype plugin.
- Copyright
- 2010 onwards Eloy Lafuente (stronk7)
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
static restore_qtype_match_plugin::convert_backup_to_questiondata |
( |
array | $backupdata | ) |
|
|
static |
Convert the backup structure of this question type into a structure matching its question data.
This should take the hierarchical array of tags from the question's backup structure, and return a structure that matches that returned when calling {
- See also
- get_question_options()} for this question type. See https://docs.moodle.org/dev/Question_data_structures#Representation_1:_%24questiondata for an explanation of this structure.
This data will then be used to produce an identity hash for comparison with questions in the database.
This base implementation deals with all common backup elements created by the add_question_*_options() methods in this class, plus elements added by define_question_plugin_structure() named for the qtype. The question type will need to extend this function if define_question_plugin_structure() adds any other elements to the backup.
- Parameters
-
array | $backupdata | The hierarchical array of tags from the backup. |
- Return values
-
stdClass | The questiondata object. |
Reimplemented from restore_qtype_plugin.
restore_qtype_match_plugin::define_excluded_identity_hash_fields |
( |
| ) |
|
|
protected |
Return a list of paths to fields to be removed from questiondata before creating an identity hash.
Fields that should be excluded from common elements such as answers or numerical units that are used by the plugin will be excluded automatically. This method just needs to define any specific to this plugin, such as foreign keys used in the plugin's tables.
The returned array should be a list of slash-delimited paths to locate the fields to be removed from the questiondata object. For example, if you want to remove the field $questiondata->options->questionid
, the path would be '/options/questionid'. If a field in the path is an array, the rest of the path will be applied to each object in the array. So if you have $questiondata->options->answers[]
, the path '/options/answers/id' will remove the 'id' field from each element of the 'answers' array.
- Return values
-
Reimplemented from restore_qtype_plugin.
static restore_qtype_plugin::define_plugin_decode_contents |
( |
| ) |
|
|
staticinherited |
Return the contents of the questions stuff that must be processed by the links decoder.
Only common stuff to all plugins, in this case:
- question: text and feedback
- question_answers: text and feedback
- question_hints: hint
Note each qtype will have, if needed, its own define_decode_contents method
Reimplemented from restore_plugin.