Index: lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/choice/lib.php,v retrieving revision 1.59.2.11 diff -u -r1.59.2.11 lib.php --- lib.php 18 Jan 2008 00:31:37 -0000 1.59.2.11 +++ lib.php 17 Feb 2008 23:11:57 -0000 @@ -338,10 +338,18 @@ $currentgroup = 0; } - $users = get_users_by_capability($context, 'mod/choice:choose', 'u.id, u.picture, u.firstname, u.lastname, u.idnumber', 'u.firstname ASC', '', '', $currentgroup, '', true, true); - - $allusersnothidden = get_users_by_capability($context, 'mod/choice:choose', 'u.id', 'u.firstname ASC', '', '', $currentgroup, '', true, false); ///MDL-12331 ugly hack to prevent hidden users from being displayed in the unanswered column. needs fixing! + $allresponses = get_records("choice_answers", "choiceid", $choice->id); + foreach ($allresponses as $usr) { + if (has_capability('mod/choice:choose', $context, $usr->userid, false)) { //if this user is allowed to select a choice. + $users[$usr->userid] = get_record('user', 'id', $usr->userid); + } + } + if ($choice->showunanswered) { + $allusersnothidden = get_users_by_capability($context, 'mod/choice:choose', 'u.id', 'u.firstname ASC', '', '', $currentgroup, '', true, false); ///MDL-12331 ugly hack to prevent hidden users from being displayed in the unanswered column. needs fixing! + } else { + $allusersnothidden = $users; + } if (!empty($CFG->enablegroupings) && !empty($cm->groupingid) && !empty($users)) { $groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id'); foreach($users as $key => $user) { @@ -356,7 +364,7 @@ } $answers = array () ; - if ($allresponses = get_records("choice_answers", "choiceid", $choice->id)) { + if (!empty($allresponses)) { foreach ($allresponses as $aa) { //TODO: rewrite with SQL if ($groupmode and $currentgroup) {