public function TrueFalseQuestion::getAnsweringForm in Quiz 8.4
Implementation of getAnsweringForm
Overrides QuizQuestion::getAnsweringForm
See also
QuizQuestion#getAnsweringForm($form_state, $rid)
File
- question_types/
truefalse/ lib/ Drupal/ truefalse/ TrueFalseQuestion.php, line 143 - Defines the classes necessary for a True/False quiz.
Class
- TrueFalseQuestion
- Extension of QuizQuestion.
Namespace
Drupal\truefalseCode
public function getAnsweringForm(array $form_state = NULL, $rid) {
$form = parent::getAnsweringForm($form_state, $rid);
// 'tries' is unfortunately required by quiz.module
$form['tries'] = array(
'#type' => 'radios',
'#title' => t('Choose one'),
'#options' => array(
1 => t('True'),
0 => t('False'),
),
'#default_value' => NULL,
);
if (isset($rid)) {
$response = new TrueFalseResponse($rid, $this->node);
$default = $response
->getResponse();
$form['tries']['#default_value'] = is_null($default) ? NULL : $default;
}
return $form;
}