You are here

public function LongAnswerQuestion::getNodeView in Quiz 8.5

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

Implementation of getNodeView().

Overrides QuizQuestionEntityTrait::getNodeView

See also

QuizQuestion::getNodeView()

File

question_types/quiz_long_answer/src/Plugin/quiz/QuizQuestion/LongAnswerQuestion.php, line 28

Class

LongAnswerQuestion
@QuizQuestion ( id = "long_answer", label = Plugin annotation @Translation("Long answer question"), handlers = { "response" = "\Drupal\quiz_long_answer\Plugin\quiz\QuizQuestion\LongAnswerResponse" } )

Namespace

Drupal\quiz_long_answer\Plugin\quiz\QuizQuestion

Code

public function getNodeView() {
  $content = parent::getNodeView();
  if ($this
    ->viewCanRevealCorrect()) {
    $content['answers'] = array(
      '#type' => 'item',
      '#title' => t('Rubric'),
      '#markup' => '<div class="quiz-solution">' . check_markup($this->node->rubric['value'], $this->node->rubric['format']) . '</div>',
      '#weight' => 1,
    );
  }
  else {
    $content['answers'] = array(
      '#markup' => '<div class="quiz-answer-hidden">Answer hidden</div>',
      '#weight' => 1,
    );
  }
  return $content;
}