You are here

public function TrueFalseResponse::__construct in Quiz 7.5

Same name and namespace in other branches
  1. 6.6 question_types/truefalse/truefalse.classes.inc \TrueFalseResponse::__construct()
  2. 6.3 question_types/quiz_question/quiz_question.truefalse.inc \TrueFalseResponse::__construct()
  3. 6.4 question_types/truefalse/truefalse.classes.inc \TrueFalseResponse::__construct()
  4. 6.5 question_types/quiz_question/quiz_question.truefalse.inc \TrueFalseResponse::__construct()
  5. 7.6 question_types/truefalse/truefalse.classes.inc \TrueFalseResponse::__construct()
  6. 7 question_types/truefalse/truefalse.classes.inc \TrueFalseResponse::__construct()
  7. 7.4 question_types/truefalse/truefalse.classes.inc \TrueFalseResponse::__construct()

Constructor.

Parameters

int $result_id: The result ID for the user's result set. There is one result ID per time the user takes a quiz.

stdClass $question_node: The question node.

mixed $answer: The answer.

Overrides QuizQuestionResponse::__construct

File

question_types/truefalse/truefalse.classes.inc, line 204
TrueFalse classes.

Class

TrueFalseResponse
Extension of QuizQuestionResponse.

Code

public function __construct($result_id, stdClass $question_node, $answer = NULL) {
  parent::__construct($result_id, $question_node, $answer);
  if (!isset($answer)) {

    // Get from DB.
    $r = $this
      ->getUserAnswer();
    if (!empty($r)) {
      $this->answer = $r->answer;
      $this->score = $r->score;
    }
  }
  else {

    // Load from input.
    $this->answer = $answer;
  }
}