You are here

public function MatchingQuestion::getCorrectAnswer in Quiz 7.5

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

Get the correct answers for this question.

Return value

array Array of correct answers

File

question_types/matching/matching.classes.inc, line 401
Matching classes.

Class

MatchingQuestion
Extension of QuizQuestion.

Code

public function getCorrectAnswer() {
  $correct_answers = array();
  $query = db_query('SELECT match_id, question, answer, feedback FROM {quiz_matching_node} WHERE nid = :nid AND vid = :vid', array(
    ':nid' => $this->node->nid,
    ':vid' => $this->node->vid,
  ));
  while ($result = $query
    ->fetch()) {
    $correct_answers[$result->match_id] = array(
      'match_id' => $result->match_id,
      'question' => $result->question,
      'answer' => $result->answer,
      'feedback' => $result->feedback,
    );
  }
  return $correct_answers;
}