Permalink
Browse files

MDL-30677 quiz: fix attempt counts when a student is in several groups.

  • Loading branch information...
timhunt committed Dec 9, 2011
1 parent 6508da4 commit 13e3f4ca925ddd304e5060a0167e1c833d262719
Showing with 2 additions and 2 deletions.
  1. +2 −2 mod/quiz/lib.php
View
@@ -1433,15 +1433,15 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup
if (groups_get_activity_groupmode($cm)) {
$a->total = $numattempts;
if ($currentgroup) {
- $a->group = $DB->count_records_sql('SELECT count(1) FROM ' .
+ $a->group = $DB->count_records_sql('SELECT COUNT(DISTINCT qa.id) FROM ' .
'{quiz_attempts} qa JOIN ' .
'{groups_members} gm ON qa.userid = gm.userid ' .
'WHERE quiz = ? AND preview = 0 AND groupid = ?',
array($quiz->id, $currentgroup));
return get_string('attemptsnumthisgroup', 'quiz', $a);
} else if ($groups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid)) {
list($usql, $params) = $DB->get_in_or_equal(array_keys($groups));
- $a->group = $DB->count_records_sql('SELECT count(1) FROM ' .
+ $a->group = $DB->count_records_sql('SELECT COUNT(DISTINCT qa.id) FROM ' .
'{quiz_attempts} qa JOIN ' .
'{groups_members} gm ON qa.userid = gm.userid ' .
'WHERE quiz = ? AND preview = 0 AND ' .

0 comments on commit 13e3f4c

Please sign in to comment.