public function TrueFalseQuestion::getNodeView in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_truefalse/src/Plugin/quiz/QuizQuestion/TrueFalseQuestion.php \Drupal\quiz_truefalse\Plugin\quiz\QuizQuestion\TrueFalseQuestion::getNodeView()
- 6.x question_types/quiz_truefalse/src/Plugin/quiz/QuizQuestion/TrueFalseQuestion.php \Drupal\quiz_truefalse\Plugin\quiz\QuizQuestion\TrueFalseQuestion::getNodeView()
Retrieve information relevant for viewing the node.
(This data is generally added to the node's extra field.)
Return value
array Content array.
Overrides QuizQuestionEntityTrait::getNodeView
File
- question_types/
quiz_truefalse/ src/ Plugin/ quiz/ QuizQuestion/ TrueFalseQuestion.php, line 23
Class
- TrueFalseQuestion
- @QuizQuestion ( id = "truefalse", label = Plugin annotation @Translation("True/false question"), handlers = { "response" = "\Drupal\quiz_truefalse\Plugin\quiz\QuizQuestion\TrueFalseResponse" } )
Namespace
Drupal\quiz_truefalse\Plugin\quiz\QuizQuestionCode
public function getNodeView() {
$content = parent::getNodeView();
if ($this
->viewCanRevealCorrect()) {
$answer = $this->node->correct_answer ? t('True') : t('False');
$content['answers']['#markup'] = '<div class="quiz-solution">' . $answer . '</div>';
$content['answers']['#weight'] = 2;
}
else {
$content['answers'] = array(
'#markup' => '<div class="quiz-answer-hidden">' . t('Answer hidden') . '</div>',
'#weight' => 2,
);
}
return $content;
}