public function DDLinesQuestion::getCreationForm in Quiz 8.4
Get the form used to create a new question.
Parameters
FAPI form state:
Return value
Must return a FAPI array.
Overrides QuizQuestion::getCreationForm
File
- question_types/
quiz_ddlines/ lib/ Drupal/ quiz_ddlines/ DDLinesQuestion.php, line 39 - The main classes for the quiz_ddlines question type.
Class
- DDLinesQuestion
- Extension of QuizQuestion.
Namespace
Drupal\quiz_ddlinesCode
public function getCreationForm(array &$form_state = NULL) {
$elements = '';
if (isset($this->node->translation_source)) {
$elements = $this->node->translation_source->ddlines_elements;
}
elseif (isset($this->node->ddlines_elements)) {
$elements = $this->node->ddlines_elements;
}
$form['ddlines_elements'] = array(
'#type' => 'hidden',
'#default_value' => $elements,
);
$default_settings = $this
->getDefaultAltSettings();
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#weight' => -3,
);
$form['settings']['feedback_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable feedback'),
'#description' => t('When taking the test, and this option is enabled, a wrong placement of an alternative, will make it jump back. Also, this makes it possible to add comments to both correct and wrong answers.'),
'#default_value' => isset($this->node->translation_source) ? $this->node->translation_source->feedback_enabled : $default_settings['feedback']['enabled'],
'#parents' => array(
'feedback_enabled',
),
);
$form['settings']['hotspot_radius'] = array(
'#type' => 'textfield',
'#title' => t('Hotspot radius'),
'#description' => t('The radius of the hotspot in pixels'),
'#default_value' => isset($this->node->translation_source) ? $this->node->translation_source->hotspot_radius : $default_settings['hotspot']['radius'],
'#parents' => array(
'hotspot_radius',
),
);
$form['settings']['execution_mode'] = array(
'#type' => 'radios',
'#title' => t('Execution mode'),
'#description' => t('The mode for taking the test.'),
'#default_value' => isset($this->node->translation_source) ? $this->node->translation_source->execution_mode : $default_settings['execution_mode'],
'#options' => array(
0 => t('With lines'),
1 => t('Drag label'),
),
'#parents' => array(
'execution_mode',
),
);
drupal_add_library('system', 'ui.resizable');
$default_settings['mode'] = 'edit';
$default_settings['editmode'] = $this->node
->id() ? 'update' : 'add';
drupal_add_js(array(
'quiz_ddlines' => $default_settings,
), 'setting');
_quiz_ddlines_add_js_and_css();
return $form;
}