You are here

function qformat_examview::readquestions in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/question/format/examview/format.php \qformat_examview::readquestions()

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.

If your format does not use blank lines as a delimiter then you will need to override this method. Even then try to use readquestion for each question

Parameters

array lines array of lines from readdata:

Return value

array array of question objects

Overrides qformat_default::readquestions

File

includes/moodle/question/format/examview/format.php, line 125

Class

qformat_examview

Code

function readquestions($lines) {

  /// Parses an array of lines into an array of questions,

  /// where each item is a question object as defined by

  /// readquestion().
  $questions = array();
  $currentquestion = array();
  $text = implode($lines, ' ');
  $text = $this
    ->cleanUnicode($text);
  $xml = xmlize($text, 0);
  if (!empty($xml['examview']['#']['matching-group'])) {
    $this
      ->parse_matching_groups($xml['examview']['#']['matching-group']);
  }
  $questionNode = $xml['examview']['#']['question'];
  foreach ($questionNode as $currentquestion) {
    if ($question = $this
      ->readquestion($currentquestion)) {
      $questions[] = $question;
    }
  }
  $this
    ->process_matches($questions);
  return $questions;
}