You are here

public function QuizQuestionResponse::__construct in Quiz 8.4

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

8 calls to QuizQuestionResponse::__construct()
ClozeResponse::__construct in question_types/cloze/lib/Drupal/cloze/ClozeResponse.php
Constructor
DDLinesResponse::__construct in question_types/quiz_ddlines/lib/Drupal/quiz_ddlines/DDLinesResponse.php
Constructor
LongAnswerResponse::__construct in question_types/long_answer/lib/Drupal/long_answer/LongAnswerResponse.php
Constructor
MatchingResponse::__construct in question_types/matching/lib/Drupal/matching/MatchingResponse.php
Constructor
MultichoiceResponse::__construct in question_types/multichoice/lib/Drupal/multichoice/MultichoiceResponse.php
Constructor

... See full list

8 methods override QuizQuestionResponse::__construct()
ClozeResponse::__construct in question_types/cloze/lib/Drupal/cloze/ClozeResponse.php
Constructor
DDLinesResponse::__construct in question_types/quiz_ddlines/lib/Drupal/quiz_ddlines/DDLinesResponse.php
Constructor
LongAnswerResponse::__construct in question_types/long_answer/lib/Drupal/long_answer/LongAnswerResponse.php
Constructor
MatchingResponse::__construct in question_types/matching/lib/Drupal/matching/MatchingResponse.php
Constructor
MultichoiceResponse::__construct in question_types/multichoice/lib/Drupal/multichoice/MultichoiceResponse.php
Constructor

... See full list

File

question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestionResponse.php, line 36

Class

QuizQuestionResponse

Namespace

Drupal\quiz_question

Code

public function __construct($result_id, $question_node, $answer = NULL) {
  $this->rid = $result_id;
  $this->question = $question_node;
  $this->answer = $answer;
  if ($question_node instanceof \stdClass) {
    $params = array(
      ':result_id' => $result_id,
      ':question_nid' => $question_node->nid,
      ':question_vid' => $question_node->vid,
    );
  }
  else {
    $params = array(
      ':result_id' => $result_id,
      ':question_nid' => $question_node
        ->id(),
      ':question_vid' => $question_node
        ->getRevisionId(),
    );
  }
  $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', $params)
    ->fetch();
  if (is_object($result)) {
    $this->is_doubtful = $result->is_doubtful;
    $this->is_skipped = $result->is_skipped;
  }
}