]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed up some more links.
authorthepurpleblob <thepurpleblob>
Thu, 9 Mar 2006 16:17:45 +0000 (16:17 +0000)
committerthepurpleblob <thepurpleblob>
Thu, 9 Mar 2006 16:17:45 +0000 (16:17 +0000)
Fixed up a bunch of hardcoded text.
Added test for exporting category with no questions.

question/export.php
question/format.php
question/import.php

index cf1509286523172c3a9a0e79cc5ea9c842980565..b75b56090b09e4757bc761ffc08ce30ba07db2e7 100644 (file)
     }
 
     if (! $categorycourse = get_record("course", "id", $category->course)) {
-        error("This category doesn't belong to a valid course!");
+        error( get_string('nocategory','quiz') );
     }
 
     require_login($course->id, false);
 
     if (!isteacher($course->id)) {
-        error("Only the teacher can export quiz questions!");
+        error( get_string('onlyteachersexport','quiz') );
     }
 
     // ensure the files area exists for this course
         $qformat = new $classname();
 
         if (! $qformat->exportpreprocess($category, $course)) {   // Do anything before that we need to
-            error("Error occurred during pre-processing!",
-                    "$CFG->wwwroot/question/export.php?category=$category->id");
+            error( get_string('exporterror','quiz'),
+                    "$CFG->wwwroot/question/export.php?courseid={$course->id}&amp;category=$category->id");
         }
 
         if (! $qformat->exportprocess($exportfilename)) {         // Process the export data
-            error("Error occurred during processing!",
-                    "$CFG->wwwroot/question/export.php?category=$category->id");
+            error( get_string('exporterror','quiz'),
+                    "$CFG->wwwroot/question/export.php?courseid={$course->id}&amp;category=$category->id");
         }
 
         if (! $qformat->exportpostprocess()) {                    // In case anything needs to be done after
-            error("Error occurred during post-processing!",
-                    "$CFG->wwwroot/question/export.php?category=$category->id");
+            error( get_string('exporterror','quiz'),
+                    "$CFG->wwwroot/question/export.php?courseid={$course->id}&amp;category=$category->id");
         }
         echo "<hr />";
 
index 5a8115579cf176b20544be36e27d5c8751a3b18b..c00d6f12c04798e63defd43c7818ad71b6ca3781 100644 (file)
@@ -41,16 +41,16 @@ class qformat_default {
     /// Processes a given file.  There's probably little need to change this
 
         if (! $lines = $this->readdata($filename)) {
-            notify("File could not be read, or was empty");
+            notify( get_string('cannotread','quiz') );
             return false;
         }
 
         if (! $questions = $this->readquestions($lines)) {   // Extract all the questions
-            notify("There are no questions in this file!");
+            notify( get_string('noquestionsinfile','quiz') );
             return false;
         }
 
-        notify("Importing ".count($questions)." questions");
+        notify( get_string('importingquestions','quiz',count($questions)) );
 
         $count = 0;
 
@@ -64,7 +64,7 @@ class qformat_default {
             $question->version = 1;                    // Original version of this question
 
             if (!$question->id = insert_record("question", $question)) {
-                error("Could not insert new question!");
+                error( get_string('cannotinsert','quiz') );
             }
 
             $this->questionids[] = $question->id;
@@ -158,7 +158,8 @@ class qformat_default {
     /// this format, this function converts it into a question 
     /// object suitable for processing and insertion into Moodle.
 
-        echo "<p>This quiz format has not yet been completed!</p>";
+        $formatnotimplemented = get_string( 'formatnotimplemented','quiz' );
+        echo "<p>$formatnotimplemented</p>";
 
         return NULL;
     }
@@ -210,7 +211,7 @@ class qformat_default {
         $path = $CFG->dataroot.'/'.$courseid.'/'.$dirname;
         if (!is_dir($path)) {
             if (!mkdir($path, $CFG->directorypermissions)) {
-              error("Cannot create path: $path");
+              error( get_string('cannotcreatepath','quiz',$path) );
             }
         }
 
@@ -218,9 +219,10 @@ class qformat_default {
         // only get q's with no parents (no cloze subquestions specifically)
         $questions = get_questions_category( $this->category, true );
 
-        notify("Exporting questions.");
+        notify( get_string('exportingquestions','quiz') );
         if (!count($questions)) {
-            return true;
+            notify( get_string('noquestions','quiz') );
+            return false;
         }
         $count = 0;
 
@@ -245,10 +247,10 @@ class qformat_default {
         // write file
         $filepath = $path."/".$filename . $this->export_file_extension();
         if (!$fh=fopen($filepath,"w")) {
-            error("Cannot open for writing: $filepath");
+            error( get_string('cannotopen','quiz',$filepath) );
         }
         if (!fwrite($fh, $expout)) {
-            error("Cannot write exported questions to $filepath");
+            error( get_string('cannotwrite','quiz',$filepath) );
         }
         fclose($fh);
 
@@ -265,7 +267,9 @@ class qformat_default {
     /// Turns a question object into textual output in the given format 
     /// must be overidden
 
-        echo "<p>This quiz format has not yet been completed!</p>";
+        // if not overidden, then this is an error.
+        $formatnotimplemented = get_string( 'formatnotimplemented','quiz' );
+        echo "<p>$formatnotimplemented</p>";
 
         return NULL;
     }
index f00335c7ab3b9202134f27ed62c896fa882df7bd..57a699887439f7647c0234e4f3d4c8abe326facf 100644 (file)
@@ -28,7 +28,7 @@
         if ($courseid) {
             $category = get_default_question_category($courseid);
         } else {
-            error("No category specified");
+            error( get_string('nocategory','quiz') );
         }
     }
 
@@ -43,7 +43,7 @@
     require_login($course->id, false);
 
     if (!isteacheredit($course->id)) {
-        error("Only editing teachers can import quiz questions!");
+        error( get_string('onlyteachersimport','quiz') );
     }
 
     // ensure the files area exists for this course
@@ -94,7 +94,7 @@
         } else {  // Valid file is found
 
             if (! is_readable("format/$format/format.php")) {
-                error("Format not known ($format)");
+                error( get_string('formatnotfound','quiz', $format) );
             }
 
             require("format.php");  // Parent class
             $qformat = new $classname();
 
             if (! $qformat->importpreprocess($category,$course)) {             // Do anything before that we need to
-                error("Error occurred during pre-processing!",
-                      "$CFG->wwwroot/question/import.php?category=$category->id");
+                error( get_string('importerror','quiz'),
+                      "$CFG->wwwroot/question/import.php?courseid={$course->id}&amp;category=$category->id");
             }
 
             if (! $qformat->importprocess($_FILES['newfile']['tmp_name'])) {     // Process the uploaded file
-                error("Error occurred during processing!",
-                      "$CFG->wwwroot/question/import.php?category=$category->id");
+                error( get_string('importerror','quiz'),
+                      "$CFG->wwwroot/question/import.php?courseid={$course->id}&amp;category=$category->id");
             }
 
             if (! $qformat->importpostprocess()) {                     // In case anything needs to be done after
-                error("Error occurred during post-processing!",
-                      "$CFG->wwwroot/question/import.php?category=$category->id");
+                error( get_string('importerror','quiz'),
+                      "$CFG->wwwroot/question/import.php?courseid={$course->id}&amp;category=$category->id");
             }
 
             echo "<hr />";