]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11279:
authorthepurpleblob <thepurpleblob>
Mon, 17 Sep 2007 10:57:49 +0000 (10:57 +0000)
committerthepurpleblob <thepurpleblob>
Mon, 17 Sep 2007 10:57:49 +0000 (10:57 +0000)
Code was not properly checking for empty category.
Check moved to right place and proper print_error() function called as appropriate

Merged from STABLE_18

question/format.php

index 76220530f64553d57650aeb0c8273a4ff62ea71a..5e664efac3b3ba0afc37c9fb367f5bf7b8a1d6c5 100644 (file)
@@ -642,16 +642,25 @@ class qformat_default {
             }
         }
 
+        // continue path for following error checks
+        $course = $this->course;
+        $continuepath = "$CFG->wwwroot/question/export.php?courseid=$course->id"; 
+
+        // did we actually process anything
+        if ($count==0) {
+            print_error( 'noquestions','quiz',$continuepath );        
+        }
+
         // final pre-process on exported data
         $expout = $this->presave_process( $expout );
 
         // write file
         $filepath = $path."/".$this->filename . $this->export_file_extension();
         if (!$fh=fopen($filepath,"w")) {
-            error( get_string('cannotopen','quiz',$filepath) );
+            print_error( 'cannotopen','quiz',$continuepath,$filepath );
         }
         if (!fwrite($fh, $expout, strlen($expout) )) {
-            error( get_string('cannotwrite','quiz',$filepath) );
+            print_error( 'cannotwrite','quiz',$continuepath,$filepath );
         }
         fclose($fh);
         return true;