|
Moodle
2.2.1
http://www.collinsharper.com
|

#@+ The core question types.
These used to be in lib/questionlib.php, but are being deprecated. Copying them here to keep the import/export code working for now (there are 135 references to these constants which I don't want to try to fix at the moment.)#@- Base class for question import and export formats.
Definition at line 303 of file format.php.
| assemble_category_path | ( | $ | names | ) | [protected] |
Convert a list of category names, possibly preceeded by one of the context tokens like $course$, into a string representation of the category path.
Names are separated by / delimiters. And /s in the name are replaced by //.
To reverse the process and split the paths into names, use split_category_path().
| array | $names |
Reimplemented in testable_qformat.
Definition at line 812 of file format.php.

| count_questions | ( | $ | questions | ) | [protected] |
Count all non-category questions in the questions array.
| array | questions An array of question objects. |
Definition at line 449 of file format.php.
| count_questions | ( | $ | questions | ) | [protected] |
Count all non-category questions in the questions array.
| array | questions An array of question objects. |
Definition at line 461 of file format.php.

| create_category_path | ( | $ | catpath | ) | [protected] |
find and/or create the category described by a delimited list e.g. $course$/tom/dick/harry or tom/dick/harry
removes any context string no matter whether $getcontext is set but if $getcontext is set then ignore the context and use selected category context.
| string | catpath delimited category path |
| int | courseid course to search for categories |
Definition at line 475 of file format.php.


| defaultquestion | ( | ) |
Definition at line 535 of file format.php.


| defaultquestion | ( | ) | [protected] |
return an "empty" question Somewhere to specify question parameters that are not handled by import but are required db fields. This should not be overridden.
Definition at line 587 of file format.php.

| error | ( | $ | message, |
| $ | text = '', |
||
| $ | questionname = '' |
||
| ) | [protected] |
Handle parsing error
Definition at line 229 of file format.php.


Reimplemented in qformat_xml, qformat_xhtml, and qformat_gift.
Definition at line 102 of file format.php.

| exportpostprocess | ( | ) | [protected] |
Do an post-processing that may be required
Definition at line 850 of file format.php.
| exportpreprocess | ( | ) |
Do any pre-processing that may be required
| bool | success |
Definition at line 672 of file format.php.
| exportprocess | ( | ) |
Do the export For most types this should not need to be overrided
Definition at line 692 of file format.php.

| format_question_text | ( | $ | question | ) | [protected] |
Convert the question text to plain text, so it can safely be displayed during import to let the user see roughly what is going on.
Definition at line 577 of file format.php.

| format_question_text | ( | $ | question | ) | [protected] |
Convert the question text to plain text, so it can safely be displayed during import to let the user see roughly what is going on.
Definition at line 872 of file format.php.

| get_category_path | ( | $ | id, |
| $ | includecontext = true |
||
| ) | [protected] |
get the category as a path (e.g., tom/dick/harry)
| int | id the id of the most nested catgory |
Definition at line 776 of file format.php.


Does any post-processing that may be desired Argument is a simple array of question ids that have just been added.
Reimplemented in qformat_blackboard_six.
Definition at line 566 of file format.php.
Override if any post-processing is required
Reimplemented in qformat_blackboard_six.
Definition at line 640 of file format.php.
| importpreprocess | ( | ) |
| importpreprocess | ( | ) |
Definition at line 320 of file format.php.
| importprocess | ( | $ | category | ) |
Process the file This method should not normally be overidden
| object | $category |
Definition at line 297 of file format.php.

| importprocess | ( | $ | filename, |
| $ | lesson, | ||
| $ | pageid | ||
| ) |
Processes a given file. There's probably little need to change this
Definition at line 325 of file format.php.

| mime_type | ( | ) |
The string mime-type of the files that this plugin reads or writes.
Reimplemented in qformat_xml.
Definition at line 94 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
| string | output text |
| string | processed output text |
Reimplemented in qformat_xml, and qformat_xhtml.
Definition at line 683 of file format.php.

| provide_export | ( | ) |
Reimplemented in qformat_gift, qformat_xml, and qformat_xhtml.
Definition at line 89 of file format.php.
| provide_import | ( | ) |
Reimplemented in qformat_webct, qformat_gift, qformat_aiken, qformat_examview, qformat_missingword, qformat_xml, qformat_learnwise, qformat_blackboard, qformat_blackboard_six, and qformat_multianswer.
Definition at line 84 of file format.php.
| provide_import | ( | ) |
Reimplemented in qformat_webct, qformat_gift, qformat_aiken, qformat_examview, qformat_missingword, qformat_xml, qformat_learnwise, qformat_blackboard, qformat_blackboard_six, and qformat_multianswer.
Definition at line 316 of file format.php.
| readdata | ( | $ | filename | ) |
Returns complete file with an array, one item per line
Check for Macintosh OS line returns (ie file on one line), and fix
Reimplemented in qformat_blackboard_six.
Definition at line 476 of file format.php.

| readdata | ( | $ | filename | ) | [protected] |
Return complete file within an array, one item per line
| string | filename name of file |
Check for Macintosh OS line returns (ie file on one line), and fix
Reimplemented in qformat_blackboard_six.
Definition at line 525 of file format.php.
| readquestion | ( | $ | lines | ) |
Given an array of lines known to define a question in this format, this function converts it into a question object suitable for processing and insertion into Moodle.
Reimplemented in qformat_examview, qformat_gift, qformat_aiken, qformat_learnwise, and qformat_missingword.
Definition at line 525 of file format.php.

| readquestion | ( | $ | lines | ) | [protected] |
Given the data known to define a question in this format, this function converts it into a question object suitable for processing and insertion into Moodle.
If your format does not use blank lines to delimit questions (e.g. an XML format) you must override 'readquestions' too
| $lines | mixed data that represents question |
Reimplemented in qformat_examview, qformat_gift, qformat_aiken, qformat_learnwise, and qformat_missingword.
Definition at line 628 of file format.php.
| readquestions | ( | $ | lines | ) | [protected] |
Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
Reimplemented in qformat_xml, qformat_blackboard_six, qformat_webct, qformat_examview, qformat_aiken, qformat_learnwise, qformat_blackboard, and qformat_multianswer.
Definition at line 492 of file format.php.


| readquestions | ( | $ | lines, |
| $ | context | ||
| ) | [protected] |
Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
If your format does not use blank lines as a delimiter then you will need to override this method. Even then try to use readquestion for each question
| array | lines array of lines from readdata | |
| object | $context |
Definition at line 552 of file format.php.

| set_can_access_backupdata | ( | $ | canaccess | ) |
| bool | $canaccess | Whether the current use can access the backup data folder. Determines where export files are saved. |
Definition at line 218 of file format.php.
| setCategory | ( | $ | category | ) |
set the category
| object | category the category object |
Definition at line 112 of file format.php.

| setCatfromfile | ( | $ | catfromfile | ) |
set catfromfile
| bool | catfromfile allow categories embedded in import file |
Definition at line 178 of file format.php.
| setCattofile | ( | $ | cattofile | ) |
set cattofile
| bool | cattofile exports categories within export file |
Definition at line 194 of file format.php.
| setContextfromfile | ( | $ | contextfromfile | ) |
set contextfromfile
| bool | $contextfromfile | allow contexts embedded in import file |
Definition at line 186 of file format.php.
| setContexts | ( | $ | contexts | ) |
set an array of contexts.
| array | $contexts | Moodle course variable |
Definition at line 144 of file format.php.
| setContexttofile | ( | $ | contexttofile | ) |
set contexttofile
| bool | cattofile exports categories within export file |
Definition at line 202 of file format.php.
| setCourse | ( | $ | course | ) |
set the course class variable
| course | object Moodle course variable |
Definition at line 136 of file format.php.
| setFilename | ( | $ | filename | ) |
set the filename
| string | filename name of file to import/export |
Definition at line 153 of file format.php.
| setMatchgrades | ( | $ | matchgrades | ) |
set matchgrades
| string | matchgrades error or nearest for grades |
Definition at line 170 of file format.php.
| setQuestions | ( | $ | questions | ) |
Set the specific questions to export. Should not include questions with parents (sub questions of cloze question type). Only used for question export.
| array | of question objects |
Definition at line 125 of file format.php.

| setRealfilename | ( | $ | realfilename | ) |
set the "real" filename (this is what the user typed, regardless of wha happened next)
| string | realfilename name of file as typed by user |
Definition at line 162 of file format.php.
| setStoponerror | ( | $ | stoponerror | ) |
set stoponerror
| bool | stoponerror stops database write if any errors reported |
Definition at line 210 of file format.php.
| split_category_path | ( | $ | path | ) | [protected] |
Convert a string, as returned by assemble_category_path(), back into an array of category names.
Each category name is cleaned by a call to clean_param(, PARAM_MULTILANG), which matches the cleaning in question/category_form.php.
| string | $path |
Reimplemented in testable_qformat.
Definition at line 837 of file format.php.


| try_exporting_using_qtypes | ( | $ | name, |
| $ | question, | ||
| $ | extra = null |
||
| ) | [protected] |
Provide export functionality for plugin questiontypes Do not override
| name | questiontype name |
| question | object data to export |
| extra | mixed any addition format specific data needed |
Definition at line 656 of file format.php.


| try_importing_using_qtypes | ( | $ | data, |
| $ | question = null, |
||
| $ | extra = null, |
||
| $ | qtypehint = '' |
||
| ) |
Import for questiontype plugins Do not override.
| data | mixed The segment of data containing the question |
| question | object processed (so far) by standard import code if appropriate |
| extra | mixed any additional format specific data that may be passed by the format |
| qtypehint | hint about a question type from format |
Definition at line 253 of file format.php.


| writequestion | ( | $ | question | ) | [protected] |
convert a single question object into text output in the given format. This must be overriden
| object | question question object |
Reimplemented in qformat_xml, qformat_gift, and qformat_xhtml.
Definition at line 861 of file format.php.

| $canaccessbackupdata = true |
Definition at line 76 of file format.php.
| $category = NULL |
Definition at line 306 of file format.php.
| $catfromfile = 0 |
Definition at line 68 of file format.php.
| $cattofile = 0 |
Definition at line 70 of file format.php.
| $contextfromfile = 0 |
Definition at line 69 of file format.php.
| $contexttofile = 0 |
Definition at line 71 of file format.php.
| $course = null |
Definition at line 64 of file format.php.
| $displayerrors = true |
Definition at line 305 of file format.php.
| $filename = '' |
Definition at line 65 of file format.php.
$importcontext = null [protected] |
Definition at line 78 of file format.php.
| $importerrors = 0 |
Definition at line 73 of file format.php.
| $matchgrades = 'error' |
Definition at line 67 of file format.php.
| $qtypeconvert |
array(NUMERICAL => LESSON_PAGE_NUMERICAL, MULTICHOICE => LESSON_PAGE_MULTICHOICE, TRUEFALSE => LESSON_PAGE_TRUEFALSE, SHORTANSWER => LESSON_PAGE_SHORTANSWER, MATCH => LESSON_PAGE_MATCHING )
Definition at line 308 of file format.php.
| $questionids = array() |
Definition at line 307 of file format.php.
Definition at line 63 of file format.php.
| $realfilename = '' |
Definition at line 66 of file format.php.
| $stoponerror = true |
Definition at line 74 of file format.php.
| $translator = null |
Definition at line 75 of file format.php.