You are here

function QuizQuestionResponse::getScore in Quiz 8.4

Returns stored score if it exists, if not the score is calculated and returned.

Parameters

$weight_adjusted: If the returned score shall be adjusted according to the max_score the question has in a quiz

Return value

Score(int)

7 calls to QuizQuestionResponse::getScore()
ClozeResponse::getReportFormScore in question_types/cloze/lib/Drupal/cloze/ClozeResponse.php
Implementation of getReportFormScore()
LongAnswerResponse::getReportFormScore in question_types/long_answer/lib/Drupal/long_answer/LongAnswerResponse.php
Implementation of getReportFormScore
QuizQuestionResponse::getReport in question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestionResponse.php
Get data suitable for reporting a user's score on the question. This expects an object with the following attributes:
QuizQuestionResponse::getReportFormScore in question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestionResponse.php
Get the score part of the report form
QuizQuestionResponse::isCorrect in question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestionResponse.php
Check to see if the answer is marked as correct.

... See full list

File

question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestionResponse.php, line 91

Class

QuizQuestionResponse

Namespace

Drupal\quiz_question

Code

function getScore($weight_adjusted = TRUE) {
  if ($this->is_skipped) {
    return 0;
  }
  if (!isset($this->score)) {
    $this->score = $this
      ->score();
  }
  if (isset($this->question->score_weight) && $weight_adjusted) {
    return round($this->score * $this->question->score_weight);
  }
  return $this->score;
}