Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
Code for exporting questions as Moodle XML.
Copyright: | 1999 onwards Martin Dougiamas {@link http://moodle.com} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1677 lines (71 kb) |
Included or required: | 0 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
qformat_xml:: (45 methods):
provide_import()
provide_export()
mime_type()
validate_file()
trans_format()
trans_single()
import_text()
getpath()
import_text_with_files()
import_files_as_draft()
import_headers()
import_answer()
import_combined_feedback()
import_hint()
import_hints()
import_question_tags()
import_files()
import_multichoice()
import_multianswer()
import_truefalse()
import_shortanswer()
import_description()
import_numerical()
import_match()
import_essay()
import_calculated()
import_category()
readquestions()
import_questions()
import_question()
export_file_extension()
get_qtype()
get_format()
get_single()
xml_escape()
writetext()
write_files()
presave_process()
writequestion()
write_answers()
write_answer()
write_hints()
format()
write_hint()
write_combined_feedback()
Class: qformat_xml - X-Ref
Importer for Moodle XML question format.provide_import() X-Ref |
No description |
provide_export() X-Ref |
No description |
mime_type() X-Ref |
No description |
validate_file(stored_file $file) X-Ref |
Validate the given file. For more expensive or detailed integrity checks. param: stored_file $file the file to check return: string the error message that occurred while validating the given file |
trans_format($name) X-Ref |
Translate human readable format name into internal Moodle code number Note the reverse function is called get_format. param: string name format name from xml file return: int Moodle format code |
trans_single($name) X-Ref |
Translate human readable single answer option to internal code number param: string name true/false return: int internal code number |
import_text($text) X-Ref |
process text string from xml file param: array $text bit of xml tree after ['text'] return: string processed text. |
getpath($xml, $path, $default, $istext=false, $error='') X-Ref |
return the value of a node, given a path to the node if it doesn't exist return the default value param: array xml data to read param: array path path to node expressed as array param: mixed default param: bool istext process as text param: string error if set value must exist, return false and issue message if not return: mixed value |
import_text_with_files($data, $path, $defaultvalue = '', $defaultformat = 'html') X-Ref |
No description |
import_files_as_draft($xml) X-Ref |
No description |
import_headers($question) X-Ref |
import parts of question common to all types param: $question array question question array from xml tree return: object question object |
import_answer($answer, $withanswerfiles = false, $defaultformat = 'html') X-Ref |
Import the common parts of a single answer param: array answer xml tree for single answer param: bool $withanswerfiles if true, the answers are HTML (or $defaultformat) param: array Default text format for the feedback, and the answers if $withanswerfiles return: object answer object |
import_combined_feedback($qo, $questionxml, $withshownumpartscorrect = false) X-Ref |
Import the common overall feedback fields. param: object $question the part of the XML relating to this question. param: object $qo the question data to add the fields to. param: bool $withshownumpartscorrect include the shownumcorrect field. |
import_hint($hintxml, $defaultformat) X-Ref |
Import a question hint param: array $hintxml hint xml fragment. param: string $defaultformat the text format to assume for hints that do not specify. return: object hint for storing in the database. |
import_hints($qo, $questionxml, $withparts = false,$withoptions = false, $defaultformat = 'html') X-Ref |
Import all the question hints param: object $qo the question data that is being constructed. param: array $questionxml The xml representing the question. param: bool $withparts whether the extra fields relating to parts should be imported. param: bool $withoptions whether the extra options field should be imported. param: string $defaultformat the text format to assume for hints that do not specify. return: array of objects representing the hints in the file. |
import_question_tags($qo, $questionxml) X-Ref |
Import all the question tags param: object $qo the question data that is being constructed. param: array $questionxml The xml representing the question. return: array of objects representing the tags in the file. |
import_files($xml) X-Ref |
Import files from a node in the XML. param: array $xml an array of <file> nodes from the the parsed XML. return: array of things representing files - in the form that save_question expects. |
import_multichoice($question) X-Ref |
import multiple choice question param: array question question array from xml tree return: object question object |
import_multianswer($question) X-Ref |
Import cloze type question param: array question question array from xml tree return: object question object |
import_truefalse($question) X-Ref |
Import true/false type question param: array question question array from xml tree return: object question object |
import_shortanswer($question) X-Ref |
Import short answer type question param: array question question array from xml tree return: object question object |
import_description($question) X-Ref |
Import description type question param: array question question array from xml tree return: object question object |
import_numerical($question) X-Ref |
Import numerical type question param: array question question array from xml tree return: object question object |
import_match($question) X-Ref |
Import matching type question param: array question question array from xml tree return: object question object |
import_essay($question) X-Ref |
Import essay type question param: array question question array from xml tree return: object question object |
import_calculated($question) X-Ref |
Import a calculated question param: object $question the imported XML data. |
import_category($question) X-Ref |
This is not a real question type. It's a dummy type used to specify the import category. The format is: <question type="category"> <category>tom/dick/harry</category> <info format="moodle_auto_format"><text>Category description</text></info> </question> |
readquestions($lines) X-Ref |
Parse the array of lines into an array of questions this *could* burn memory - but it won't happen that much so fingers crossed! param: array of lines from the input file. param: stdClass $context return: array (of objects) question objects. |
import_questions($xml) X-Ref |
param: array $xml the xmlized xml return: stdClass[] question objects to pass to question type save_question_options |
import_question($questionxml) X-Ref |
param: array $questionxml xml describing the question return: null|stdClass an object with data to be fed to question type save_question_options |
export_file_extension() X-Ref |
No description |
get_qtype($qtype) X-Ref |
Turn the internal question type name into a human readable form. (In the past, the code used to use integers internally. Now, it uses strings, so there is less need for this, but to maintain backwards-compatibility we change two of the type names.) param: string $qtype question type plugin name. return: string $qtype string to use in the file. |
get_format($id) X-Ref |
Convert internal Moodle text format code into human readable form param: int id internal code return: string format text |
get_single($id) X-Ref |
Convert internal single question code into human readable form param: int id single question code return: string single question string |
xml_escape($string) X-Ref |
Take a string, and wrap it in a CDATA secion, if that is required to make the output XML valid. param: string $string a string return: string the string, wrapped in CDATA if necessary. |
writetext($raw, $indent = 0, $short = true) X-Ref |
Generates <text></text> tags, processing raw text therein param: string $raw the content to output. param: int $indent the current indent level. param: bool $short stick it on one line. return: string formatted text. |
write_files($files) X-Ref |
Generte the XML to represent some files. param: array of store array of stored_file objects. return: string $string the XML. |
presave_process($content) X-Ref |
No description |
writequestion($question) X-Ref |
Turns question into an xml segment param: object $question the question data. return: string xml segment |
write_answers($answers) X-Ref |
No description |
write_answer($answer, $extra = '') X-Ref |
No description |
write_hints($question) X-Ref |
Write out the hints. param: object $question the question definition data. return: string XML to output. |
format($format) X-Ref |
param: int $format a FORMAT_... constant. return: string the attribute to add to an XML tag. |
write_hint($hint, $contextid) X-Ref |
No description |
write_combined_feedback($questionoptions, $questionid, $contextid) X-Ref |
Output the combined feedback fields. param: object $questionoptions the question definition data. param: int $questionid the question id. param: int $contextid the question context id. return: string XML to output. |