]> git.mjollnir.org Git - moodle.git/commitdiff
couple of bugs when no data returned.
authordanmarsden <danmarsden>
Thu, 6 Apr 2006 20:42:35 +0000 (20:42 +0000)
committerdanmarsden <danmarsden>
Thu, 6 Apr 2006 20:42:35 +0000 (20:42 +0000)
mod/choice/lib.php

index 75eca5bd09c8ef18c3d7c58a15674332d1ed57f3..9351d1abb1dd71006b42304d878b726aa0f5b0e1 100644 (file)
@@ -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 "</td>";
@@ -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 "</tr></table>";
-            if (isteacher($course->id, $user->id)) {
+            if (isteacher($course->id, $USER->id)) {
                            echo "</form></div>";
                        }
             break;