You are here

function qformat_xml::import_headers in Quiz 6.5

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

import parts of question common to all types

Parameters

$question array question question array from xml tree:

Return value

object question object

8 calls to qformat_xml::import_headers()
qformat_xml::import_calculated in includes/moodle/question/format/xml/format.php
qformat_xml::import_description in includes/moodle/question/format/xml/format.php
import description type question
qformat_xml::import_essay in includes/moodle/question/format/xml/format.php
import essay type question
qformat_xml::import_matching in includes/moodle/question/format/xml/format.php
import matching type question
qformat_xml::import_multichoice in includes/moodle/question/format/xml/format.php
import multiple choice question

... See full list

File

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

Class

qformat_xml

Code

function import_headers($question) {

  // get some error strings
  $error_noname = get_string('xmlimportnoname', 'quiz');
  $error_noquestion = get_string('xmlimportnoquestion', 'quiz');

  // this routine initialises the question object
  $qo = $this
    ->defaultquestion();

  // question name
  $qo->name = $this
    ->getpath($question, array(
    '#',
    'name',
    0,
    '#',
    'text',
    0,
    '#',
  ), '', true, $error_noname);
  $qo->questiontext = $this
    ->getpath($question, array(
    '#',
    'questiontext',
    0,
    '#',
    'text',
    0,
    '#',
  ), '', true);
  $qo->questiontextformat = $this
    ->getpath($question, array(
    '#',
    'questiontext',
    0,
    '@',
    'format',
  ), '');
  $qo->image = $this
    ->getpath($question, array(
    '#',
    'image',
    0,
    '#',
  ), $qo->image);
  $image_base64 = $this
    ->getpath($question, array(
    '#',
    'image_base64',
    '0',
    '#',
  ), '');
  if (!empty($image_base64)) {
    $qo->image = $this
      ->importimagefile($qo->image, stripslashes($image_base64));
  }
  $qo->generalfeedback = $this
    ->getpath($question, array(
    '#',
    'generalfeedback',
    0,
    '#',
    'text',
    0,
    '#',
  ), $qo->generalfeedback, true);
  $qo->defaultgrade = $this
    ->getpath($question, array(
    '#',
    'defaultgrade',
    0,
    '#',
  ), $qo->defaultgrade);
  $qo->penalty = $this
    ->getpath($question, array(
    '#',
    'penalty',
    0,
    '#',
  ), $qo->penalty);
  return $qo;
}