From: moodler Date: Mon, 3 Mar 2008 04:36:32 +0000 (+0000) Subject: MDL-13478 Merged from 1.9 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7b360f33af295979e94226716ef4df0eda12fbe8;p=moodle.git MDL-13478 Merged from 1.9 --- diff --git a/mod/choice/lib.php b/mod/choice/lib.php index bd0b244153..c1e44cb5e0 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -304,16 +304,15 @@ function choice_show_reportlink($choice, $courseid, $cm, $groupmode) { } $context = get_context_instance(CONTEXT_MODULE, $cm->id); - $responsecount = 0; + $availableusers = get_users_by_capability($context, 'mod/choice:choose', 'u.id', '','','',$currentgroup, '', true, true); - $allresponses = get_records("choice_answers", "choiceid", $choice->id); //get all responses for this choice. - $responsecount = 0; - foreach ($allresponses as $usr) { - if (has_capability('mod/choice:choose', $context, $usr->userid, false)) { //if this user is allowed to select a choice. - $responsecount++; - } - } + $responsecount = 0; + if(!empty($availableusers)){ + // flatten the users to get a list of userids + $userids = implode( ', ', array_keys($availableusers)); + $responsecount = count_records_select('choice_answers', "choiceid = {$choice->id} AND userid IN ( $userids );"); + } echo ''; - } - - if (empty($htmlarray[$choice->course]['choice'])) { - $htmlarray[$choice->course]['choice'] = $str; - } else { - $htmlarray[$choice->course]['choice'] .= $str; - } - } - } -} ?>