You are here

public function ScaleResponse::__construct in Quiz 7.5

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleResponse.php \ScaleResponse::__construct()
  2. 8.5 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleResponse.php \ScaleResponse::__construct()
  3. 6.6 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  4. 6.4 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  5. 7.6 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  6. 7 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  7. 7.4 question_types/scale/scale.classes.inc \ScaleResponse::__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 (dependent on question type).

Overrides QuizQuestionResponse::__construct

File

question_types/scale/scale.classes.inc, line 584
Scale classes.

Class

ScaleResponse
Extension of QuizQuestionResponse.

Code

public function __construct($result_id, stdClass $question_node, $answer = NULL) {
  parent::__construct($result_id, $question_node, $answer);
  if (isset($answer)) {
    $this->answer_id = intval($answer);
  }
  else {
    $this->answer_id = db_query('SELECT answer_id FROM {quiz_scale_user_answers} WHERE result_answer_id = :raid', array(
      ':raid' => $this->result_answer_id,
    ))
      ->fetchField();
  }
  $answer = db_query('SELECT answer FROM {quiz_scale_answer} WHERE id = :id', array(
    ':id' => $this->answer_id,
  ))
    ->fetchField();
  $this->answer = check_plain($answer);
}