public function LongAnswerQuestion::validate in Quiz 6.6
Same name and namespace in other branches
- 6.3 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::validate()
- 6.5 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::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/
long_answer/ long_answer.classes.inc, line 38 - Long answer classes.
Class
- LongAnswerQuestion
- Implementation of QuizQuestion.
Code
public function validate($node, &$form) {
// Check to make sure that the maximum score is greater-than or equal-to 0.
$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).'));
}
}