public function MatchingQuestion::getNodeView in Quiz 7.5
Same name and namespace in other branches
- 6.4 question_types/matching/matching.classes.inc \MatchingQuestion::getNodeView()
- 7.6 question_types/matching/matching.classes.inc \MatchingQuestion::getNodeView()
- 7 question_types/matching/matching.classes.inc \MatchingQuestion::getNodeView()
- 7.4 question_types/matching/matching.classes.inc \MatchingQuestion::getNodeView()
Implementation of getNodeView().
Overrides QuizQuestion::getNodeView
See also
File
- question_types/
matching/ matching.classes.inc, line 164 - 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;
}