You are here

public function ShortAnswerQuestion::getNodeView in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 question_types/quiz_short_answer/src/Plugin/quiz/QuizQuestion/ShortAnswerQuestion.php \Drupal\quiz_short_answer\Plugin\quiz\QuizQuestion\ShortAnswerQuestion::getNodeView()
  2. 6.x question_types/quiz_short_answer/src/Plugin/quiz/QuizQuestion/ShortAnswerQuestion.php \Drupal\quiz_short_answer\Plugin\quiz\QuizQuestion\ShortAnswerQuestion::getNodeView()

Implementation of getNodeView().

Overrides QuizQuestionEntityTrait::getNodeView

See also

QuizQuestion::getNodeView()

File

question_types/quiz_short_answer/src/Plugin/quiz/QuizQuestion/ShortAnswerQuestion.php, line 43

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\QuizQuestion

Code

public function getNodeView() {
  $content = parent::getNodeView();
  if ($this
    ->viewCanRevealCorrect()) {
    $content['answers'] = array(
      '#markup' => '<div class="quiz-solution">' . check_plain($this->node->correct_answer) . '</div>',
      '#weight' => 2,
    );
  }
  else {
    $content['answers'] = array(
      '#markup' => '<div class="quiz-answer-hidden">Answer hidden</div>',
      '#weight' => 2,
    );
  }
  return $content;
}