public function MatchingQuestion::getAnsweringForm in Quiz 7.4
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.5 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
Implementation of getAnsweringForm
Overrides QuizQuestion::getAnsweringForm
See also
QuizQuestion#getAnsweringForm($form_state, $rid)
File
- question_types/
matching/ matching.classes.inc, line 217 - matching.classes
Class
- MatchingQuestion
- Extension of QuizQuestion.
Code
public function getAnsweringForm(array $form_state = NULL, $rid) {
$form = parent::getAnsweringForm($form_state, $rid);
//$form['#theme'] = 'matching_answering_form';
if (isset($rid)) {
// The question has already been answered. We load the answers
$response = new MatchingResponse($rid, $this->node);
$responses = $response
->getResponse();
}
list($matches, $select_option) = $this
->getSubquestions();
$form['subquestions']['#theme'] = 'matching_subquestion_form';
foreach ($matches as $match) {
$form['subquestions'][$match['match_id']]['#question'] = check_markup($match['question']);
$form['subquestions'][$match['match_id']]['tries[' . $match['match_id'] . ']'] = array(
'#type' => 'select',
'#options' => $this
->customShuffle($select_option),
);
if (isset($rid)) {
// If this question already has been answered
$form['subquestions'][$match['match_id']]['tries[' . $match['match_id'] . ']']['#default_value'] = $responses[$match['match_id']];
}
}
$this
->remove_repeated($form['subquestions']);
$form['scoring_info'] = array(
'#markup' => '<p><em>' . t('You lose points by selecting incorrect options. You may leave an option blank to avoid losing points.') . '</em></p>',
);
if (variable_get('quiz_matching_shuffle_options', TRUE)) {
$form['subquestions'] = $this
->customShuffle($form['subquestions']);
}
return $form;
}