From 82ab7cb5358e66ebd26a258bfd22ff80606014dc Mon Sep 17 00:00:00 2001
From: danmarsden <danmarsden>
Date: Mon, 9 Feb 2009 09:33:50 +0000
Subject: [PATCH] MDL-18092 - better checking for empty vars when no users are
 in course. wrong place for empty check!

---
 mod/choice/lib.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/mod/choice/lib.php b/mod/choice/lib.php
index 182cfc8975..c0befa5a8a 100644
--- a/mod/choice/lib.php
+++ b/mod/choice/lib.php
@@ -379,21 +379,23 @@ function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish
             }
             echo "</tr><tr>";
 
-            if ($choice->showunanswered && !empty($allresponses[0])) {
+            if ($choice->showunanswered) {
                 echo "<td class=\"col$count data\" >";
                 // added empty row so that when the next iteration is empty,
                 // we do not get <table></table> erro from w3c validator
                 // MDL-7861
                 echo "<table class=\"choiceresponse\"><tr><td></td></tr>";
-                foreach ($allresponses[0] as $user) {
-                    echo "<tr>";
-                    echo "<td class=\"picture\">";
-                    print_user_picture($user->id, $course->id, $user->picture);
-                    echo "</td><td class=\"fullname\">";
-                    echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">";
-                    echo fullname($user, $hascapfullnames);
-                    echo "</a>";
-                    echo "</td></tr>";
+                if (!empty($allresponses[0])) {
+                    foreach ($allresponses[0] as $user) {
+                        echo "<tr>";
+                        echo "<td class=\"picture\">";
+                        print_user_picture($user->id, $course->id, $user->picture);
+                        echo "</td><td class=\"fullname\">";
+                        echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">";
+                        echo fullname($user, $hascapfullnames);
+                        echo "</a>";
+                        echo "</td></tr>";
+                    }
                 }
                 echo "</table></td>";
             }
-- 
2.39.5