You are here

function multichoice_render_question_form in Quiz 5.2

Same name and namespace in other branches
  1. 5 multichoice.module \multichoice_render_question_form()
  2. 6.6 question_types/multichoice/multichoice.module \multichoice_render_question_form()
  3. 6.2 multichoice.module \multichoice_render_question_form()
  4. 6.3 question_types/multichoice/multichoice.module \multichoice_render_question_form()
  5. 6.5 question_types/multichoice/multichoice.module \multichoice_render_question_form()

Print question to screen.

Parameters

$node: Question node.

Return value

HTML output.

1 string reference to 'multichoice_render_question_form'
multichoice_render_question in ./multichoice.module

File

./multichoice.module, line 530
Multiple choice question type for the Quiz module.

Code

function multichoice_render_question_form($node) {

  // Radio buttons for single selection questions, checkboxes for multiselect.
  if ($node->multiple_answers == 0) {
    $type = 'radios';
  }
  else {
    $type = 'checkboxes';
  }

  // Get options.
  $options = array();
  while (list($key, $answer) = each($node->answers)) {
    if (empty($answer['correct']) && !isset($answer['answer']) && empty($answer['feedback'])) {
      unset($node->answers[$key]);
    }
    else {
      $options[$answer['answer_id']] = '<span class="multichoice_answer_text">' . check_markup($answer['answer'], $node->format, FALSE) . '</span>';
    }
  }
  $form['start'] = array(
    '#type' => 'markup',
    '#value' => '<div class="multichoice_form">',
  );
  $form['question'] = array(
    '#type' => 'markup',
    '#value' => check_markup($node->body, $node->format, FALSE),
  );

  // Create form.
  $form['tries'] = array(
    '#type' => $type,
    '#options' => $options,
    '#default_value' => -1,
  );
  $quiz = node_load(arg(1));
  if ($quiz->backwards_navigation == 1 && $node->question_number) {
    $form['back'] = array(
      '#type' => 'submit',
      '#value' => t('Back'),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}