From 6c5a77bbb7a96092bb5aba9fbfe75c8efdab90e6 Mon Sep 17 00:00:00 2001 From: danmarsden Date: Thu, 6 Apr 2006 20:42:35 +0000 Subject: [PATCH] couple of bugs when no data returned. --- mod/choice/lib.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 75eca5bd09..9351d1abb1 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -224,7 +224,7 @@ $cdisplay = array(); echo ($cd->maxanswers - $cd->countanswers); echo " ".get_string('spaceleft', 'choice'); } else { - echo ($cd->maxans - $cd->countanswers); + echo ($cd->maxanswers - $cd->countanswers); echo " ".get_string('spacesleft', 'choice'); } echo ""; @@ -350,12 +350,14 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { foreach ($choice->option as $optionid => $text) { $useranswer[$optionid] = array(); } - foreach ($users as $user) { - if (!empty($user->id) and !empty($answers[$user->id])) { - $answer = $answers[$user->id]; - $useranswer[(int)$answer->optionid][] = $user; - } else { - $useranswer[0][] = $user; + if (!empty($users)) { + foreach ($users as $user) { + if (!empty($user->id) and !empty($answers[$user->id])) { + $answer = $answers[$user->id]; + $useranswer[(int)$answer->optionid][] = $user; + } else { + $useranswer[0][] = $user; + } } } foreach ($choice->option as $optionid => $text) { @@ -473,7 +475,7 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { echo ""; - if (isteacher($course->id, $user->id)) { + if (isteacher($course->id, $USER->id)) { echo ""; } break; -- 2.39.5