|
Moodle PHP Documentation 4.5
Moodle 4.5.5+ (Build: 20250711) (ce34e8ff087)
|
Blackboard 6.0 question importer. More...
Public Member Functions | |
| can_import_file ($file) | |
| Check if the given file is capable of being imported by this plugin. | |
| clean_question_name ($name) | |
| Ensure that a question name does not contain anything nasty, and will fit in the DB field. | |
| clean_question_name ($name) | |
| Ensure that a question name does not contain anything nasty, and will fit in the DB field. | |
| cleaned_text_field ($text) | |
| Same as text_field but text is cleaned. | |
| cleaninput ($str) | |
| A lot of imported files contain unwanted entities. | |
| cleaninput ($str) | |
| A lot of imported files contain unwanted entities. | |
| create_default_question_name ($questiontext, $default) | |
| Construct a reasonable default question name, based on the start of the question text. | |
| create_default_question_name ($questiontext, $default) | |
| Construct a reasonable default question name, based on the start of the question text. | |
| create_raw_question ($quest) | |
| Creates a cleaner object to deal with for processing into Moodle. | |
| export_file_extension () | |
| exportpreprocess () | |
| Do any pre-processing that may be required. | |
| exportprocess ($checkcapabilities=true) | |
| Perform the export. | |
| 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. | |
| 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. | |
| importpostprocess () | |
| Does any post-processing that may be desired Clean the temporary directory if a zip file was imported. | |
| importpreprocess () | |
| importpreprocess () | |
| Perform any required pre-processing. | |
| importprocess ($filename, $lesson, $pageid) | |
| importprocess () | |
| Process the file This method should not normally be overidden. | |
| mime_type () | |
| The string mime-type of the files that this plugin reads or writes. | |
| process_block ($curblock, $block) | |
| Helper function to process an XML block into an object. | |
| process_category ($xml, &$questions) | |
| Add a category question entry based on the assessment title. | |
| process_common ($quest) | |
| Create common parts of question. | |
| process_essay ($quest, &$questions) | |
| Process Essay Questions Parse an essay rawquestion and add the result to the array of questions already parsed. | |
| process_feedback ($feedbackset, &$feedbacks) | |
| Preprocess XML blocks containing data for responses feedbacks. | |
| process_ma ($quest, &$questions) | |
| Process Multiple Choice Questions With Multiple Answers. | |
| process_matching ($quest, &$questions) | |
| Process Matching Questions Parse a matching rawquestion and add the result to the array of questions already parsed. | |
| provide_export () | |
| provide_import () | |
| This plugin provide import. | |
| readdata ($filename) | |
| set_can_access_backupdata ($canaccess) | |
| set_display_progress ($displayprogress) | |
| Change whether to display progress messages. | |
| set_filebase ($path) | |
| Set the path to the root of images tree. | |
| set_importcontext ($context) | |
| setCategory ($category) | |
| set the category | |
| setCatfromfile ($catfromfile) | |
| set catfromfile | |
| setCattofile ($cattofile) | |
| set cattofile | |
| setContextfromfile ($contextfromfile) | |
| set contextfromfile | |
| setContexts ($contexts) | |
| set an array of contexts. | |
| setContexttofile ($contexttofile) | |
| set contexttofile | |
| setCourse ($course) | |
| set the course class variable | |
| setFilename ($filename) | |
| set the filename | |
| setMatchgrades ($matchgrades) | |
| set matchgrades | |
| setQuestions ($questions) | |
| Set the specific questions to export. | |
| setRealfilename ($realfilename) | |
| set the "real" filename (this is what the user typed, regardless of wha happened next) | |
| setStoponerror ($stoponerror) | |
| set stoponerror | |
| strip_applet_tags_get_mathml ($string) | |
| Strip the applet tag used by Blackboard to render mathml formulas, keeping the mathml tag. | |
| text_field ($text) | |
| Given an HTML text with references to images files, store all images in a draft filearea, and return an array with all urls in text recoded, format set to FORMAT_HTML, and itemid set to filearea itemid. | |
| try_importing_using_qtypes ($data, $question=null, $extra=null, $qtypehint='') | |
| Import for questiontype plugins. | |
| try_importing_using_qtypes ($data, $question=null, $extra=null, $qtypehint='') | |
| Import for questiontype plugins Do not override. | |
| validate_file (stored_file $file) | |
| Validate the given file. | |
Public Attributes | |
| $canaccessbackupdata = true | |
| $category = null | |
| $catfromfile = 0 | |
| $cattofile = 0 | |
| $contextfromfile = 0 | |
| context[] | $contexts |
| $contexttofile = 0 | |
| $course = null | |
| $displayerrors = true | |
| bool | $displayprogress = true |
| $displayprogress Whether to display progress. | |
| string | $filebase = '' |
| path to path to root of image tree in unzipped archive. | |
| $filename = '' | |
| $importerrors = 0 | |
| $matchgrades = 'error' | |
| $qtypeconvert | |
| $questionids = array() | |
| $questions = array() | |
| $realfilename = '' | |
| $stoponerror = true | |
| string | $tempdir = '' |
| path to the temporary directory. | |
| $translator = null | |
Protected Member Functions | |
| add_blank_combined_feedback ($question) | |
| Since the lesson module tries to re-use the question bank import classes in a crazy way, this is necessary to stop things breaking. | |
| add_blank_combined_feedback ($question) | |
| Add a blank combined feedback to a question object. | |
| assemble_category_path ($names) | |
| Convert a list of category names, possibly preceeded by one of the context tokens like $course$, into a string representation of the category path. | |
| count_questions ($questions) | |
| Count all non-category questions in the questions array. | |
| count_questions ($questions) | |
| Count all non-category questions in the questions array. | |
| create_category_path ($catpath, $lastcategoryinfo=null) | |
| find and/or create the category described by a delimited list e.g. | |
| create_dummy_question_representing_category (string $categoryname, $categoryinfo) | |
| Create 'dummy' question for category export. | |
| defaultquestion () | |
| return an "empty" question Somewhere to specify question parameters that are not handled by import but are required db fields. | |
| defaultquestion () | |
| return an "empty" question Somewhere to specify question parameters that are not handled by import but are required db fields. | |
| error ($message, $text='', $questionname='') | |
| Handle parsing error. | |
| error ($message, $text='', $questionname='') | |
| Handle parsing error. | |
| exportpostprocess () | |
| Do an post-processing that may be required. | |
| format_question_text ($question) | |
| 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. | |
| format_question_text ($question) | |
| 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. | |
| get_category_path ($id, $includecontext=true) | |
| get the category as a path (e.g., tom/dick/harry) | |
| get_name () | |
| Return the localized pluginname string for the question format. | |
| presave_process ($content) | |
| Enable any processing to be done on the content just prior to the file being saved default is to do nothing. | |
| process_choices ($bbchoices, &$choices) | |
| Preprocess XML blocks containing data for questions' choices. | |
| process_fblank ($quest, &$questions) | |
| Process Fill in the Blank Questions Parse a fillintheblank rawquestion and add the result to the array of questions already parsed. | |
| process_matching_responses ($bbresponses, &$responses) | |
| Preprocess XML blocks containing data for subanswers Called by create_raw_question() for matching questions only. | |
| process_mc ($quest, &$questions) | |
| Process Multichoice Questions Parse a multichoice single answer rawquestion and add the result to the array of questions already parsed. | |
| process_responses ($bbresponses, &$responses) | |
| Preprocess XML blocks containing data for responses processing. | |
| process_tf ($quest, &$questions) | |
| Process True / False Questions Parse a truefalse rawquestion and add the result to the array of questions already parsed. | |
| readdata ($filename) | |
| Return complete file within an array, one item per line. | |
| readquestion ($lines) | |
| readquestion ($lines) | |
| 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. | |
| readquestions ($text) | |
| Parse the xml document into an array of questions this could burn memory - but it won't happen that much so fingers crossed! | |
| split_category_path ($path) | |
| Convert a string, as returned by assemble_category_path(), back into an array of category names. | |
| store_file_for_text_field (&$text, $tempdir, $filepathinsidetempdir, $filename) | |
| Store an image file in a draft filearea. | |
| try_exporting_using_qtypes ($name, $question, $extra=null) | |
| Provide export functionality for plugin questiontypes Do not override. | |
| validate_is_utf8_file (stored_file $file) | |
| Check if the given file has the required utf8 encoding. | |
| writequestion ($question) | |
| convert a single question object into text output in the given format. | |
Protected Attributes | |
| $importcontext = null | |
Blackboard 6.0 question importer.
|
protectedinherited |
Add a blank combined feedback to a question object.
| object | question |
| object | question |
|
protectedinherited |
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 |
| string |
|
inherited |
Check if the given file is capable of being imported by this plugin.
As file_storage::mimetype() may use finfo PHP extension if available, the value returned by $file->get_mimetype for a .dat file is not the same on all servers. So we must made 2 checks to verify if the plugin can import the file.
| stored_file | $file | the file to check |
| bool | whether this plugin can import the file |
Reimplemented from qformat_default.
|
inherited |
Ensure that a question name does not contain anything nasty, and will fit in the DB field.
| string | $name | the raw question name. |
| string | a safe question name. |
|
inherited |
Ensure that a question name does not contain anything nasty, and will fit in the DB field.
| string | $name | the raw question name. |
| string | a safe question name. |
|
inherited |
Same as text_field but text is cleaned.
| string | $text | text to parse and recode |
| array | with keys text, format, itemid. |
|
inherited |
A lot of imported files contain unwanted entities.
This method tries to clean up all known problems.
| string | str string to correct |
| string | the corrected string |
|
inherited |
A lot of imported files contain unwanted entities.
This method tries to clean up all known problems.
| string | str string to correct |
| string | the corrected string |
|
protectedinherited |
Count all non-category questions in the questions array.
| array | questions An array of question objects. |
| int | The count. |
|
protectedinherited |
Count all non-category questions in the questions array.
| array | questions An array of question objects. |
| int | The count. |
|
protectedinherited |
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 | |
| object | $lastcategoryinfo | Contains category information |
| mixed | category object or null if fails |
|
inherited |
Construct a reasonable default question name, based on the start of the question text.
| string | $questiontext | the question text. |
| string | $default | default question name to use if the constructed one comes out blank. |
| string | a reasonable question name. |
|
inherited |
Construct a reasonable default question name, based on the start of the question text.
| string | $questiontext | the question text. |
| string | $default | default question name to use if the constructed one comes out blank. |
| string | a reasonable question name. |
|
protectedinherited |
Create 'dummy' question for category export.
| string | $categoryname | the name of the category |
| object | $categoryinfo | description of the category |
| stdClass | 'dummy' question for category |
| qformat_blackboard_six_qti::create_raw_question | ( | $quest | ) |
Creates a cleaner object to deal with for processing into Moodle.
The object returned is NOT a moodle question object.
| array | $quest | XML question data |
| object | rawquestion |
|
protectedinherited |
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.
| object | default question |
|
protectedinherited |
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.
| object | default question |
|
protectedinherited |
Handle parsing error.
| string | $message | information about error |
| string | $text | imported text that triggered the error |
| string | $questionname | imported question name |
|
inherited |
| string | the file extension (including .) that is normally used for files handled by this plugin. |
Reimplemented in qformat_gift, and qformat_xml.
|
protectedinherited |
Do an post-processing that may be required.
| bool | success |
|
inherited |
|
inherited |
Perform the export.
For most types this should not need to be overrided.
| bool | $checkcapabilities | Whether to check capabilities when exporting the questions. |
| string | The content of the export. |
|
protectedinherited |
get the category as a path (e.g., tom/dick/harry)
| int | id the id of the most nested catgory |
| string | the path |
|
protectedinherited |
Return the localized pluginname string for the question format.
| string | the pluginname string for the question format |
|
inherited |
Return the value of a node, given a path to the node if it doesn't exist return the default value.
| array | xml data to read |
| array | path path to node expressed as array |
| mixed | default |
| bool | istext process as text |
| string | error if set value must exist, return false and issue message if not |
| mixed | value |
|
inherited |
Return the value of a node, given a path to the node if it doesn't exist return the default value.
| array | xml data to read |
| array | path path to node expressed as array |
| mixed | default |
| bool | istext process as text |
| string | error if set value must exist, return false and issue message if not |
| mixed | value |
|
inherited |
Does any post-processing that may be desired Clean the temporary directory if a zip file was imported.
| bool | success |
Reimplemented from qformat_default.
|
inherited |
Perform any required pre-processing.
| bool | success |
|
inherited |
Process the file This method should not normally be overidden.
| bool | success |
|
inherited |
The string mime-type of the files that this plugin reads or writes.
Reimplemented from qformat_default.
|
protectedinherited |
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.
| qformat_blackboard_six_qti::process_block | ( | $curblock, | |
| $block ) |
Helper function to process an XML block into an object.
Can call himself recursively if necessary to parse this branch of the XML tree.
| array | $curblock | XML block to parse |
| object | $block | block already parsed so far |
| object#$block | parsed |
| qformat_blackboard_six_qti::process_category | ( | $xml, | |
| & | $questions ) |
Add a category question entry based on the assessment title.
| array | $xml | the xml tree |
| array | $questions | the questions already parsed |
|
protected |
Preprocess XML blocks containing data for questions' choices.
Called by create_raw_question() for matching, multichoice and fill in the blank questions.
| array | $bbchoices | XML block to parse |
| array | $choices | array of choices suitable for a rawquestion. |
| qformat_blackboard_six_qti::process_common | ( | $quest | ) |
Create common parts of question.
| object | $quest | rawquestion |
| object | Moodle question. |
| qformat_blackboard_six_qti::process_essay | ( | $quest, | |
| & | $questions ) |
Process Essay Questions Parse an essay rawquestion and add the result to the array of questions already parsed.
| object | $quest | rawquestion |
| array | $questions | array of Moodle questions already done. |
|
protected |
Process Fill in the Blank Questions Parse a fillintheblank rawquestion and add the result to the array of questions already parsed.
| object | $quest | rawquestion |
| array | $questions | array of Moodle questions already done. |
| qformat_blackboard_six_qti::process_feedback | ( | $feedbackset, | |
| & | $feedbacks ) |
Preprocess XML blocks containing data for responses feedbacks.
Called by create_raw_question() for all questions types.
| array | $feedbackset | XML block to parse |
| array | $feedbacks | array of feedbacks suitable for a rawquestion. |
| qformat_blackboard_six_qti::process_ma | ( | $quest, | |
| & | $questions ) |
Process Multiple Choice Questions With Multiple Answers.
Parse a multichoice multianswer rawquestion and add the result to the array of questions already parsed.
| object | $quest | rawquestion |
| array | $questions | array of Moodle questions already done. |
| qformat_blackboard_six_qti::process_matching | ( | $quest, | |
| & | $questions ) |
Process Matching Questions Parse a matching rawquestion and add the result to the array of questions already parsed.
| object | $quest | rawquestion |
| array | $questions | array of Moodle questions already done. |
|
protected |
Preprocess XML blocks containing data for subanswers Called by create_raw_question() for matching questions only.
| array | $bbresponses | XML block to parse |
| array | $responses | array of responses suitable for a matching rawquestion. |
|
protected |
Process Multichoice Questions Parse a multichoice single answer rawquestion and add the result to the array of questions already parsed.
| object | $quest | rawquestion |
| array | $questions | array of Moodle questions already done. |
|
protected |
Preprocess XML blocks containing data for responses processing.
Called by create_raw_question() for all questions types.
| array | $bbresponses | XML block to parse |
| array | $responses | array of responses suitable for a rawquestion. |
|
protected |
Process True / False Questions Parse a truefalse rawquestion and add the result to the array of questions already parsed.
| object | $quest | rawquestion |
| array | $questions | array of Moodle questions already done |
|
inherited |
| bool | whether this plugin provides export functionality. |
Reimplemented in qformat_aiken, qformat_gift, and qformat_xml.
|
inherited |
|
inherited |
Reimplemented in qformat_blackboard_six.
|
protectedinherited |
Return complete file within an array, one item per line.
| string | filename name of file |
| mixed | contents array or false on failure |
Reimplemented in qformat_blackboard_six.
|
protectedinherited |
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 |
| object | question object |
|
protected |
Parse the xml document into an array of questions this could burn memory - but it won't happen that much so fingers crossed!
| array | $text | array of lines from the input file. |
| array | (of objects) questions objects. |
Reimplemented from qformat_default.
|
inherited |
| bool | $canaccess | Whether the current use can access the backup data folder. Determines where export files are saved. |
|
inherited |
Change whether to display progress messages.
There is normally no need to use this function as the default for $displayprogress is true. Set to false for unit tests.
| bool | $displayprogress |
|
inherited |
Set the path to the root of images tree.
| string | $path | path to images root |
|
inherited |
set the category
| object | category the category object |
|
inherited |
set catfromfile
| bool | catfromfile allow categories embedded in import file |
|
inherited |
set cattofile
| bool | cattofile exports categories within export file |
|
inherited |
set contextfromfile
| bool | $contextfromfile | allow contexts embedded in import file |
|
inherited |
set an array of contexts.
| context[] | $contexts |
|
inherited |
set contexttofile
| bool | cattofile exports categories within export file |
|
inherited |
set the course class variable
| course | object Moodle course variable |
|
inherited |
set the filename
| string | filename name of file to import/export |
|
inherited |
set matchgrades
| string | matchgrades error or nearest for grades |
|
inherited |
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 |
|
inherited |
set the "real" filename (this is what the user typed, regardless of wha happened next)
| string | realfilename name of file as typed by user |
|
inherited |
set stoponerror
| bool | stoponerror stops database write if any errors reported |
|
protectedinherited |
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_TEXT), which matches the cleaning in question/bank/managecategories/category_form.php.
| string | $path |
| array | of category names. |
|
protectedinherited |
Store an image file in a draft filearea.
| array | $text,if | itemid element don't exists it will be created |
| string | $tempdir | path to root of image tree |
| string | $filepathinsidetempdir | path to image in the tree |
| string | $filename | image's name |
| string | new name of the image as it was stored |
| qformat_blackboard_six_qti::strip_applet_tags_get_mathml | ( | $string | ) |
Strip the applet tag used by Blackboard to render mathml formulas, keeping the mathml tag.
| string | $string |
| string |
|
inherited |
Given an HTML text with references to images files, store all images in a draft filearea, and return an array with all urls in text recoded, format set to FORMAT_HTML, and itemid set to filearea itemid.
| string | $text | text to parse and recode |
| array | with keys text, format, itemid. |
Reimplemented from qformat_based_on_xml.
|
protectedinherited |
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 |
| string | the data to append to export or false if error (or unhandled) |
|
inherited |
Import for questiontype plugins.
| mixed | $data | The segment of data containing the question |
| object | $question | processed (so far) by standard import code if appropriate |
| object | $extra | mixed any additional format specific data that may be passed by the format |
| string | $qtypehint | hint about a question type from format |
| object | question object suitable for save_options() or false if cannot handle |
|
inherited |
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 |
| object | question object suitable for save_options() or false if cannot handle |
|
inherited |
Validate the given file.
For more expensive or detailed integrity checks.
| stored_file | $file | the file to check |
| string | the error message that occurred while validating the given file |
Reimplemented in qformat_aiken, qformat_gift, qformat_missingword, qformat_multianswer, and qformat_xml.
|
protectedinherited |
Check if the given file has the required utf8 encoding.
| stored_file | $file | the file to check |
| string | the error message if the file encoding is not UTF-8 |
|
protectedinherited |
convert a single question object into text output in the given format.
This must be overriden
| object | question question object |
| mixed | question export text or null if not implemented |
Reimplemented in qformat_aiken, qformat_gift, and qformat_xml.
|
inherited |