You are here

function qformat_blackboard::process_fib in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/question/format/blackboard/format.php \qformat_blackboard::process_fib()
1 call to qformat_blackboard::process_fib()
qformat_blackboard::readquestions in includes/moodle/question/format/blackboard/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/blackboard/format.php, line 304

Class

qformat_blackboard

Code

function process_fib($xml, &$questions) {
  if (isset($xml["POOL"]["#"]["QUESTION_FILLINBLANK"])) {
    $fibquestions = $xml["POOL"]["#"]["QUESTION_FILLINBLANK"];
  }
  else {
    return;
  }
  for ($i = 0; $i < sizeof($fibquestions); $i++) {
    $question = $this
      ->defaultquestion();
    $question->qtype = SHORTANSWER;
    $question->usecase = 0;

    // Ignore case
    $thisquestion = $fibquestions[$i];

    // determine if the question is already escaped html
    $ishtml = $thisquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"];

    // put questiontext in question object
    if ($ishtml) {
      $question->questiontext = html_entity_decode_php4(trim($thisquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
    }
    $question->questiontext = addslashes($question->questiontext);

    // put name of question in question object
    $question->name = substr($question->questiontext, 0, 254);
    $answer = trim($thisquestion["#"]["ANSWER"][0]["#"]["TEXT"][0]["#"]);
    $question->answer[] = addslashes($answer);
    $question->fraction[] = 1;
    $question->feedback = array();
    if (is_array($thisquestion['#']['GRADABLE'][0]['#'])) {
      $question->feedback[0] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]));
    }
    else {
      $question->feedback[0] = '';
    }
    if (is_array($thisquestion["#"]["GRADABLE"][0]["#"])) {
      $question->feedback[1] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]));
    }
    else {
      $question->feedback[1] = '';
    }
    $questions[] = $question;
  }
}