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

This commit is contained in:
Tim Hunt
2011-12-09 17:59:29 +00:00
parent acb3bf8ac1
commit 853f2e8eea
+2 -2
View File
@@ -1447,7 +1447,7 @@ 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 = ?',
@@ -1455,7 +1455,7 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $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 ' .