Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Defines backup_qtype_plugin class

Copyright: 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 210 lines (8 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: backup_qtype_plugin  - X-Ref

Class extending standard backup_plugin in order to implement some
helper methods related with the questions (qtype plugin)

TODO: Finish phpdocs
add_question_question_answers($element)   X-Ref
Attach to $element (usually questions) the needed backup structures
for question_answers for a given question
Used by various qtypes (calculated, essay, multianswer,
multichoice, numerical, shortanswer, truefalse)


add_question_numerical_units($element)   X-Ref
Attach to $element (usually questions) the needed backup structures
for question_numerical_units for a given question
Used both by calculated and numerical qtypes


add_question_numerical_options($element)   X-Ref
Attach to $element (usually questions) the needed backup structures
for question_numerical_options for a given question
Used both by calculated and numerical qtypes


add_question_datasets($element)   X-Ref
Attach to $element (usually questions) the needed backup structures
for question_datasets for a given question
Used by calculated qtypes


get_components_and_fileareas($filter = null)   X-Ref
Returns all the components and fileareas used by all the installed qtypes

The method introspects each qtype, asking it about fileareas used. Then,
one 2-level array is returned. 1st level is the component name (qtype_xxxx)
and 2nd level is one array of filearea => mappings to look

Note that this function is used both in backup and restore, so it is important
to use the same mapping names (usually, name of the table in singular) always

TODO: Surely this can be promoted to backup_plugin easily and make it to
work for ANY plugin, not only qtypes (but we don't need it for now)

get_qtype_fileareas()   X-Ref
Returns one array with filearea => mappingname elements for the qtype

Used by {@link get_components_and_fileareas} to know about all the qtype
files to be processed both in backup and restore.