public function ShortAnswerQuestion::validate in Quiz 6.5
Same name and namespace in other branches
- 6.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::validate()
- 6.3 question_types/short_answer/short_answer.classes.inc \ShortAnswerQuestion::validate()
Provides validation for question before it is created.
When a new question is created and initially submited, this is called to validate that the settings are acceptible.
Parameters
$node: The node storing the question.
$form: The processed form.
Overrides QuizQuestion::validate
File
- question_types/
short_answer/ short_answer.classes.inc, line 62 - The main classes for the short answer question type.
Class
- ShortAnswerQuestion
- Implementation of QuizQuestion.
Code
public function validate($node, &$form) {
$maximum_score = $node->maximum_score;
if (!ctype_digit($maximum_score) || intval($maximum_score) < 0) {
form_set_error('maximum_score', t('Score must be a positive integer (0 or higher).'));
}
if ($node->correct_answer_evaluation != self::ANSWER_MANUAL && empty($node->correct_answer)) {
form_set_error('correct_answer_evaluation', t('An answer must be specified for any evaluation type other than manual scoring.'));
}
}