You are here

public function TrueFalseQuestion::getAnsweringForm in Quiz 7.5

Same name and namespace in other branches
  1. 6.4 question_types/truefalse/truefalse.classes.inc \TrueFalseQuestion::getAnsweringForm()
  2. 7.6 question_types/truefalse/truefalse.classes.inc \TrueFalseQuestion::getAnsweringForm()
  3. 7 question_types/truefalse/truefalse.classes.inc \TrueFalseQuestion::getAnsweringForm()
  4. 7.4 question_types/truefalse/truefalse.classes.inc \TrueFalseQuestion::getAnsweringForm()

Implementation of getAnsweringForm().

Overrides QuizQuestion::getAnsweringForm

See also

QuizQuestion::getAnsweringForm()

File

question_types/truefalse/truefalse.classes.inc, line 106
TrueFalse classes.

Class

TrueFalseQuestion
Extension of QuizQuestion.

Code

public function getAnsweringForm(array $form_state = NULL, $result_id) {
  $element = parent::getAnsweringForm($form_state, $result_id);
  $element += array(
    '#type' => 'radios',
    '#title' => t('Choose one'),
    '#options' => array(
      1 => t('True'),
      0 => t('False'),
    ),
  );
  if (isset($result_id)) {
    $response = new TrueFalseResponse($result_id, $this->node);
    $default = $response
      ->getResponse();
    $element['#default_value'] = is_null($default) ? NULL : $default;
  }
  return $element;
}