function long_answer_score_form in Quiz 8.4
Same name and namespace in other branches
- 6.6 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
- 6.3 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
- 6.4 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
- 6.5 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
- 7.6 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
- 7 question_types/long_answer/long_answer.admin.inc \long_answer_score_form()
- 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 72 - Administration pages for the long answer questions module.
Code
function long_answer_score_form($form, $form_state, $node, $answer) {
if (!$node || $node
->getType() != 'long_answer' || !$answer) {
throw new NotFoundHttpException();
return;
}
$body = $node->{'body'}
->getValue();
// Set up the form
$form['question'] = array(
'#type' => 'item',
'#title' => t('Question'),
'#markup' => check_markup($body[0]['value'], $body[0]['format']),
);
$form['rubric'] = array(
'#type' => 'item',
'#title' => t('Rubric'),
'#markup' => check_markup($node->rubric),
);
$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),
);
$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']['answer_feedback'] = array(
'#title' => t('Feedback'),
'#type' => 'textarea',
'#description' => t('The text entered here would be shown to attendees'),
'#default_value' => $answer->answer_feedback,
);
$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;
}