You are here

public function ScaleQuestion::getAnsweringForm in Quiz 6.4

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::getAnsweringForm()
  2. 8.5 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::getAnsweringForm()
  3. 7.6 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()
  4. 7 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()
  5. 7.4 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()
  6. 7.5 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()

Implementation of getAnsweringForm

Overrides QuizQuestion::getAnsweringForm

See also

getAnsweringForm($form_state, $rid)

File

question_types/scale/scale.classes.inc, line 312
The main classes for the scale question type.

Class

ScaleQuestion
Extension of QuizQuestion.

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 < variable_get('scale_max_num_of_alts', 10); $i++) {
    if (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;
}