You are here

function qformat_hotpot::process_jcross in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/question/format/hotpot/format.php \qformat_hotpot::process_jcross()
1 call to qformat_hotpot::process_jcross()
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 226

Class

qformat_hotpot
@package questionbank @subpackage importexport

Code

function process_jcross(&$xml, &$questions) {

  // xml tags to the start of the crossword exercise clue items
  $tags = 'data,crossword,clues,item';
  $x = 0;
  while (($item = "[{$x}]['#']") && $xml
    ->xml_value($tags, $item)) {
    $text = $xml
      ->xml_value($tags, $item . "['def'][0]['#']");
    $answer = $xml
      ->xml_value($tags, $item . "['word'][0]['#']");
    if ($text && $answer) {
      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, true);
      $question->questiontext = $this
        ->hotpot_prepare_str($text);
      $question->answer = array(
        $this
          ->hotpot_prepare_str($answer),
      );
      $question->fraction = array(
        1,
      );
      $question->feedback = array(
        '',
      );
      $questions[] = $question;
    }
    $x++;
  }
}