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

Public Member Functions

 provide_import ()
 importpreprocess ()
 importprocess ($filename, $lesson, $pageid)
 readdata ($filename)
 readquestion ($lines)
 defaultquestion ()
 importpostprocess ()
 provide_import ()
 provide_export ()
 mime_type ()
 export_file_extension ()
 setCategory ($category)
 setQuestions ($questions)
 setCourse ($course)
 setContexts ($contexts)
 setFilename ($filename)
 setRealfilename ($realfilename)
 setMatchgrades ($matchgrades)
 setCatfromfile ($catfromfile)
 setContextfromfile ($contextfromfile)
 setCattofile ($cattofile)
 setContexttofile ($contexttofile)
 setStoponerror ($stoponerror)
 set_can_access_backupdata ($canaccess)
 try_importing_using_qtypes ($data, $question=null, $extra=null, $qtypehint= '')
 importpreprocess ()
 importprocess ($category)
 importpostprocess ()
 exportpreprocess ()
 exportprocess ()

Data Fields

 $displayerrors = true
 $category = NULL
 $questionids = array()
 $qtypeconvert
 $questions = array()
 $course = null
 $filename = ''
 $realfilename = ''
 $matchgrades = 'error'
 $catfromfile = 0
 $contextfromfile = 0
 $cattofile = 0
 $contexttofile = 0
 $importerrors = 0
 $stoponerror = true
 $translator = null
 $canaccessbackupdata = true

Protected Member Functions

 count_questions ($questions)
 readquestions ($lines)
 format_question_text ($question)
 error ($message, $text='', $questionname='')
 count_questions ($questions)
 create_category_path ($catpath)
 readdata ($filename)
 readquestions ($lines, $context)
 defaultquestion ()
 readquestion ($lines)
 try_exporting_using_qtypes ($name, $question, $extra=null)
 presave_process ($content)
 get_category_path ($id, $includecontext=true)
 assemble_category_path ($names)
 split_category_path ($path)
 exportpostprocess ()
 writequestion ($question)
 format_question_text ($question)

Protected Attributes

 $importcontext = null

Detailed Description

#@+ 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.


Member Function Documentation

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

Parameters:
array$names
Returns:
string

Reimplemented in testable_qformat.

Definition at line 812 of file format.php.

Here is the caller graph for this function:

count_questions ( questions) [protected]

Count all non-category questions in the questions array.

Parameters:
arrayquestions An array of question objects.
Returns:
int The count.

Definition at line 449 of file format.php.

count_questions ( questions) [protected]

Count all non-category questions in the questions array.

Parameters:
arrayquestions An array of question objects.
Returns:
int The count.

Definition at line 461 of file format.php.

Here is the caller graph for this function:

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.

Parameters:
stringcatpath delimited category path
intcourseid course to search for categories
Returns:
mixed category object or null if fails

Definition at line 475 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 535 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Returns:
object default question

Definition at line 587 of file format.php.

Here is the call graph for this function:

error ( message,
text = '',
questionname = '' 
) [protected]

Handle parsing error

Definition at line 229 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented in qformat_xml, qformat_xhtml, and qformat_gift.

Definition at line 102 of file format.php.

Here is the caller graph for this function:

exportpostprocess ( ) [protected]

Do an post-processing that may be required

Returns:
bool success

Definition at line 850 of file format.php.

Do any pre-processing that may be required

Parameters:
boolsuccess

Definition at line 672 of file format.php.

Do the export For most types this should not need to be overrided

Returns:
stored_file

Definition at line 692 of file format.php.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

get_category_path ( id,
includecontext = true 
) [protected]

get the category as a path (e.g., tom/dick/harry)

Parameters:
intid the id of the most nested catgory
Returns:
string the path

Definition at line 776 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
bool success

Reimplemented in qformat_blackboard_six.

Definition at line 640 of file format.php.

Perform any required pre-processing

Returns:
bool success

Definition at line 287 of file format.php.

Definition at line 320 of file format.php.

importprocess ( category)

Process the file This method should not normally be overidden

