\n";
echo "
$importerrorquestion $questionname";
if (!empty($text)) {
$text = s($text);
echo "
$text
\n";
}
echo "
$message\n";
echo "
";
}
/**
* Import for questiontype plugins
* @param mixed $data The segment of data containing the question
* @param object $question processed (so far) by standard import code if appropriate
* @param object $extra mixed any additional format specific data that may be passed by the format
* @param string $qtypehint hint about a question type from format
* @return object question object suitable for save_options() or false if cannot handle
*/
public function try_importing_using_qtypes($data, $question = null, $extra = null,
$qtypehint = '') {
return false;
}
function importpreprocess() {
// Does any pre-processing that may be desired
return true;
}
function importprocess($filename, $lesson, $pageid) {
global $DB, $OUTPUT;
/// Processes a given file. There's probably little need to change this
$timenow = time();
if (! $lines = $this->readdata($filename)) {
echo $OUTPUT->notification("File could not be read, or was empty");
return false;
}
if (! $questions = $this->readquestions($lines)) { // Extract all the questions
echo $OUTPUT->notification("There are no questions in this file!");
return false;
}
//Avoid category as question type
echo $OUTPUT->notification(get_string('importcount', 'lesson',
$this->count_questions($questions)), 'notifysuccess');
$count = 0;
$addquestionontop = false;
if ($pageid == 0) {
$addquestionontop = true;
$updatelessonpage = $DB->get_record('lesson_pages', array('lessonid' => $lesson->id, 'prevpageid' => 0));
} else {
$updatelessonpage = $DB->get_record('lesson_pages', array('lessonid' => $lesson->id, 'id' => $pageid));
}
$unsupportedquestions = 0;
foreach ($questions as $question) { // Process and store each question
switch ($question->qtype) {
//TODO: Bad way to bypass category in data... Quickfix for MDL-27964
case 'category':
break;
// the good ones
case 'shortanswer' :
case 'numerical' :
case 'truefalse' :
case 'multichoice' :
case 'match' :
case 'essay' :
$count++;
//Show nice formated question in one line.
echo "