public function MatchingResponse::score in Quiz 6.3
Same name and namespace in other branches
- 6.6 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 6.4 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 6.5 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 7.6 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 7 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 7.4 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 7.5 question_types/matching/matching.classes.inc \MatchingResponse::score()
Calculate the score for the response. This MUST set the $score instance variable.
Overrides QuizQuestionResponse::score
1 call to MatchingResponse::score()
- MatchingResponse::__construct in question_types/
matching/ matching.classes.inc - Create a new user response.
File
- question_types/
matching/ matching.classes.inc, line 241 - quiz_directions.classes
Class
- MatchingResponse
- Class that describes a "Directions question response". For the most part, no real scoring takes place for a direction node. However, there are a few behind-the-scenes tricks that are done here to make the quiz-taking process a little easier.
Code
public function score() {
$wrong_answer = 0;
$user_answers = isset($this->answer) ? $this->answer : $this
->getUserAnswers();
foreach ($user_answers as $key => $value) {
if ($key != $value) {
$wrong_answer++;
}
}
$this->score = !empty($user_answers) && !$wrong_answer ? 1 : 0;
return $this->score;
}