function short_answer_score_form_validate in Quiz 7
Same name and namespace in other branches
- 8.4 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_validate()
- 6.6 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_validate()
- 6.3 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_validate()
- 6.4 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_validate()
- 6.5 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_validate()
- 7.6 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_validate()
- 7.4 question_types/short_answer/short_answer.admin.inc \short_answer_score_form_validate()
Validate the score form
File
- question_types/
short_answer/ short_answer.admin.inc, line 136 - short_answer.admin
Code
function short_answer_score_form_validate($form, $form_state) {
// Check to make sure that entered score is not higher than max allowed score.
$max = (int) $form_state['values']['rel_max_score'];
$given = (int) $form_state['values']['score'];
if (!_quiz_is_int($form_state['values']['score'], 0, $max)) {
$args = array(
'@score' => $given,
'@max' => $max,
);
form_error($form['score'], t('The score needs to be a number between 0 and @max', $args));
}
}