You are here

function qformat_blackboard_6::readquestions in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/question/format/blackboard_6/format.php \qformat_blackboard_6::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/blackboard_6/format.php, line 214

Class

qformat_blackboard_6

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().
  $text = implode($lines, " ");
  $xml = xmlize($text, 0);
  $raw_questions = $xml['questestinterop']['#']['assessment'][0]['#']['section'][0]['#']['item'];
  $questions = array();
  foreach ($raw_questions as $quest) {
    $question = $this
      ->create_raw_question($quest);
    switch ($question->qtype) {
      case "Matching":
        $this
          ->process_matching($question, $questions);
        break;
      case "Multiple Choice":
        $this
          ->process_mc($question, $questions);
        break;
      case "Essay":
        $this
          ->process_essay($question, $questions);
        break;
      case "Multiple Answer":
        $this
          ->process_ma($question, $questions);
        break;
      case "True/False":
        $this
          ->process_tf($question, $questions);
        break;
      case 'Fill in the Blank':
        $this
          ->process_fblank($question, $questions);
        break;
      case 'Short Response':
        $this
          ->process_essay($question, $questions);
        break;
      default:
        print "Unknown or unhandled question type: \"{$question->qtype}\"<br />";
        break;
    }
  }
  return $questions;
}