You are here

function qformat_xml::import_shortanswer in Quiz 6.5

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

import short answer type question

Parameters

array question question array from xml tree:

Return value

object question object

1 call to qformat_xml::import_shortanswer()
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 277

Class

qformat_xml

Code

function import_shortanswer($question) {

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

  // header parts particular to shortanswer
  $qo->qtype = SHORTANSWER;

  // get usecase
  $qo->usecase = $this
    ->getpath($question, array(
    '#',
    'usecase',
    0,
    '#',
  ), $qo->usecase);

  // run through the answers
  $answers = $question['#']['answer'];
  $a_count = 0;
  foreach ($answers as $answer) {
    $ans = $this
      ->import_answer($answer);
    $qo->answer[$a_count] = $ans->answer;
    $qo->fraction[$a_count] = $ans->fraction;
    $qo->feedback[$a_count] = $ans->feedback;
    ++$a_count;
  }
  return $qo;
}