You are here

public function LongAnswerQuestion::getAnsweringForm in Quiz 7.5

Same name and namespace in other branches
  1. 6.4 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::getAnsweringForm()
  2. 7.6 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::getAnsweringForm()
  3. 7 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::getAnsweringForm()
  4. 7.4 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::getAnsweringForm()

Implementation of getAnsweringForm().

Overrides QuizQuestion::getAnsweringForm

See also

QuizQuestion::getAnsweringForm()

File

question_types/long_answer/long_answer.classes.inc, line 118
Long answer classes.

Class

LongAnswerQuestion
Extension of QuizQuestion.

Code

public function getAnsweringForm(array $form_state = NULL, $result_id) {
  $element = parent::getAnsweringForm($form_state, $result_id);
  $element += array(
    '#title' => t('Answer'),
    '#description' => t('Enter your answer here. If you need more space, click on the grey bar at the bottom of this area and drag it down.'),
    '#rows' => 15,
    '#cols' => 60,
  );
  if ($this->node->answer_text_processing) {
    $element['#type'] = 'text_format';
  }
  else {
    $element['#type'] = 'textarea';
  }
  if (isset($result_id)) {
    if ($response = _quiz_question_response_get_instance($result_id, $this->node)) {
      if ($user_response = $response
        ->getResponse()) {
        $element['#default_value'] = $user_response;
        $element['#format'] = $response->answer_format;
      }
    }
  }
  return $element;
}