From 9acb770082595b6f318d1dcaeaa49681cb3b745d Mon Sep 17 00:00:00 2001 From: danmarsden Date: Mon, 9 Feb 2009 09:19:47 +0000 Subject: [PATCH] MDL-18092 - better checking for empty vars when no users are in course. --- mod/choice/lib.php | 9 ++++++--- mod/choice/report.php | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mod/choice/lib.php b/mod/choice/lib.php index f1fde6886f..182cfc8975 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -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 ""; - if ($choice->showunanswered) { + if ($choice->showunanswered && !empty($allresponses[0])) { echo ""; // added empty row so that when the next iteration is empty, // we do not get
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; } diff --git a/mod/choice/report.php b/mod/choice/report.php index 1d75240971..33e6f611f5 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -206,7 +206,7 @@ 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 "
\n"; echo "\n"; echo "
"; @@ -225,4 +225,4 @@ } print_footer($course); -?> +?> \ No newline at end of file -- 2.39.5