public function ShortAnswerResponse::score in Quiz 8.4
Implementation of score
Overrides QuizQuestionResponse::score
See also
QuizQuestionResponse#score()
File
- question_types/
short_answer/ lib/ Drupal/ short_answer/ ShortAnswerResponse.php, line 168 - The main classes for the short answer response.
Class
- ShortAnswerResponse
- Extension of QuizQuestionResponse
Namespace
Drupal\short_answerCode
public function score() {
// Manual scoring means we go with what is in the DB.
if ($this->question->correct_answer_evaluation == ShortAnswerQuestion::ANSWER_MANUAL) {
$score = db_query('SELECT score FROM {quiz_short_answer_user_answers} WHERE result_id = :result_id AND question_vid = :question_vid', array(
':result_id' => $this->rid,
':question_vid' => $this->question
->getRevisionId(),
))
->fetchField();
if (!$score) {
$score = 0;
}
}
else {
$shortAnswer = new ShortAnswerQuestion($this->question);
$score = $shortAnswer
->evaluateAnswer($this
->getResponse());
}
return $score;
}