You are here

public function MatchingQuestion::getNodeProperties in Quiz 7.6

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

Implementation of getNodeProperties

Overrides QuizQuestion::getNodeProperties

See also

QuizQuestion#getNodeProperties()

File

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

Class

MatchingQuestion
Extension of QuizQuestion.

Code

public function getNodeProperties() {
  if (isset($this->nodeProperties)) {
    return $this->nodeProperties;
  }
  $props = parent::getNodeProperties();
  $res_a = db_query('SELECT choice_penalty FROM {quiz_matching_properties}
            WHERE nid = :nid AND vid = :vid', array(
    ':nid' => $this->node->nid,
    ':vid' => $this->node->vid,
  ))
    ->fetchAssoc();
  if (is_array($res_a)) {
    $props = array_merge($props, $res_a);
  }

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