Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Handles the conversion of the question bank included in the moodle.xml file. More...
Public Member Functions | |
get_converter () | |
get_current_category_context () | |
Returns the information about the question category context being currently parsed. More... | |
get_file_manager () | |
Return the file manager instance used. More... | |
get_paths () | |
Registers path that are not qtype-specific. | |
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. | |
on_question_categories_end () | |
Stops writing questions.xml. | |
on_question_categories_start () | |
Starts writing questions.xml and prepares the file manager instance. | |
on_question_category_end () | |
Closes the question_category and annotates the category id so that it can be dumped into course/inforef.xml. | |
on_question_category_start () | |
Initializes the current category cache. | |
on_questions_end () | |
Closes the questions wrapper. | |
process_question (array $data, array $raw) | |
Writes the common <question> data and re-dispateches the whole grouped <QUESTION> data to the qtype for appending its qtype specific data processing. More... | |
process_question_category ($data, $raw) | |
Populates the current question category data. More... | |
process_question_category_context ($data) | |
Inject the context related information into the current category. | |
Protected Member Functions | |
close_xml_writer () | |
Close the XML writer. More... | |
get_qtype_handler ($qtype) | |
Provides access to the qtype handlers. More... | |
has_xml_writer () | |
Checks if the XML writer has been opened by self::open_xml_writer(). More... | |
make_sure_xml_exists ($filename, $rootelement=false, $content=array()) | |
Makes sure that a new XML file exists, or creates it itself. More... | |
open_xml_writer ($filename) | |
Opens the XML writer - after calling, one is free to use $xmlwriter. More... | |
write_xml ($element, array $data, array $attribs=array(), $parent='/') | |
Writes the given XML tree data into the currently opened file. More... | |
Protected Attributes | |
moodle1_converter | $converter |
array | $currentcategory = null |
the current question category being parsed | |
array | $currentcategoryraw = null |
of the raw data for the current category | |
moodle1_file_manager | $fileman = null |
instance used to convert question images | |
null string | $xmlfilename |
the name of file we are writing to | |
null xml_writer | $xmlwriter |
Handles the conversion of the question bank included in the moodle.xml file.
|
protectedinherited |
Close the XML writer.
At the moment, the caller must close all tags before calling
void |
Reimplemented in moodle1_qtype_handler.
|
inherited |
moodle1_converter | the converter that required this handler |
moodle1_question_bank_handler::get_current_category_context | ( | ) |
Returns the information about the question category context being currently parsed.
array | with keys contextid, contextlevel and contextinstanceid |
moodle1_question_bank_handler::get_file_manager | ( | ) |
Return the file manager instance used.
moodle1_file_manager |
|
protected |
Provides access to the qtype handlers.
Returns either list of all qtype handler instances (if passed '*') or a particular handler for the given qtype or false if the qtype is not supported.
moodle1_convert_exception |
string | $qtype | the name of the question type or '*' for returning all |
array|moodle1_qtype_handler|bool |
|
protectedinherited |
Checks if the XML writer has been opened by self::open_xml_writer().
bool |
|
protectedinherited |
Makes sure that a new XML file exists, or creates it itself.
This is here so we can check that all XML files that the restore process relies on have been created by an executed handler. If the file is not found, this method can create it using the given $rootelement as an empty root container in the file.
string | $filename | relative file name like 'course/course.xml' |
string | bool | $rootelement | root element to use, false to not create the file |
array | $content | content of the root element |
bool | true is the file existed, false if it did not |
|
protectedinherited |
Opens the XML writer - after calling, one is free to use $xmlwriter.
string | $filename | XML file name to write into |
void |
Reimplemented in moodle1_qtype_handler.
moodle1_question_bank_handler::process_question | ( | array | $data, |
array | $raw | ||
) |
Writes the common <question> data and re-dispateches the whole grouped <QUESTION> data to the qtype for appending its qtype specific data processing.
array | $data | |
array | $raw |
array |
moodle1_question_bank_handler::process_question_category | ( | $data, | |
$raw | |||
) |
Populates the current question category data.
Bacuse of the known subpath-in-the-middle problem (CONTEXT in this case), this is actually called twice for both halves of the data. We merge them here into the currentcategory array.
|
protectedinherited |
Writes the given XML tree data into the currently opened file.
string | $element | the name of the root element of the tree |
array | $data | the associative array of data to write |
array | $attribs | list of additional fields written as attributes instead of nested elements |
string | $parent | used internally during the recursion, do not set yourself |