public function MatchingResponse::score in Quiz 6.5
Same name and namespace in other branches
- 6.6 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 6.3 question_types/matching/matching.classes.inc \MatchingResponse::score()
- 6.4 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()
1 call to MatchingResponse::score()
- MatchingResponse::__construct in question_types/
matching/ matching.classes.inc
File
- question_types/
matching/ matching.classes.inc, line 236 - 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();
$user_answers = isset($user_answers) ? $user_answers : array();
// to prevent warning : Invalid argument supplied for foreach()
foreach ($user_answers as $key => $value) {
if ($key != $value) {
$wrong_answer++;
}
}
$this->score = !empty($user_answers) && !$wrong_answer ? 1 : 0;
return $this->score;
}