You are here

function qformat_examview::parse_nr in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/question/format/examview/format.php \qformat_examview::parse_nr()
1 call to qformat_examview::parse_nr()
qformat_examview::readquestion in includes/moodle/question/format/examview/format.php
Given the data known to define a question in this format, this function converts it into a question object suitable for processing and insertion into Moodle.

File

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

Class

qformat_examview

Code

function parse_nr($qrec, $question) {
  $answer = trim($this
    ->unxmlise($qrec['answer'][0]['#']));
  $answer = strip_tags($answer);
  $answers = explode("\n", $answer);
  foreach ($answers as $key => $value) {
    $value = trim($value);
    if (is_numeric($value)) {
      $errormargin = 0;
      $question->answer[$key] = $value;
      $question->fraction[$key] = 1;
      $question->feedback[$key] = "Correct";
      $question->min[$key] = $question->answer[$key] - $errormargin;
      $question->max[$key] = $question->answer[$key] + $errormargin;
    }
  }
  return $question;
}