You are here

public function MatchingResponse::__construct in Quiz 6.4

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

Constructor

Overrides QuizQuestionResponse::__construct

File

question_types/matching/matching.classes.inc, line 350
matching.classes

Class

MatchingResponse
Extension of QuizQuestionResponse

Code

public function __construct($result_id, stdClass $question_node, $answer = NULL) {
  parent::__construct($result_id, $question_node, $answer);
  if (!isset($answer)) {
    $sql = 'SELECT ua.answer, score, ua.match_id
              FROM {quiz_matching_user_answers} ua
              JOIN {quiz_matching_node} n
              ON n.match_id = ua.match_id
              WHERE n.nid = %d AND n.vid = %d AND ua.result_id = %d';
    $res = db_query($sql, $question_node->nid, $question_node->vid, $result_id);
    $this->answer = array();
    while ($obj = db_fetch_object($res)) {
      $this->answer[$obj->match_id] = $obj->answer;
    }
  }
  $this->is_correct = $this
    ->isCorrect();
}