public function TrueFalseResponse::score in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_truefalse/src/Plugin/quiz/QuizQuestion/TrueFalseResponse.php \Drupal\quiz_truefalse\Plugin\quiz\QuizQuestion\TrueFalseResponse::score()
- 6.x question_types/quiz_truefalse/src/Plugin/quiz/QuizQuestion/TrueFalseResponse.php \Drupal\quiz_truefalse\Plugin\quiz\QuizQuestion\TrueFalseResponse::score()
Calculate the unscaled score in points for this question response.
Parameters
array $values: A part of form state values with the question input from the user.
Return value
int The unscaled point value of the answer.
Overrides QuizResultAnswerEntityTrait::score
File
- question_types/
quiz_truefalse/ src/ Plugin/ quiz/ QuizQuestion/ TrueFalseResponse.php, line 17
Class
- TrueFalseResponse
- Extension of QuizQuestionResponse.
Namespace
Drupal\quiz_truefalse\Plugin\quiz\QuizQuestionCode
public function score($response) {
$tfQuestion = $this
->getQuizQuestion();
$this
->set('truefalse_answer', $response['answer']);
if ($response['answer'] == $tfQuestion
->getCorrectAnswer()) {
return $tfQuestion
->getMaximumScore();
}
else {
return 0;
}
}