public function ScaleQuestion::getAnsweringForm in Quiz 7.5
Same name and namespace in other branches
- 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::getAnsweringForm()
- 8.5 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::getAnsweringForm()
- 6.4 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()
- 7.6 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()
- 7 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()
- 7.4 question_types/scale/scale.classes.inc \ScaleQuestion::getAnsweringForm()
Implementation of getAnsweringForm().
Overrides QuizQuestion::getAnsweringForm
See also
QuizQuestion::getAnsweringForm()
File
- question_types/
scale/ scale.classes.inc, line 361 - Scale classes.
Class
- ScaleQuestion
- Extension of QuizQuestion.
Code
public function getAnsweringForm(array $form_state = NULL, $result_id) {
$form = parent::getAnsweringForm($form_state, $result_id);
//$form['#theme'] = 'scale_answering_form';
$options = array();
for ($i = 0; $i < variable_get('scale_max_num_of_alts', 10); $i++) {
if (isset($this->node->scale[$i]) && drupal_strlen($this->node->scale[$i]->answer) > 0) {
$options[$this->node->scale[$i]->id] = check_plain($this->node->scale[$i]->answer);
}
}
$form = array(
'#type' => 'radios',
'#title' => t('Choose one'),
'#options' => $options,
);
if (isset($result_id)) {
$response = new ScaleResponse($result_id, $this->node);
$form['#default_value'] = $response
->getResponse();
}
return $form;
}