Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is 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.