function qformat_default::try_importing_using_qtypes in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/question/format.php \qformat_default::try_importing_using_qtypes()
Import for questiontype plugins Do not override.
Parameters
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:
Return value
object question object suitable for save_options() or false if cannot handle
2 calls to qformat_default::try_importing_using_qtypes()
- qformat_gift::readquestion in includes/
moodle/ question/ format/ gift/ format.php - 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.
- qformat_xml::readquestions in includes/
moodle/ question/ format/ xml/ format.php - parse the array of lines into an array of questions this *could* burn memory - but it won't happen that much so fingers crossed!
File
- includes/
moodle/ question/ format.php, line 186
Class
- qformat_default
- Base class for question import and export formats.
Code
function try_importing_using_qtypes($data, $question = null, $extra = null) {
global $QTYPES;
// work out what format we are using
$formatname = substr(get_class($this), strlen('qformat_'));
$methodname = "import_from_{$formatname}";
// loop through installed questiontypes checking for
// function to handle this question
$QTYPES = isset($QTYPES) ? $QTYPES : array();
foreach ($QTYPES as $qtype) {
if (method_exists($qtype, $methodname)) {
if ($question = $qtype
->{$methodname}($data, $question, $this, $extra)) {
return $question;
}
}
}
return false;
}