You are here

function QuizQuestionResponse::getScore in OG Quiz 7

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)

5 calls to QuizQuestionResponse::getScore()
LongAnswerResponse::getReportFormScore in includes/og_long_answer.php
Implementation of getReportFormScore
QuizQuestionResponse::getReport in includes/og_quiz_question.php
Get data suitable for reporting a user's score on the question. This expects an object with the following attributes:
QuizQuestionResponse::getReportFormScore in includes/og_quiz_question.php
Get the score part of the report form
QuizQuestionResponse::isCorrect in includes/og_quiz_question.php
Check to see if the answer is marked as correct.
QuizQuestionResponse::toBareObject in includes/og_quiz_question.php
Represent the response as a stdClass object.

File

includes/og_quiz_question.php, line 895
Classes used in the Quiz Question module.

Class

QuizQuestionResponse
Each question type must store its own response data and be able to calculate a score for that data.

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;
}