You are here

public function MatchingQuestion::getSubquestions in Quiz 7.6

Same name and namespace in other branches
  1. 6.4 question_types/matching/matching.classes.inc \MatchingQuestion::getSubquestions()
  2. 7 question_types/matching/matching.classes.inc \MatchingQuestion::getSubquestions()
  3. 7.4 question_types/matching/matching.classes.inc \MatchingQuestion::getSubquestions()
  4. 7.5 question_types/matching/matching.classes.inc \MatchingQuestion::getSubquestions()

Helper function to fetch subquestions

Return value

Array with two arrays, matches and selected options

2 calls to MatchingQuestion::getSubquestions()
MatchingQuestion::getAnsweringForm in question_types/matching/matching.classes.inc
Implementation of getAnsweringForm
MatchingQuestion::getNodeView in question_types/matching/matching.classes.inc
Implementation of getNodeView

File

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

Class

MatchingQuestion
Extension of QuizQuestion.

Code

public function getSubquestions() {
  $matches = $select_option = array();

  //$sql = "SELECT match_id, question, answer, feedback FROM {quiz_matching_node} WHERE nid = %d AND vid = %d";
  $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()) {
    $matches[] = array(
      'match_id' => $result->match_id,
      'question' => $result->question,
      'answer' => $result->answer,
      'feedback' => $result->feedback,
    );
    $select_option[$result->match_id] = $result->answer;
  }
  return array(
    $matches,
    $select_option,
  );
}