You are here

public function MatchingQuestion::getNodeProperties in Quiz 8.4

Implementation of getNodeProperties

Overrides QuizQuestion::getNodeProperties

See also

QuizQuestion#getNodeProperties()

File

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

Class

MatchingQuestion
Extension of QuizQuestion.

Namespace

Drupal\matching

Code

public function getNodeProperties() {
  if (isset($this->nodeProperties)) {
    return $this->nodeProperties;
  }
  $props = parent::getNodeProperties();

  //$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()) {
    $props['match'][] = array(
      'match_id' => $result->match_id,
      'question' => $result->question,
      'answer' => $result->answer,
      'feedback' => $result->feedback,
    );
  }
  $this->nodeProperties = $props;
  return $props;
}