Parameters:
object$category
Returns:
bool success

Definition at line 297 of file format.php.

Here is the call graph for this function:

importprocess ( filename,
lesson,
pageid 
)

Processes a given file. There's probably little need to change this

Definition at line 325 of file format.php.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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 in qformat_xml, and qformat_xhtml.

Definition at line 683 of file format.php.

Here is the caller graph for this function:

Returns:
bool whether this plugin provides export functionality.

Reimplemented in qformat_gift, qformat_xml, and qformat_xhtml.

Definition at line 89 of file format.php.

Returns:
bool whether this plugin provides import functionality.

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.

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.

Here is the caller graph for this function:

readdata ( filename) [protected]

Return complete file within an array, one item per line

Parameters:
stringfilename name of file
Returns:
mixed contents array or false on failure

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.

Here is the caller graph for this function:

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

Parameters:
$linesmixed data that represents question
Returns:
object question object

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
arraylines array of lines from readdata
object$context
Returns:
array array of question objects

Definition at line 552 of file format.php.

Here is the call graph for this function:

set_can_access_backupdata ( canaccess)
Parameters:
bool$canaccessWhether 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

Parameters:
objectcategory the category object

Definition at line 112 of file format.php.

Here is the call graph for this function:

setCatfromfile ( catfromfile)

set catfromfile

Parameters:
boolcatfromfile allow categories embedded in import file

Definition at line 178 of file format.php.

setCattofile ( cattofile)

set cattofile

Parameters:
boolcattofile exports categories within export file

Definition at line 194 of file format.php.

setContextfromfile ( contextfromfile)

set contextfromfile

Parameters:
bool$contextfromfileallow contexts embedded in import file

Definition at line 186 of file format.php.

setContexts ( contexts)

set an array of contexts.

Parameters:
array$contextsMoodle course variable

Definition at line 144 of file format.php.

setContexttofile ( contexttofile)

set contexttofile

Parameters:
boolcattofile exports categories within export file

Definition at line 202 of file format.php.

setCourse ( course)

set the course class variable

Parameters:
courseobject Moodle course variable

Definition at line 136 of file format.php.

setFilename ( filename)

set the filename

Parameters:
stringfilename name of file to import/export

Definition at line 153 of file format.php.

setMatchgrades ( matchgrades)

set matchgrades

Parameters:
stringmatchgrades 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.

Parameters:
arrayof question objects

Definition at line 125 of file format.php.

Here is the call graph for this function:

setRealfilename ( realfilename)

set the "real" filename (this is what the user typed, regardless of wha happened next)

Parameters:
stringrealfilename name of file as typed by user

Definition at line 162 of file format.php.

setStoponerror ( stoponerror)

set stoponerror

Parameters:
boolstoponerror 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.

Parameters:
string$path
Returns:
array of category names.

Reimplemented in testable_qformat.

Definition at line 837 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

try_exporting_using_qtypes ( name,
question,
extra = null 
) [protected]

Provide export functionality for plugin questiontypes Do not override

Parameters:
namequestiontype name
questionobject data to export
extramixed any addition format specific data needed
Returns:
string the data to append to export or false if error (or unhandled)

Definition at line 656 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

try_importing_using_qtypes ( data,
question = null,
extra = null,
qtypehint = '' 
)

Import for questiontype plugins Do not override.

Parameters:
datamixed The segment of data containing the question
questionobject processed (so far) by standard import code if appropriate
extramixed any additional format specific data that may be passed by the format
qtypehinthint about a question type from format
Returns:
object question object suitable for save_options() or false if cannot handle

Definition at line 253 of file format.php.

Here is the call graph for this function:

Here is the caller graph for this function:

writequestion ( question) [protected]

convert a single question object into text output in the given format. This must be overriden

Parameters:
objectquestion question object
Returns:
mixed question export text or null if not implemented

Reimplemented in qformat_xml, qformat_gift, and qformat_xhtml.

Definition at line 861 of file format.php.

Here is the caller graph for this function:


Field Documentation

$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
Initial value:
 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.


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