You are here

public function TrueFalseQuestion::getQuestionForm in Quiz 6.6

Same name and namespace in other branches
  1. 6.3 question_types/quiz_question/quiz_question.truefalse.inc \TrueFalseQuestion::getQuestionForm()
  2. 6.5 question_types/quiz_question/quiz_question.truefalse.inc \TrueFalseQuestion::getQuestionForm()

Get the form that will be displayed to the test-taking user.

Parameters

$node: The question node.

$context: The form context.

Return value

Must return a FAPI array.

Overrides QuizQuestion::getQuestionForm

File

question_types/truefalse/truefalse.classes.inc, line 74
Defines the classes necessary for a True/False quiz.

Class

TrueFalseQuestion
Implementation of QuizQuestion.

Code

public function getQuestionForm($node, $context = NULL) {
  $taking_quiz = _quiz_is_taking_context();

  // Question first
  $form['question'] = array(
    '#type' => 'markup',
    '#value' => $node->body,
  );

  // 'tries' is unfortunately required by quiz.module
  $form['tries'] = array(
    '#type' => 'radios',
    '#title' => t('Choose one'),
    '#options' => array(
      1 => $taking_quiz || $node->correct_answer == 0 ? t('True') : t('True (correct)'),
      0 => $taking_quiz || $node->correct_answer == 1 ? t('False') : t('False (correct)'),
    ),
    //'#default_value' => 1,
    '#required' => TRUE,
  );
  return $form;
}