public function MatchingQuestion::getCreationForm in Quiz 7.4
Same name and namespace in other branches
- 6.6 question_types/matching/matching.classes.inc \MatchingQuestion::getCreationForm()
- 6.3 question_types/matching/matching.classes.inc \MatchingQuestion::getCreationForm()
- 6.4 question_types/matching/matching.classes.inc \MatchingQuestion::getCreationForm()
- 6.5 question_types/matching/matching.classes.inc \MatchingQuestion::getCreationForm()
- 7.6 question_types/matching/matching.classes.inc \MatchingQuestion::getCreationForm()
- 7 question_types/matching/matching.classes.inc \MatchingQuestion::getCreationForm()
- 7.5 question_types/matching/matching.classes.inc \MatchingQuestion::getCreationForm()
Implementation of getCreationForm
Overrides QuizQuestion::getCreationForm
See also
QuizQuestion#getCreationForm($form_state)
File
- question_types/
matching/ matching.classes.inc, line 313 - matching.classes
Class
- MatchingQuestion
- Extension of QuizQuestion.
Code
public function getCreationForm(array &$form_state = NULL) {
// Get the nodes settings, users settings or default settings
$default_settings = $this
->getDefaultAltSettings();
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['settings']['choice_penalty'] = array(
'#type' => 'checkbox',
'#title' => t('Penalty for guessing'),
'#description' => t('Subtract 1 point from the users score for each incorrect match. Scores cannot go below 0.'),
'#default_value' => $default_settings['choice_penalty'],
'#parents' => array(
'choice_penalty',
),
);
$form['match'] = array(
'#type' => 'fieldset',
'#title' => t('Answer'),
'#weight' => -4,
'#tree' => TRUE,
'#theme' => 'matching_question_form',
'#description' => t('Write your pairs in the question and answer columns. For the user the question will be fixed and the answers will be shown as alternatives in a dropdown box.'),
);
for ($i = 1; $i <= variable_get('quiz_matching_form_size', 5); ++$i) {
$form['match'][$i] = array(
'#type' => 'fieldset',
'#title' => t('Question ' . $i),
);
$form['match'][$i]['match_id'] = array(
'#type' => 'value',
'#default_value' => isset($this->node->match[$i - 1]['match_id']) ? $this->node->match[$i - 1]['match_id'] : '',
);
$form['match'][$i]['question'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#default_value' => isset($this->node->match[$i - 1]['question']) ? $this->node->match[$i - 1]['question'] : '',
'#required' => $i < 3,
);
$form['match'][$i]['answer'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#default_value' => isset($this->node->match[$i - 1]['answer']) ? $this->node->match[$i - 1]['answer'] : '',
'#required' => $i < 3,
);
$form['match'][$i]['feedback'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#default_value' => isset($this->node->match[$i - 1]['feedback']) ? $this->node->match[$i - 1]['feedback'] : '',
);
}
return $form;
}