You are here

public function MultichoiceQuestion::getMaximumScore in Quiz 7.6

Same name and namespace in other branches
  1. 6.4 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getMaximumScore()
  2. 7 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getMaximumScore()
  3. 7.4 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getMaximumScore()
  4. 7.5 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getMaximumScore()

Implementation of getMaximumScore.

Overrides QuizQuestion::getMaximumScore

See also

QuizQuestion#getMaximumScore()

File

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

Class

MultichoiceQuestion
Extension of QuizQuestion.

Code

public function getMaximumScore() {
  if ($this->node->choice_boolean) {
    return 1;
  }
  $max = 0;
  for ($i = 0; isset($this->node->alternatives[$i]); $i++) {
    $short = $this->node->alternatives[$i];
    if ($this->node->choice_multi) {
      $max += max($short['score_if_chosen'], $short['score_if_not_chosen']);
    }
    else {
      $max = max($max, $short['score_if_chosen'], $short['score_if_not_chosen']);
    }
  }
  return max($max, 1);
}