You are here

public function MultichoiceResponse::isValid in Quiz 7.4

Same name and namespace in other branches
  1. 6.4 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::isValid()
  2. 7 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::isValid()

Implementation of isValid

Overrides QuizQuestionResponse::isValid

See also

QuizQuestionResponse#isValid()

File

question_types/multichoice/multichoice.classes.inc, line 848
The main classes for the multichoice question type.

Class

MultichoiceResponse
Extension of QuizQuestionResponse

Code

public function isValid() {
  if ($this->question->choice_multi) {
    return TRUE;
  }
  if (empty($this->user_answer_ids)) {
    return t('You must provide an answer');
  }

  // Perform extra check since FAPI isn't being used:
  if (count($this->user_answer_ids) > 1) {
    return t('You are only allowed to select one answer');
  }
  return TRUE;
}