You are here

public function MultichoiceQuestion::getNodeView in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php \Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceQuestion::getNodeView()

Implementation of getNodeView().

Overrides QuizQuestionEntityTrait::getNodeView

See also

QuizQuestion::getNodeView()

File

question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php, line 400

Class

MultichoiceQuestion
@QuizQuestion ( id = "multichoice", label = Plugin annotation @Translation("Multiple choice question"), handlers = { "response" = "\Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceResponse" } )

Namespace

Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion

Code

public function getNodeView() {
  $content = parent::getNodeView();
  if ($this->node->choice_random) {
    $this
      ->shuffle($this->node->alternatives);
  }
  $content['answers'] = array(
    '#markup' => theme('multichoice_answer_node_view', array(
      'alternatives' => $this->node->alternatives,
      'show_correct' => $this
        ->viewCanRevealCorrect(),
    )),
    '#weight' => 2,
  );
  return $content;
}