You are here

public function ShortAnswerQuestion::getQuestionForm in Quiz 6.6

Same name and namespace in other branches
  1. 6.3 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getQuestionForm()
  2. 6.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::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

1 call to ShortAnswerQuestion::getQuestionForm()
ShortAnswerQuestion::view in question_types/short_answer/short_answer.classes.inc
Retrieve information relevant for viewing the node. This data is generally added to the node's extra field.

File

question_types/short_answer/short_answer.classes.inc, line 95
The main classes for the short answer question type.

Class

ShortAnswerQuestion
Implementation of QuizQuestion.

Code

public function getQuestionForm($node, $context = NULL) {
  $form['question'] = array(
    '#type' => 'markup',
    '#value' => check_markup($node->body, $node->format, FALSE),
  );
  if (_quiz_is_taking_context()) {
    $form['tries'] = array(
      '#type' => 'textfield',
      '#title' => t('Answer'),
      '#description' => t('Enter your answer here'),
      '#default_value' => isset($context['tries']) ? $context['tries'] : '',
      '#size' => 60,
      '#maxlength' => 256,
      '#required' => FALSE,
    );
  }
  else {
    if (user_access('view quiz question solutions')) {
      $form['tries'] = array(
        '#type' => 'markup',
        // FIXME hack should use CSS instead, maybe across all quiz_question.module
        '#value' => t('Correct answer is <span style="background-color: lightgreen">!answer</span>', array(
          '!answer' => $node->correct_answer,
        )),
      );
    }

    // else case handled in quiz_question.module
  }
  return $form;
}