You are here

public function ShortAnswerResponse::score in Quiz 6.3

Same name and namespace in other branches
  1. 6.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::score()
  2. 6.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::score()
  3. 6.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::score()
  4. 7.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::score()
  5. 7 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::score()
  6. 7.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::score()
  7. 7.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::score()

Calculate the score for the response. This MUST set the $score instance variable.

Overrides QuizQuestionResponse::score

File

question_types/short_answer/short_answer.classes.inc, line 324
The main classes for the short answer question type.

Class

ShortAnswerResponse
The short answer question response class.

Code

public function score() {

  // Manual scoring means we go with what is in the DB.
  if ($this->question->correct_answer_evaluation == ShortAnswerQuestion::ANSWER_MANUAL) {
    $sql = "SELECT score FROM {quiz_short_answer_user_answers} WHERE result_id = %d AND question_vid = %d";
    $score = (int) db_result(db_query($sql, $this->rid, $this->question->vid));
  }
  else {
    $shortAnswer = new ShortAnswerQuestion($this->question);
    $score = $shortAnswer
      ->evaluateAnswer($this
      ->getResponse());
  }
  $this->score = $score;
  return $score;
}