You are here

public function TrueFalseQuestion::getAnsweringForm in Quiz 7.6

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

Implementation of getAnsweringForm

Overrides QuizQuestion::getAnsweringForm

See also

QuizQuestion#getAnsweringForm($form_state, $result_id)

File

question_types/truefalse/truefalse.classes.inc, line 118
Defines the classes necessary for a True/False quiz.

Class

TrueFalseQuestion
Extension of QuizQuestion.

Code

public function getAnsweringForm(array $form_state = NULL, $result_id) {
  $element = parent::getAnsweringForm($form_state, $result_id);

  //$form['#theme'] = 'truefalse_answering_form';

  // 'tries' is unfortunately required by quiz.module
  $element += array(
    '#type' => 'radios',
    '#title' => t('Choose one'),
    '#options' => array(
      1 => t('True'),
      0 => t('False'),
    ),
    '#default_value' => NULL,
  );
  if (isset($result_id)) {
    $response = new TrueFalseResponse($result_id, $this->node);
    $default = $response
      ->getResponse();
    $element['#default_value'] = is_null($default) ? NULL : $default;
  }
  return $element;
}