You are here

function qformat_examview::parse_tf_yn in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/question/format/examview/format.php \qformat_examview::parse_tf_yn()
1 call to qformat_examview::parse_tf_yn()
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 201

Class

qformat_examview

Code

function parse_tf_yn($qrec, $question) {
  $choices = array(
    'T' => 1,
    'Y' => 1,
    'F' => 0,
    'N' => 0,
  );
  $answer = trim($qrec['answer'][0]['#']);
  $question->answer = $choices[$answer];
  $question->correctanswer = $question->answer;
  if ($question->answer == 1) {
    $question->feedbacktrue = 'Correct';
    $question->feedbackfalse = 'Incorrect';
  }
  else {
    $question->feedbacktrue = 'Incorrect';
    $question->feedbackfalse = 'Correct';
  }
  return $question;
}