You are here

public function QuizQuestionResponse::__construct in Quiz 7.5

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

Create a new user response.

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).

6 calls to QuizQuestionResponse::__construct()
LongAnswerResponse::__construct in question_types/long_answer/long_answer.classes.inc
Constructor.
MatchingResponse::__construct in question_types/matching/matching.classes.inc
Constructor.
MultichoiceResponse::__construct in question_types/multichoice/multichoice.classes.inc
Constructor.
ScaleResponse::__construct in question_types/scale/scale.classes.inc
Constructor.
ShortAnswerResponse::__construct in question_types/short_answer/short_answer.classes.inc
Constructor.

... See full list

7 methods override QuizQuestionResponse::__construct()
LongAnswerResponse::__construct in question_types/long_answer/long_answer.classes.inc
Constructor.
MatchingResponse::__construct in question_types/matching/matching.classes.inc
Constructor.
MultichoiceResponse::__construct in question_types/multichoice/multichoice.classes.inc
Constructor.
QuizQuestionResponseBroken::__construct in question_types/quiz_question/quiz_question.core.inc
Create a new user response.
ScaleResponse::__construct in question_types/scale/scale.classes.inc
Constructor.

... See full list

File

question_types/quiz_question/quiz_question.core.inc, line 528
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->result_id = $result_id;
  $this->question = $question_node;
  $this->quizQuestion = _quiz_question_get_instance($question_node);
  $this->answer = $answer;
  $result = db_query('SELECT *
      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)) {
    foreach ($result as $key => $value) {
      $this->{$key} = $value;
    }
  }
}