public function ShortAnswerQuestion::getNodeView in Quiz 6.x
Same name and namespace in other branches
- 8.6 question_types/quiz_short_answer/src/Plugin/quiz/QuizQuestion/ShortAnswerQuestion.php \Drupal\quiz_short_answer\Plugin\quiz\QuizQuestion\ShortAnswerQuestion::getNodeView()
- 8.5 question_types/quiz_short_answer/src/Plugin/quiz/QuizQuestion/ShortAnswerQuestion.php \Drupal\quiz_short_answer\Plugin\quiz\QuizQuestion\ShortAnswerQuestion::getNodeView()
Implementation of getNodeView().
See also
QuizQuestion::getNodeView()
File
- question_types/
quiz_short_answer/ src/ Plugin/ quiz/ QuizQuestion/ ShortAnswerQuestion.php, line 46
Class
- ShortAnswerQuestion
- @QuizQuestion ( id = "short_answer", label = Plugin annotation @Translation("Short answer question"), handlers = { "response" = "\Drupal\quiz_short_answer\Plugin\quiz\QuizQuestion\ShortAnswerResponse" } )
Namespace
Drupal\quiz_short_answer\Plugin\quiz\QuizQuestionCode
public function getNodeView() {
$content = parent::getNodeView();
if ($this
->viewCanRevealCorrect()) {
$content['answers'] = [
'#markup' => '<div class="quiz-solution">' . check_plain($this->node->correct_answer) . '</div>',
'#weight' => 2,
];
}
else {
$content['answers'] = [
'#markup' => '<div class="quiz-answer-hidden">Answer hidden</div>',
'#weight' => 2,
];
}
return $content;
}