You are here

function long_answer_score_form in Quiz 6.5

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. 7.6 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
  6. 7 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 84
Administration pages for the long answer questions module.

Code

function long_answer_score_form($context, $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'),
    '#value' => check_markup($node->body, $node->format),
  );
  $form['answer'] = array(
    '#type' => 'item',
    '#title' => t('Answer'),
    '#value' => check_markup($answer->answer, variable_get('long_answer_markup_filter', FILTER_FORMAT_DEFAULT)),
  );
  $form['show_max_score'] = array(
    '#type' => 'item',
    '#title' => t('Maximum Score'),
    '#value' => (int) $node->maximum_score,
  );
  $form['score'] = array(
    '#type' => 'textfield',
    '#title' => t('Score'),
    '#description' => t('The score for this essay, between 0 and @max', array(
      '@max' => $node->maximum_score,
    )),
    '#size' => 6,
    '#maxlength' => 6,
    '#default_value' => (int) $answer->score,
    '#required' => TRUE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save this score'),
  );

  // Save some work by keeping these.
  $form['maximum_score'] = array(
    '#type' => 'value',
    '#value' => $node->maximum_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;
}