From: Andrew Davis Date: Tue, 24 Jun 2014 03:53:34 +0000 (+0800) Subject: MDL-46036 mod_survey: added logic to prevent user trying to download when there are... X-Git-Tag: v2.8.0-beta~647^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=4257ae82e87710327310cef47e0bfa401788d017;hp=-c MDL-46036 mod_survey: added logic to prevent user trying to download when there are no results --- 4257ae82e87710327310cef47e0bfa401788d017 diff --git a/mod/survey/report.php b/mod/survey/report.php index 5ff293e81a8..2b6efc21d17 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -485,22 +485,28 @@ require_capability('mod/survey:download', $context); - echo '

'.get_string("downloadinfo", "survey").'

'; + $numusers = survey_count_responses($survey->id, $currentgroup, $groupingid); + if ($numusers > 0) { + echo html_writer::tag('p', get_string("downloadinfo", "survey"), array('class' => 'centerpara')); - echo $OUTPUT->container_start('reportbuttons'); - $options = array(); - $options["id"] = "$cm->id"; - $options["group"] = $currentgroup; + echo $OUTPUT->container_start('reportbuttons'); + $options = array(); + $options["id"] = "$cm->id"; + $options["group"] = $currentgroup; - $options["type"] = "ods"; - echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadods")); + $options["type"] = "ods"; + echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadods")); - $options["type"] = "xls"; - echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadexcel")); + $options["type"] = "xls"; + echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadexcel")); - $options["type"] = "txt"; - echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadtext")); - echo $OUTPUT->container_end(); + $options["type"] = "txt"; + echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadtext")); + echo $OUTPUT->container_end(); + + } else { + echo html_writer::tag('p', get_string("nobodyyet", "survey"), array('class' => 'centerpara')); + } break;