You are here

public function ShortAnswerQuestion::getAnsweringForm in Quiz 8.4

Implementation of getAnsweringForm

Overrides QuizQuestion::getAnsweringForm

See also

QuizQuestion#getAnsweringForm($form_state, $rid)

File

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

Class

ShortAnswerQuestion
Extension of QuizQuestion.

Namespace

Drupal\short_answer

Code

public function getAnsweringForm(array $form_state = NULL, $rid) {
  $form = parent::getAnsweringForm($form_state, $rid);
  $form['tries'] = array(
    '#type' => 'textfield',
    '#title' => t('Answer'),
    '#description' => t('Enter your answer here'),
    '#default_value' => '',
    '#size' => 60,
    '#maxlength' => 256,
    '#required' => FALSE,
    '#attributes' => array(
      'autocomplete' => 'off',
    ),
  );
  if (isset($rid)) {
    $response = new ShortAnswerResponse($rid, $this->node);
    $form['tries']['#default_value'] = $response
      ->getResponse();
  }
  return $form;
}