You are here

public function QuizQuestionResponse::__construct in OG Quiz 7

Create a new user response.

Parameters

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

$question_node: The question node.

$answer: The answer (dependent on question type).

1 call to QuizQuestionResponse::__construct()
LongAnswerResponse::__construct in includes/og_long_answer.php
Constructor
1 method overrides QuizQuestionResponse::__construct()
LongAnswerResponse::__construct in includes/og_long_answer.php
Constructor

File

includes/og_quiz_question.php, line 769
Classes used in the Quiz Question module.

Class

QuizQuestionResponse
Each question type must store its own response data and be able to calculate a score for that data.

Code

public function __construct($result_id, stdClass $question_node, $answer = NULL) {
  $this->rid = $result_id;
  $this->question = $question_node;
  $this->answer = $answer;
  $result = db_query('SELECT is_skipped, is_doubtful FROM {quiz_node_results_answers}
            WHERE result_id = :result_id AND question_nid = :question_nid AND question_vid = :question_vid', array(
    ':result_id' => $result_id,
    ':question_nid' => $question_node->nid,
    ':question_vid' => $question_node->vid,
  ))
    ->fetch();
  if (is_object($result)) {
    $this->is_doubtful = $result->is_doubtful;
    $this->is_skipped = $result->is_skipped;
  }
}