You are here

public function ScaleQuestion::getAnsweringForm in Quiz 8.4

Implementation of getAnsweringForm

Overrides QuizQuestion::getAnsweringForm

See also

getAnsweringForm($form_state, $rid)

File

question_types/scale/lib/Drupal/scale/ScaleQuestion.php, line 366
The main classes for the short answer question type.

Class

ScaleQuestion
Extension of QuizQuestion.

Namespace

Drupal\scale

Code

public function getAnsweringForm(array $form_state = NULL, $rid) {
  $form = parent::getAnsweringForm($form_state, $rid);

  //$form['#theme'] = 'scale_answering_form';
  $options = array();
  for ($i = 0; $i < \Drupal::config('scale.settings')
    ->get('scale_max_num_of_alts'); $i++) {
    if (isset($this->node->{$i}) && drupal_strlen($this->node->{$i}->answer) > 0) {
      $options[$this->node->{$i}->id] = check_plain($this->node->{$i}->answer);
    }
  }
  $form['tries'] = array(
    '#type' => 'radios',
    '#title' => t('Choose one'),
    '#options' => $options,
  );
  if (isset($rid)) {
    $response = new ScaleResponse($rid, $this->node);
    $form['tries']['#default_value'] = $response
      ->getResponse();
  }
  return $form;
}