You are here

private function MatchingQuestion::getSubquestions in Quiz 8.4

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/lib/Drupal/matching/MatchingQuestion.php
Implementation of getAnsweringForm
MatchingQuestion::getNodeView in question_types/matching/lib/Drupal/matching/MatchingQuestion.php
Implementation of getNodeView

File

question_types/matching/lib/Drupal/matching/MatchingQuestion.php, line 274
The main classes for the matching question type.

Class

MatchingQuestion
Extension of QuizQuestion.

Namespace

Drupal\matching

Code

private 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
      ->id(),
    ':vid' => $this->node
      ->getRevisionId(),
  ));
  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,
  );
}