function qformat_examview::readquestion in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/question/format/examview/format.php \qformat_examview::readquestion()
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
$lines mixed data that represents question:
Return value
object question object
Overrides qformat_default::readquestion
1 call to qformat_examview::readquestion()
- qformat_examview::readquestions in includes/
moodle/ question/ format/ examview/ format.php - 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.
File
- includes/
moodle/ question/ format/ examview/ format.php, line 153
Class
Code
function readquestion($qrec) {
$type = trim($qrec['@']['type']);
$question = $this
->defaultquestion();
if (array_key_exists($type, $this->qtypes)) {
$question->qtype = $this->qtypes[$type];
}
else {
$question->qtype = null;
}
$question->single = 1;
// Only one answer is allowed
$htmltext = $this
->unxmlise($qrec['#']['text'][0]['#']);
$question->questiontext = $htmltext;
$question->name = shorten_text($question->questiontext, 250);
switch ($question->qtype) {
case MULTICHOICE:
$question = $this
->parse_mc($qrec['#'], $question);
break;
case MATCH:
$groupname = trim($qrec['@']['group']);
$question = $this
->parse_ma($qrec['#'], $groupname);
break;
case TRUEFALSE:
$question = $this
->parse_tf_yn($qrec['#'], $question);
break;
case SHORTANSWER:
$question = $this
->parse_co($qrec['#'], $question);
break;
case ESSAY:
$question = $this
->parse_sa($qrec['#'], $question);
break;
case NUMERICAL:
$question = $this
->parse_nr($qrec['#'], $question);
break;
break;
default:
print "<p>Question type " . $type . " import not supported for " . $question->questiontext . "<p>";
$question = NULL;
}
// end switch ($question->qtype)
return $question;
}