function short_answer_score_form_submit in Quiz 7
Same name and namespace in other branches
- 8.4 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_submit()
- 6.6 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_submit()
- 6.3 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_submit()
- 6.4 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_submit()
- 6.5 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_submit()
- 7.6 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_submit()
- 7.4 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_submit()
Submit the score form
File
- question_types/
short_answer/ short_answer.admin.inc, line 150 - short_answer.admin
Code
function short_answer_score_form_submit($form, &$form_state) {
$sql = 'SELECT nid, vid FROM {quiz_node_results} WHERE result_id = %d';
$result = db_fetch_object(db_query('SELECT nid, vid FROM {quiz_node_results} WHERE result_id = :result_id', array(
':result_id' => $form_state['values']['result_id'],
)));
$quiz = node_load($result->nid, $result->vid);
$nid = $form_state['values']['question_nid'];
$vid = $form_state['values']['question_vid'];
$rid = $form_state['values']['result_id'];
$score = $form_state['values']['score'];
$result = short_answer_score_an_answer($quiz, $nid, $vid, $rid, $score);
if ($result == 1) {
drupal_set_message("The score has been saved.");
$form_state['redirect'] = 'admin/quiz/reports/score-short-answer';
}
else {
drupal_set_message(t('Error saving the score. The selected answer was not scored.'), 'error');
}
}