public static function LongAnswerQuestion::getAnsweringFormValidate in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_long_answer/src/Plugin/quiz/QuizQuestion/LongAnswerQuestion.php \Drupal\quiz_long_answer\Plugin\quiz\QuizQuestion\LongAnswerQuestion::getAnsweringFormValidate()
- 6.x question_types/quiz_long_answer/src/Plugin/quiz/QuizQuestion/LongAnswerQuestion.php \Drupal\quiz_long_answer\Plugin\quiz\QuizQuestion\LongAnswerQuestion::getAnsweringFormValidate()
Validate a user's answer.
Parameters
array $element: The form element of this question.
mixed $form_state: Form state.
Overrides QuizQuestionEntityTrait::getAnsweringFormValidate
File
- question_types/
quiz_long_answer/ src/ Plugin/ quiz/ QuizQuestion/ LongAnswerQuestion.php, line 77
Class
- LongAnswerQuestion
- @QuizQuestion ( id = "long_answer", label = Plugin annotation @Translation("Long answer question"), handlers = { "response" = "\Drupal\quiz_long_answer\Plugin\quiz\QuizQuestion\LongAnswerResponse" } )
Namespace
Drupal\quiz_long_answer\Plugin\quiz\QuizQuestionCode
public static function getAnsweringFormValidate(array &$element, FormStateInterface $form_state) {
parent::getAnsweringFormValidate($element, $form_state);
if (isset($element['value'])) {
$check =& $element['value'];
}
else {
$check =& $element;
}
if (empty($check['#value'])) {
$form_state
->setError($check, t('You must provide an answer.'));
}
}