function qformat_examview::parse_mc in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/question/format/examview/format.php \qformat_examview::parse_mc()
1 call to qformat_examview::parse_mc()
- qformat_examview::readquestion in includes/
moodle/ question/ format/ examview/ 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.
File
- includes/
moodle/ question/ format/ examview/ format.php, line 217
Class
Code
function parse_mc($qrec, $question) {
$answer = 'choice-' . strtolower(trim($qrec['answer'][0]['#']));
$choices = $qrec['choices'][0]['#'];
foreach ($choices as $key => $value) {
if (strpos(trim($key), 'choice-') !== FALSE) {
$question->answer[$key] = s($this
->unxmlise($value[0]['#']));
if (strcmp($key, $answer) == 0) {
$question->fraction[$key] = 1;
$question->feedback[$key] = 'Correct';
}
else {
$question->fraction[$key] = 0;
$question->feedback[$key] = 'Incorrect';
}
}
}
return $question;
}