public function DDLinesQuestion::getAnsweringForm in Quiz 7.4
Generates the question form.
This is called whenever a question is rendered, either to an administrator or to a quiz taker.
Overrides QuizQuestion::getAnsweringForm
File
- question_types/
quiz_ddlines/ quiz_ddlines.classes.inc, line 143 - The main classes for the drag and drop with lines question type.
Class
- DDLinesQuestion
- Extension of QuizQuestion.
Code
public function getAnsweringForm(array $form_state = NULL, $rid) {
$form = parent::getAnsweringForm($form_state, $rid);
$form['helptext'] = array(
'#markup' => t('Answer this question by dragging each rectangular label to the correct circular hotspot.'),
'#weight' => 0,
);
// Form element containing the correct answers
$form['ddlines_elements'] = array(
'#type' => 'hidden',
'#default_value' => isset($this->node->ddlines_elements) ? $this->node->ddlines_elements : '',
);
// Form element containing the user answers
// The quiz module requires this element to be named "tries":
$form['tries'] = array(
'#type' => 'hidden',
'#default_value' => '',
);
$image_uri = $this->node->field_image['und'][0]['uri'];
$image_url = image_style_url('large', $image_uri);
$form['image'] = array(
'#markup' => '<div class="image-preview">' . theme('image', array(
'path' => $image_url,
)) . '</div>',
);
$default_settings = $this
->getDefaultAltSettings();
$default_settings['mode'] = 'take';
$form['#attached']['js'][] = array(
'data' => array(
'quiz_ddlines' => $default_settings,
),
'type' => 'setting',
);
_quiz_ddlines_add_js_and_css();
return $form;
}