/** * Parse the array of strings into an array of questions. * Each string is the content of a .dat questions file. * This *could* burn memory - but it won't happen that much * so fingers crossed! * @param array of strings from the input file. * @param stdClass $context * @return array (of objects) question objects. */ public function readquestions($lines) { // Set up array to hold all our questions. $questions = array(); if ($this->filetype == self::FILETYPE_QTI) { $importer = new qformat_blackboard_six_qti(); } else if ($this->filetype == self::FILETYPE_POOL) { $importer = new qformat_blackboard_six_pool(); } else { // In all other cases we are not able to import the file. return false; } $importer->set_filebase($this->filebase); // Each element of $lines is a string containing a complete xml document. foreach ($lines as $text) { $questions = array_merge($questions, $importer->readquestions($text)); } return $questions; }
/** * Parse the array of objects into an array of questions. * Each object is the content of a .dat questions file. * This *could* burn memory - but it won't happen that much * so fingers crossed! * @param array $lines array of qformat_blackboard_six_file objects for each input file. * @return array (of objects) question objects. */ public function readquestions($lines) { // Set up array to hold all our questions. $questions = array(); // Each element of $lines is a qformat_blackboard_six_file object. foreach ($lines as $fileobj) { if ($fileobj->filetype == self::FILETYPE_QTI) { $importer = new qformat_blackboard_six_qti(); } else if ($fileobj->filetype == self::FILETYPE_POOL) { $importer = new qformat_blackboard_six_pool(); } else { // In all other cases we are not able to import the file. debugging('fileobj type not recognised', DEBUG_DEVELOPER); continue; } $importer->set_filebase($fileobj->filebase); $questions = array_merge($questions, $importer->readquestions($fileobj->text)); } return $questions; }
/** * Parse the array of objects into an array of questions. * Each object is the content of a .dat questions file. * This *could* burn memory - but it won't happen that much * so fingers crossed! * @param array $lines array of qformat_blackboard_six_file objects for each input file. * @return array (of objects) question objects. */ public function readquestions($lines) { // Set up array to hold all our questions. $questions = array(); // Each element of $lines is a qformat_blackboard_six_file object. foreach ($lines as $fileobj) { if ($fileobj->filetype == self::FILETYPE_QTI) { $importer = new qformat_blackboard_six_qti(); } else { if ($fileobj->filetype == self::FILETYPE_POOL) { $importer = new qformat_blackboard_six_pool(); } else { // In all other cases we are not able to import the file. debugging('fileobj type not recognised', DEBUG_DEVELOPER); continue; } } $importer->set_filebase($fileobj->filebase); $questions = array_merge($questions, $importer->readquestions($fileobj->text)); } // Give any unnamed categories generated names. $unnamedcount = 0; foreach ($questions as $question) { if ($question->qtype == 'category' && $question->category == '') { $question->category = get_string('importedcategory', 'qformat_blackboard_six', ++$unnamedcount); } } return $questions; }