Index: lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/choice/lib.php,v retrieving revision 1.59.2.13 diff -u -r1.59.2.13 lib.php --- lib.php 29 Feb 2008 11:58:32 -0000 1.59.2.13 +++ lib.php 2 Mar 2008 23:35:55 -0000 @@ -294,24 +294,14 @@ } } - -function choice_show_reportlink($choice, $courseid, $cm, $groupmode) { - - if ($groupmode > 0) { - $currentgroup = groups_get_activity_group($cm); - } else { - $currentgroup = 0; - } - - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - $responsecount = 0; - - $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++; - } +function choice_show_reportlink($user, $cm) { + $responsecount =0; + foreach($user as $optionid => $userlist) { + if ($optionid <> 0) { + foreach($userlist as $user) { + $responsecount++; + } + } } echo '
"; - } else if ($choice->showunanswered) { - echo " | "; - } else { - continue; - } - echo format_string(choice_get_option_text($choice, $optionid)); + $maxcolumn = 0; + if ($choice->showunanswered) { + echo " | "; + print_string('notanswered', 'choice'); echo " | "; - $count++; + $column[0] = 0; + foreach ($users[0] as $user) { + $column[0]++; + } + $maxcolumn = $column[0]; } - echo ""; + echo format_string($optiontext); + echo " | "; + $column[$optionid] = 0; - foreach ($userlist as $user) { - if (!($optionid==0 AND empty($allusersnothidden[$user->id]))) { //don't show admins or hidden users + if (isset($users[$optionid])) { + foreach ($users[$optionid] as $user) { $column[$optionid]++; } - } - if ($column[$optionid] > $maxcolumn) { - $maxcolumn = $column[$optionid]; + if ($column[$optionid] > $maxcolumn) { + $maxcolumn = $column[$optionid]; + } + } else { + $column[$optionid] = 0; } } + echo "
---|---|---|
";
+ echo "![]() | ";
+ }
+ $count = 1;
+ foreach ($choice->option as $optionid => $optiontext) {
if ($maxcolumn) {
$height = $COLUMN_HEIGHT * ((float)$column[$optionid] / (float)$maxcolumn);
}
@@ -560,16 +503,16 @@
echo "";
$count++;
}
- echo "||
"; + } + $count = 1; + foreach ($choice->option as $optionid => $optiontext) { echo " | ";
- if ($choice->limitanswers && !$optionid==0) {
+ if ($choice->limitanswers) {
echo get_string("taken", "choice").":";
echo $column[$optionid];
echo " "; @@ -583,13 +526,13 @@ $count++; } echo " |