You are here

public function MatchingQuestion::getNodeView in Quiz 7.6

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

Implementation of getNodeView

Overrides QuizQuestion::getNodeView

See also

QuizQuestion#getNodeView()

File

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

Class

MatchingQuestion
Extension of QuizQuestion.

Code

public function getNodeView() {
  $content = parent::getNodeView();
  list($matches, $select_option) = $this
    ->getSubquestions();
  $subquestions = array();
  if ($this
    ->viewCanRevealCorrect()) {
    foreach ($matches as $match) {
      $subquestions[] = array(
        'question' => $match['question'],
        'correct' => $match['answer'],
        'feedback' => $match['feedback'],
      );
    }
  }
  else {

    // shuffle the answer column
    foreach ($matches as $match) {
      $sub_qs[] = $match['question'];
      $sub_as[] = $match['answer'];
    }
    shuffle($sub_as);
    foreach ($sub_qs as $i => $sub_q) {
      $subquestions[] = array(
        'question' => $sub_q,
        'random' => $sub_as[$i],
      );
    }
  }
  $content['answers'] = array(
    '#markup' => theme('matching_match_node_view', array(
      'subquestions' => $subquestions,
    )),
    '#weight' => 2,
  );
  return $content;
}