MDL-14945
authorthepurpleblob <thepurpleblob>
Thu, 22 May 2008 10:13:55 +0000 (10:13 +0000)
committerthepurpleblob <thepurpleblob>
Thu, 22 May 2008 10:13:55 +0000 (10:13 +0000)
MDL-14946
Now checks properly for mod/choice:deleteresponses and mod/choice:downloadresponses

mod/choice/lib.php
mod/choice/report.php

index 9917fecd29beb0b2e35b5b9bf2f1dbff4775223d..3ebd07616d1a3ad936d8231572b43dd09da17459 100644 (file)
@@ -380,7 +380,7 @@ function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish
                         foreach ($allresponses[$optionid] as $user) {
                             $columncount[$optionid] += 1;
                             echo '<tr><td class="attemptcell">';
-                            if ($viewresponses) {
+                            if ($viewresponses and has_capability('mod/choice:deleteresponses',$context)) {
                                 echo '<input type="checkbox" name="attemptid[]" value="'. $user->id. '" />';
                             }
                             echo '</td><td class="picture">';
@@ -422,7 +422,7 @@ function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish
             echo "</tr>";
             
             /// Print "Select all" etc.
-            if ($viewresponses) {
+            if ($viewresponses and has_capability('mod/choice:deleteresponses',$context)) {
                 echo '<tr><td></td><td>';
                 echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
                 echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectnone', 'quiz').'</a> ';
index 5e2a62e422cdf7a4921cee14994d34d847c5fbb7..3bee4b3e6aa554de6d1fd10bd5dd727e669fb30c 100644 (file)
     choice_show_results($choice, $course, $cm, $users, $format); //show table with students responses.
 
    //now give links for downloading spreadsheets. 
-    echo "<br />\n";
-    echo "<table class=\"downloadreport\"><tr>\n";
-    echo "<td>";
-    $options = array();
-    $options["id"] = "$cm->id";   
-    $options["download"] = "ods";
-    print_single_button("report.php", $options, get_string("downloadods"));
-    echo "</td><td>";
-    $options["download"] = "xls";
-    print_single_button("report.php", $options, get_string("downloadexcel"));
-    echo "</td><td>";
-    $options["download"] = "txt";    
-    print_single_button("report.php", $options, get_string("downloadtext"));
-
-    echo "</td></tr></table>";
+    if (has_capability('mod/choice:downloadresponses',$context)) {
+        echo "<br />\n";
+        echo "<table class=\"downloadreport\"><tr>\n";
+        echo "<td>";
+        $options = array();
+        $options["id"] = "$cm->id";   
+        $options["download"] = "ods";
+        print_single_button("report.php", $options, get_string("downloadods"));
+        echo "</td><td>";
+        $options["download"] = "xls";
+        print_single_button("report.php", $options, get_string("downloadexcel"));
+        echo "</td><td>";
+        $options["download"] = "txt";    
+        print_single_button("report.php", $options, get_string("downloadtext"));
+
+        echo "</td></tr></table>";
+    }
     print_footer($course);
 
 ?>