You are here

function qformat_xml::import_matching in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/question/format/xml/format.php \qformat_xml::import_matching()

import matching type question

Parameters

array question question array from xml tree:

Return value

object question object

1 call to qformat_xml::import_matching()
qformat_xml::readquestions in includes/moodle/question/format/xml/format.php
parse the array of lines into an array of questions this *could* burn memory - but it won't happen that much so fingers crossed!

File

includes/moodle/question/format/xml/format.php, line 367

Class

qformat_xml

Code

function import_matching($question) {

  // get common parts
  $qo = $this
    ->import_headers($question);

  // header parts particular to matching
  $qo->qtype = MATCH;
  $qo->shuffleanswers = $this
    ->getpath($question, array(
    '#',
    'shuffleanswers',
    0,
    '#',
  ), 1);

  // get subquestions
  $subquestions = $question['#']['subquestion'];
  $qo->subquestions = array();
  $qo->subanswers = array();

  // run through subquestions
  foreach ($subquestions as $subquestion) {
    $qo->subquestions[] = $this
      ->getpath($subquestion, array(
      '#',
      'text',
      0,
      '#',
    ), '', true);
    $qo->subanswers[] = $this
      ->getpath($subquestion, array(
      '#',
      'answer',
      0,
      '#',
      'text',
      0,
      '#',
    ), '', true);
  }
  return $qo;
}