function qformat_hotpot::process_jmix in Quiz 6.5
Same name and namespace in other branches
- 6.6 includes/moodle/question/format/hotpot/format.php \qformat_hotpot::process_jmix()
1 call to qformat_hotpot::process_jmix()
- qformat_hotpot::readquestions in includes/
moodle/ question/ format/ hotpot/ 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/ hotpot/ format.php, line 302
Class
- qformat_hotpot
- @package questionbank @subpackage importexport
Code
function process_jmix(&$xml, &$questions) {
// define default grade (per segment)
$defaultgrade = 1;
$segment_count = 0;
// xml tags to the start of the jumbled order exercise
$tags = 'data,jumbled-order-exercise';
$x = 0;
while (($exercise = "[{$x}]['#']") && $xml
->xml_value($tags, $exercise)) {
// there is usually only one exercise in a file
if (method_exists($this, 'defaultquestion')) {
$question = $this
->defaultquestion();
}
else {
$question = new stdClass();
$question->usecase = 0;
// Ignore case
$question->image = "";
// No images with this format
}
$question->qtype = SHORTANSWER;
$question->name = $this
->hotpot_get_title($xml, $x);
$question->answer = array();
$question->fraction = array();
$question->feedback = array();
$i = 0;
$segments = array();
while ($segment = $xml
->xml_value($tags, $exercise . "['main-order'][0]['#']['segment'][{$i}]['#']")) {
$segments[] = $this
->hotpot_prepare_str($segment);
$segment_count++;
$i++;
}
$answer = implode(' ', $segments);
$this
->hotpot_seed_RNG();
shuffle($segments);
$question->questiontext = $this
->hotpot_get_reading($xml);
$question->questiontext .= $this
->hotpot_get_instructions($xml);
$question->questiontext .= ' <NOBR><B>[ ' . implode(' ', $segments) . ' ]</B></NOBR>';
$a = 0;
while (!empty($answer)) {
$question->answer[$a] = $answer;
$question->fraction[$a] = 1;
$question->feedback[$a] = '';
$answer = $this
->hotpot_prepare_str($xml
->xml_value($tags, $exercise . "['alternate'][{$a}]['#']"));
$a++;
}
$question->defaultgrade = $segment_count * $defaultgrade;
$questions[] = $question;
$x++;
}
}