You are here

public function MatchingQuestion::getAnsweringForm in Quiz 6.4

Same name and namespace in other branches
  1. 7.6 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
  2. 7 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
  3. 7.4 question_types/matching/matching.classes.inc \MatchingQuestion::getAnsweringForm()
  4. 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 171
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'], FILTER_FORMAT_DEFAULT, FALSE);
    $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']];
    }
  }
  $form['scoring_info'] = array(
    '#type' => 'markup',
    '#value' => '<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;
}