You are here

public function ShortAnswerQuestion::getNodeView in Quiz 8.4

Implementation of getNodeView

Overrides QuizQuestion::getNodeView

See also

QuizQuestion#getNodeView()

File

question_types/short_answer/lib/Drupal/short_answer/ShortAnswerQuestion.php, line 121
The main classes for the short answer question type.

Class

ShortAnswerQuestion
Extension of QuizQuestion.

Namespace

Drupal\short_answer

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;
}