You are here

public function ShortAnswerQuestion::getCreationForm in Quiz 6.3

Same name and namespace in other branches
  1. 6.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getCreationForm()
  2. 6.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getCreationForm()
  3. 6.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getCreationForm()
  4. 7.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getCreationForm()
  5. 7 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getCreationForm()
  6. 7.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getCreationForm()
  7. 7.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::getCreationForm()

Get the form used to create a new question.

Return value

Must return a FAPI array.

Overrides QuizQuestion::getCreationForm

File

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

Class

ShortAnswerQuestion
Implementation of QuizQuestion.

Code

public function getCreationForm($edit) {
  $form['answer'] = array(
    '#type' => 'fieldset',
    '#title' => t('Answer'),
    '#description' => t('Provide the answer and the method by which the answer will be evaluated.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['answer']['correct_answer_evaluation'] = array(
    '#type' => 'radios',
    '#title' => t('Pick one'),
    '#description' => t('Choose a matching type.'),
    '#options' => array(
      self::ANSWER_MATCH => t('Exact match (answer must match case)'),
      self::ANSWER_INSENSITIVE_MATCH => t('Case insensitive match (answer need not match case)'),
      self::ANSWER_REGEX => t('Match against a regular expression (answer must match the supplied regular expression)'),
      self::ANSWER_MANUAL => t('Manually score matches (no automatic grading)'),
    ),
    '#default_value' => isset($this->node->correct_answer_evaluation) ? $this->node->correct_answer_evaluation : self::ANSWER_MATCH,
    '#required' => FALSE,
  );
  $form['answer']['regex_box'] = array(
    '#type' => 'fieldset',
    '#title' => t('About regular expressions'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['answer']['regex_box']['regex_help'] = array(
    '#type' => 'markup',
    '#value' => '<p>' . t('Regular expressions are an advanced syntax for pattern matching. They allow you to create a concise set of rules that must be met before a value can be considered a match.') . '</p><p>' . t('For more on regular expression syntax, visit !url.', array(
      '!url' => l('the PHP regular expressions documentation', 'http://www.php.net/manual/en/book.pcre.php'),
    )) . '</p>',
  );
  $form['answer']['correct_answer'] = array(
    '#type' => 'textfield',
    '#title' => t('Answer'),
    '#description' => t('Specify the answer. If this question is manually scored, no answer need be supplied.'),
    '#default_value' => isset($this->node->correct_answer) ? $this->node->correct_answer : '',
    '#size' => 60,
    '#maxlength' => 256,
    '#required' => FALSE,
  );
  $form['answer']['maximum_score'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum score'),
    '#description' => t('If this is automatically graded, this will be treated as an "all or nothing" score. Manual grading may assign any whole number value between 0 and this number.'),
    '#default_value' => isset($this->node->maximum_score) ? $this->node->maximum_score : 1,
    '#size' => 3,
    '#maxlength' => 3,
    '#required' => FALSE,
  );
  return $form;
}