Moodle  2.2.1
http://www.collinsharper.com
qformat_xml Class Reference
Inheritance diagram for qformat_xml:
Collaboration diagram for qformat_xml:

Public Member Functions

 provide_import ()
 provide_export ()
 mime_type ()
 trans_format ($name)
 trans_single ($name)
 import_text ($text)
 getpath ($xml, $path, $default, $istext=false, $error='')
 import_headers ($question)
 import_answer ($answer, $withanswerfiles=false, $defaultformat= 'html')
 import_combined_feedback ($qo, $questionxml, $withshownumpartscorrect=false)
 import_hint ($hintxml, $defaultformat)
 import_hints ($qo, $questionxml, $withparts=false, $withoptions=false, $defaultformat= 'html')
 import_files ($xml)
 import_multichoice ($question)
 import_multianswer ($question)
 import_truefalse ($question)
 import_shortanswer ($question)
 import_description ($question)
 import_numerical ($question)
 import_match ($question)
 import_essay ($question)
 import_calculated ($question)
 export_file_extension ()
 get_format ($id)
 get_single ($id)
 xml_escape ($string)
 writetext ($raw, $indent=0, $short=true)
 write_files ($files)
 writequestion ($question)
 write_answers ($answers)
 write_answer ($answer, $extra= '')
 write_hints ($question)
 format ($format)
 write_hint ($hint, $contextid)
 write_combined_feedback ($questionoptions, $questionid, $contextid)

Protected Member Functions

 import_category ($question)
 readquestions ($lines)
 get_qtype ($qtype)
 presave_process ($content)

Detailed Description

Importer for Moodle XML question format.

See http://docs.moodle.org/en/Moodle_XML_format for a description of the format.

Definition at line 48 of file format.php.


Member Function Documentation

Returns:
string the file extension (including .) that is normally used for files handled by this plugin.

Reimplemented from qformat_default.

Definition at line 958 of file format.php.

format ( format)
Parameters:
int$formata FORMAT_... constant.
Returns:
string the attribute to add to an XML tag.

Definition at line 1474 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_format ( id)

Convert internal Moodle text format code into human readable form

Parameters:
intid internal code
Returns:
string format text

Definition at line 987 of file format.php.

Here is the caller graph for this function:

get_qtype ( qtype) [protected]

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.)

Parameters:
string$qtypequestion type plugin name.
Returns:
string $qtype string to use in the file.

Definition at line 970 of file format.php.

Here is the caller graph for this function:

get_single ( id)

Convert internal single question code into human readable form

Parameters:
intid single question code
Returns:
string single question string

Definition at line 1010 of file format.php.

Here is the caller graph for this function:

getpath ( xml,
path,
default,
istext = false,
error = '' 
)

return the value of a node, given a path to the node if it doesn't exist return the default value

Parameters:
arrayxml data to read
arraypath path to node expressed as array
mixeddefault
boolistext process as text
stringerror if set value must exist, return false and issue message if not
Returns:
mixed value

Definition at line 128 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_answer ( answer,
withanswerfiles = false,
defaultformat = 'html' 
)

Import the common parts of a single answer

Parameters:
arrayanswer xml tree for single answer
bool$withanswerfilesif true, the answers are HTML (or $defaultformat) and so may contain files, otherwise the answers are plain text.
arrayDefault text format for the feedback, and the answers if $withanswerfiles is true.
Returns:
object answer object

Definition at line 234 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_calculated ( question)

Import a calculated question

Parameters:
object$questionthe imported XML data.

Definition at line 731 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_category ( question) [protected]

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> </question>

Definition at line 877 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_combined_feedback ( qo,
questionxml,
withshownumpartscorrect = false 
)

Import the common overall feedback fields.

Parameters:
object$questionthe part of the XML relating to this question.
object$qothe question data to add the fields to.
bool$withshownumpartscorrectinclude the shownumcorrect field.

Definition at line 267 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_description ( question)

Import description type question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 577 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_essay ( question)

Import essay type question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 704 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_files ( xml)

Import files from a node in the XML.

Parameters:
array$xmlan array of <file> nodes from the the parsed XML.
Returns:
array of things representing files - in the form that save_question expects.

Definition at line 368 of file format.php.

Here is the caller graph for this function:

import_headers ( question)

