MDL-18092 - better checking for empty vars when no users are in course.
authordanmarsden <danmarsden>
Mon, 9 Feb 2009 09:19:47 +0000 (09:19 +0000)
committerdanmarsden <danmarsden>
Mon, 9 Feb 2009 09:19:47 +0000 (09:19 +0000)
mod/choice/lib.php
mod/choice/report.php

index f1fde6886f4d8f95d3b735c27b8af42bf1fa6e45..182cfc8975559b44c3eb4d0445d9c0d1c4c8313f 100644 (file)
@@ -332,8 +332,9 @@ function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish
         $forcepublish = $choice->publish;
     }
 
-    if (!$allresponses) {
+    if (empty($allresponses)) {
         print_heading(get_string("nousersyet"));
+        return false;
     }
 
     $totalresponsecount = 0;
@@ -378,7 +379,7 @@ function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish
             }
             echo "</tr><tr>";
 
-            if ($choice->showunanswered) {
+            if ($choice->showunanswered && !empty($allresponses[0])) {
                 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
@@ -740,7 +741,9 @@ function choice_get_response_data($choice, $cm, $groupmode) {
             }
         }
     }
-
+    if (empty($allresponses[0])) {
+        unset($allresponses[0]);
+    }
     return $allresponses;
 }
 
index 1d752409716b6f5d3ea9818a1029fc6812489c33..33e6f611f52cd3dfb25d325fa250f633ed009b5f 100644 (file)
     choice_show_results($choice, $course, $cm, $users, $format); //show table with students responses.
 
    //now give links for downloading spreadsheets.
-    if (has_capability('mod/choice:downloadresponses',$context)) {
+    if (!empty($users) && has_capability('mod/choice:downloadresponses',$context)) {
         echo "<br />\n";
         echo "<table class=\"downloadreport\"><tr>\n";
         echo "<td>";
     }
     print_footer($course);
 
-?>
+?>
\ No newline at end of file