You are here

public function QuizQuestion::getAnsweringForm in Quiz 8.4

Get the form through which the user will answer the question.

Parameters

$form_state: The FAPI form_state array

$rid: The result id.

Return value

Must return a FAPI array. At the moment all form elements that takes user response must have a key named "tries". (This is a Quiz 3.x legacy AFAIK. I'm not thrilled about it...)

8 calls to QuizQuestion::getAnsweringForm()
ClozeQuestion::getAnsweringForm in question_types/cloze/lib/Drupal/cloze/ClozeQuestion.php
Implementation of getAnsweringForm
DDLinesQuestion::getAnsweringForm in question_types/quiz_ddlines/lib/Drupal/quiz_ddlines/DDLinesQuestion.php
Generates the question form.
LongAnswerQuestion::getAnsweringForm in question_types/long_answer/lib/Drupal/long_answer/LongAnswerQuestion.php
Implementation of getAnweringForm
MatchingQuestion::getAnsweringForm in question_types/matching/lib/Drupal/matching/MatchingQuestion.php
Implementation of getAnsweringForm
MultichoiceQuestion::getAnsweringForm in question_types/multichoice/lib/Drupal/multichoice/MultichoiceQuestion.php
Generates the question form.

... See full list

8 methods override QuizQuestion::getAnsweringForm()
ClozeQuestion::getAnsweringForm in question_types/cloze/lib/Drupal/cloze/ClozeQuestion.php
Implementation of getAnsweringForm
DDLinesQuestion::getAnsweringForm in question_types/quiz_ddlines/lib/Drupal/quiz_ddlines/DDLinesQuestion.php
Generates the question form.
LongAnswerQuestion::getAnsweringForm in question_types/long_answer/lib/Drupal/long_answer/LongAnswerQuestion.php
Implementation of getAnweringForm
MatchingQuestion::getAnsweringForm in question_types/matching/lib/Drupal/matching/MatchingQuestion.php
Implementation of getAnsweringForm
MultichoiceQuestion::getAnsweringForm in question_types/multichoice/lib/Drupal/multichoice/MultichoiceQuestion.php
Generates the question form.

... See full list

File

question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestion.php, line 450
Classes used in the Quiz Question module.

Class

QuizQuestion
A base implementation of a quiz_question, adding a layer of abstraction between the node API, quiz API and the question types.

Namespace

Drupal\quiz_question

Code

public function getAnsweringForm(array $form_state = NULL, $rid) {

  //echo $this->node->getType();exit;
  $form = array();
  $form['question_nid'] = array(
    '#type' => 'hidden',
    '#value' => $this->node
      ->id(),
  );
  $body = $this->node->{'body'}
    ->getValue();
  $form['question'] = array(
    '#markup' => check_markup($body[0]['value'], $body[0]['format']),
    '#prefix' => '<div class="quiz-question-body">',
    '#suffix' => '</div>',
  );
  return $form;
}