You are here

function long_answer_score_form in Quiz 7

Same name and namespace in other branches
  1. 8.4 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
  2. 6.6 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
  3. 6.3 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
  4. 6.4 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
  5. 6.5 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
  6. 7.6 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
  7. 7.4 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()

Build a form for scoring long-answer questions.

Parameters

$node: The question node.

$answer: An object containing an answer to the question. This form is for scoring that answer.

Return value

The form (as a FAPI array).

1 string reference to 'long_answer_score_form'
long_answer_edit_score in question_types/long_answer/long_answer.admin.inc
Page handler for displaying a scoring form. This function is called directly from the menu router. It generates a form for scoring a quiz.

File

question_types/long_answer/long_answer.admin.inc, line 71
Administration pages for the long answer questions module.

Code

function long_answer_score_form($form, $form_state, $node, $answer) {
  if (!$node || $node->type != 'long_answer' || !$answer) {
    drupal_not_found();
    return;
  }

  // Set up the form
  $form['question'] = array(
    '#type' => 'item',
    '#title' => t('Question'),
    '#markup' => check_markup($node->body, $node->format),
  );
  $form['rubric'] = array(
    '#type' => 'item',
    '#title' => t('Rubric'),
    '#markup' => check_markup($node->rubric, variable_get('long_answer_markup_filter', FILTER_FORMAT_DEFAULT)),
  );
  $form['show_max_score'] = array(
    '#type' => 'item',
    '#title' => t('Maximum Score'),
    '#markup' => (int) $answer->rel_max_score,
  );
  $form['score_answer'] = array(
    '#type' => 'fieldset',
    '#title' => t('Score answer'),
  );
  $form['score_answer']['answer'] = array(
    '#type' => 'item',
    '#title' => t('Answer'),
    '#markup' => check_markup($answer->answer, variable_get('long_answer_markup_filter', FILTER_FORMAT_DEFAULT)),
  );
  $form['score_answer']['score'] = array(
    '#type' => 'textfield',
    '#title' => t('Score'),
    '#description' => t('The score for this essay, between 0 and @max', array(
      '@max' => $answer->rel_max_score,
    )),
    '#size' => 3,
    '#maxlength' => 3,
    '#default_value' => (int) $answer->rel_score,
    '#required' => TRUE,
  );
  $form['score_answer']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save this score'),
  );

  // Save some work by keeping these.
  $form['max_score'] = array(
    '#type' => 'value',
    '#value' => $node->max_score,
  );
  $form['rel_max_score'] = array(
    '#type' => 'value',
    '#value' => $answer->rel_max_score,
  );
  $form['question_nid'] = array(
    '#type' => 'value',
    '#value' => $answer->question_nid,
  );
  $form['question_vid'] = array(
    '#type' => 'value',
    '#value' => $answer->question_vid,
  );
  $form['result_id'] = array(
    '#type' => 'value',
    '#value' => $answer->result_id,
  );
  return $form;
}