public function MatchingQuestion::getAnsweringForm in Quiz 7.5
Same name and namespace in other branches
- 6.4 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
- 7.6 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
- 7 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
- 7.4 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
Implementation of getAnsweringForm().
Overrides QuizQuestion::getAnsweringForm
See also
QuizQuestion::getAnsweringForm()
File
- question_types/
matching/ matching.classes.inc, line 204 - Matching classes.
Class
- MatchingQuestion
- Extension of QuizQuestion.
Code
public function getAnsweringForm(array $form_state = NULL, $result_id) {
$form = parent::getAnsweringForm($form_state, $result_id);
if (isset($result_id)) {
// The question has already been answered. We load the answers.
$response = new MatchingResponse($result_id, $this->node);
$responses = $response
->getResponse();
}
list($matches, $select_option) = $this
->getSubquestions();
//$form['#theme'] = 'matching_subquestion_form';
foreach ($matches as $match) {
$form[$match['match_id']] = array(
'#title' => $match['question'],
'#type' => 'select',
'#options' => array(
'def' => '',
),
);
$form[$match['match_id']]['#options'] += $this
->customShuffle($select_option);
if ($responses) {
// If this question already has been answered.
$form[$match['match_id']]['#default_value'] = $responses[$match['match_id']];
}
}
if (variable_get('quiz_matching_shuffle_options', TRUE)) {
$form = $this
->customShuffle($form);
}
$form['scoring_info'] = array(
'#access' => !empty($this->node->choice_penalty),
'#markup' => '<p><em>' . t('You lose points by selecting incorrect options. You may leave an option blank to avoid losing points.') . '</em></p>',
);
return $form;
}