import parts of question common to all types

Parameters:
$questionarray question question array from xml tree
Returns:
object question object

Definition at line 158 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_hint ( hintxml,
defaultformat 
)

Import a question hint

Parameters:
array$hintxmlhint xml fragment.
string$defaultformatthe text format to assume for hints that do not specify.
Returns:
object hint for storing in the database.

Definition at line 298 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_hints ( qo,
questionxml,
withparts = false,
withoptions = false,
defaultformat = 'html' 
)

Import all the question hints

Parameters:
object$qothe question data that is being constructed.
array$questionxmlThe xml representing the question.
bool$withpartswhether the extra fields relating to parts should be imported.
bool$withoptionswhether the extra options field should be imported.
string$defaultformatthe text format to assume for hints that do not specify.
Returns:
array of objects representing the hints in the file.

Definition at line 342 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_match ( question)

Import matching type question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 667 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_multianswer ( question)

Import cloze type question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 427 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_multichoice ( question)

import multiple choice question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 385 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_numerical ( question)

Import numerical type question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 592 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_shortanswer ( question)

Import short answer type question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 546 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

import_text ( text)

process text string from xml file

Parameters:
array$textbit of xml tree after ['text']
Returns:
string processed text.

Definition at line 109 of file format.php.

Here is the caller graph for this function:

import_truefalse ( question)

Import true/false type question

Parameters:
arrayquestion question array from xml tree
Returns:
object question object

Definition at line 470 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

mime_type ( )

The string mime-type of the files that this plugin reads or writes.

Reimplemented from qformat_default.

Definition at line 58 of file format.php.

presave_process ( content) [protected]

Enable any processing to be done on the content just prior to the file being saved default is to do nothing

Parameters:
stringoutput text
stringprocessed output text

Reimplemented from qformat_default.

Definition at line 1076 of file format.php.

Returns:
bool whether this plugin provides export functionality.

Reimplemented from qformat_default.

Definition at line 54 of file format.php.

Reimplemented from qformat_default.

Definition at line 50 of file format.php.

readquestions ( lines) [protected]

Parse the array of lines into an array of questions this *could* burn memory - but it won't happen that much so fingers crossed!

Parameters:
arrayof lines from the input file.
Returns:
array (of objects) question objects.

Reimplemented from qformat_default.

Definition at line 891 of file format.php.

Here is the call graph for this function:

trans_format ( name)

Translate human readable format name into internal Moodle code number

Parameters:
stringname format name from xml file
Returns:
int Moodle format code

Definition at line 70 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

trans_single ( name)

Translate human readable single answer option to internal code number

Parameters:
stringname true/false
Returns:
int internal code number

Definition at line 95 of file format.php.

Here is the caller graph for this function:

write_answer ( answer,
extra = '' 
)

Definition at line 1438 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

write_answers ( answers)

Definition at line 1427 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

write_combined_feedback ( questionoptions,
questionid,
contextid 
)

Output the combined feedback fields.

Parameters:
object$questionoptionsthe question definition data.
int$questionidthe question id.
int$contextidthe question context id.
Returns:
string XML to output.

Definition at line 1508 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

write_files ( files)

Generte the XML to represent some files.

Parameters:
arrayof store array of stored_file objects.
Returns:
string $string the XML.

Definition at line 1060 of file format.php.

Here is the caller graph for this function:

write_hint ( hint,
contextid 
)

Definition at line 1478 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

write_hints ( question)

Write out the hints.

Parameters:
object$questionthe question definition data.
Returns:
string XML to output.

Definition at line 1458 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

writequestion ( question)

Turns question into an xml segment

Parameters:
object$questionthe question data.
Returns:
string xml segment

Reimplemented from qformat_default.

Definition at line 1088 of file format.php.

Here is the call graph for this function:

writetext ( raw,
indent = 0,
short = true 
)

Generates <text></text> tags, processing raw text therein

Parameters:
string$rawthe content to output.
int$indentthe current indent level.
bool$shortstick it on one line.
Returns:
string formatted text.

Definition at line 1042 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

xml_escape ( string)

Take a string, and wrap it in a CDATA secion, if that is required to make the output XML valid.

Parameters:
string$stringa string
Returns:
string the string, wrapped in CDATA if necessary.

Definition at line 1027 of file format.php.

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations