]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error call"
authordongsheng <dongsheng>
Wed, 21 May 2008 07:53:23 +0000 (07:53 +0000)
committerdongsheng <dongsheng>
Wed, 21 May 2008 07:53:23 +0000 (07:53 +0000)
question/category.php
question/contextmove.php
question/contextmoveq.php
question/editlib.php
question/export.php
question/format/blackboard_6/format.php
question/format/coursetestmanager/format.php
question/format/qti2/format.php
question/format/webct/format.php
question/question.php
question/tabs.php

index 366e37cbae6775581802da3384f66b3b4ee4e112..f2a0a0617d2c28b7d4eaf6b25d09a71e08adfc52 100644 (file)
@@ -48,7 +48,7 @@
     }
     if ($param->delete && ($questionstomove = count_records("question", "category", $param->delete))){
         if (!$category = get_record("question_categories", "id", $param->delete)) {  // security
-            print_error("No such category {$param->delete}!", '', $thispageurl->out());
+            print_error('nocate', 'question', $thispageurl->out(), $param->delete);
         }
         $categorycontext = get_context_instance_by_id($category->contextid);
         $qcobject->moveform = new question_move_form($thispageurl,
index 83e40122fd88d669ce1ba72c7df7f36533be1211..d4fede6b3f703d8928bc4350c4db613ca9d8432f 100644 (file)
@@ -26,7 +26,7 @@
     list($toparent, $contextto) = explode(',', $toparent);
     if (!empty($toparent)){//not top level category, make it a child of $toparent
         if (!$toparent = get_record('question_categories', 'id', $toparent)){
-            print_error('Invalid category id for parent!', '', $onerrorurl);
+            print_error('invalidcategoryidforparent', 'question', $onerrorurl);
         }
         $contextto = $toparent->contextid;
     } else {
         $toparent->contextid = $contextto;
     }
     if (!$cattomove = get_record('question_categories', 'id', $cattomove)){
-        print_error('Invalid category id to move!', '', $onerrorurl);
+        print_error('invalidcategoryidtomove', 'question', $onerrorurl);
     }
     if ($cattomove->contextid == $contextto){
-        print_error("You shouldn't have got here if you're not moving a category to another context.", '', $onerrorurl);
+        print_error('contexterror', '', $onerrorurl);
     }
     $cattomove->categorylist = question_categorylist($cattomove->id);
 
                     case QUESTION_FILEMOVELINKSONLY :
                         break;
                     default :
-                        print_error('Invalid action selected!', '', $onerrorurl);
+                        print_error('invalidaction', '', $onerrorurl);
                 }
                 switch ($urlaction){
                     //now search and replace urls in questions.
         $cat->parent = $toparent->id;
         //set context of category we are moving and all children also!
         if (!execute_sql("UPDATE {$CFG->prefix}question_categories SET contextid = {$contextto->id} WHERE id IN ({$cattomove->categorylist})", false)){
-            print_error("Could not move the category '$newname' to ".$contexttostring, '', $onerrorurl);
+            print_error('cannotmovefromto', 'question', $onerrorurl, array($newname, $contexttostring));
         }
         //finally set the new parent id
         if (!update_record("question_categories", $cat)) {
-            print_error("Could not update the category '$updatename'", '', $onerrorurl);
+            print_error('cannotupdatecate', 'question', $onerrorurl, $updatename);
         }
         $thispageurl->remove_params('cattomove', 'toparent', 'totop');
         redirect($CFG->wwwroot."/question/category.php?".$thispageurl->get_query_string(array('cat'=>"{$cattomove->id},{$contextto->id}")));
index 9973c6d66b9dad7c0d8596e92f5ebfd5df48a3b9..140f8590a523c1f9e31609c98e91257d0374d480 100644 (file)
@@ -42,7 +42,7 @@ if ($cmid){
     }
     $thispageurl->param('courseid', $COURSE->id);
 } else {
-    print_error('Need to pass courseid or cmid to this script.');
+    print_error('missingcourseorcmid', 'question');
 }
 $contexts = new question_edit_contexts($thiscontext);
 
@@ -70,7 +70,7 @@ foreach (array_keys($questions) as $id){
     $questions[$id]->context = get_context_instance_by_id($questions[$id]->contextid);
     $thisfilesid =  get_filesdir_from_context($questions[$id]->context);
     if ($fromcoursefilesid && $thisfilesid != $fromcoursefilesid){
-       print_error('You can\'t use this script to move questions that have files associated with them from different areas.');
+       print_error('cannotmovequestion', 'question');
     } else {
        $fromcoursefilesid =  $thisfilesid;
     }
@@ -136,7 +136,7 @@ if ($contextmoveform->is_cancelled()){
                 case QUESTION_FILEDONOTHING :
                     break;
                 default :
-                    print_error('Invalid action selected!', '', $returnurl);
+                    print_error('invalidaction', '', $returnurl);
             }
             //now search and replace urls in questions.
             switch ($urlaction){
@@ -152,7 +152,7 @@ if ($contextmoveform->is_cancelled()){
                 case  QUESTION_FILEDONOTHING :
                     break;
                 default :
-                    print_error('Invalid action selected!', '', $returnurl);
+                    print_error('invalidaction', '', $returnurl);
                     break;
             }
 
index b80d7f892d178bde48e1df39091a16ce692e5181..33d95fcc56a8a7cf70765ccab7eb7a317d5e263d 100644 (file)
@@ -880,12 +880,12 @@ function require_login_in_context($contextorid = null){
     } else if ($context && ($context->contextlevel == CONTEXT_MODULE)) {
         if ($cm = get_record('course_modules','id',$context->instanceid)) {
             if (!$course = get_record('course', 'id', $cm->course)) {
-                print_error('Incorrect course.');
+                print_error('invalidcourseid');
             }
             require_course_login($course, true, $cm);
 
         } else {
-            print_error('Incorrect course module id.');
+            print_error('invalidcoursemodule');
         }
     } else if ($context && ($context->contextlevel == CONTEXT_SYSTEM)) {
         if (!empty($CFG->forcelogin)) {
index c428fa41a13618519eb3c505cab315e9b816e1bc..d96ff93f7ad55fa6dad8bfe330b12fd2185c955c 100644 (file)
@@ -81,7 +81,7 @@
 
 
         if (! is_readable("format/$from_form->format/format.php")) {
-            print_error("Format not known ($from_form->format)");
+            print_error('unknowformat', '', '', $from_form->format);
         }
 
         // load parent class for import/export
index a326da0aad2704a1cd80d4aa3c1387b24a6b4cf5..96c6146dff012b839be57d3904a6d8553971dca4 100644 (file)
@@ -159,7 +159,7 @@ class qformat_blackboard_6 extends qformat_default {
         if ($this->check_and_create_import_dir($unique_code)) {
             if(is_readable($filename)) {
                 if (!copy($filename, "$temp_dir/bboard.zip")) {
-                    print_error("Could not copy backup file");
+                    print_error('cannotcopybackup', 'question');
                 }
                 if(unzip_file("$temp_dir/bboard.zip", '', false)) {
                     // assuming that the information is in res0001.dat
@@ -178,20 +178,20 @@ class qformat_blackboard_6 extends qformat_default {
                         }
                     }
                     else {
-                        print_error("Could not find question data file in zip");   
+                        print_error('cannotfindquestionfile', 'questioni');   
                     }
                 }
                 else {
                     print "filename: $filename<br />tempdir: $temp_dir <br />";
-                    print_error("Could not unzip file.");   
+                    print_error('cannotunzip', 'question');   
                 }
             }
             else {
-                error ("Could not read uploaded file");   
+                print_error('cannotreaduploadfile');   
             }
         }
         else {
-            print_error("Could not create temporary directory");   
+            print_error('cannotcreatetempdir');   
         }
     }
         
index c75578f30ccf8673d90cbcf634ebfe345b7df669..14a0923b5d47ab17c5103e53196e6b2eff15eb68 100755 (executable)
@@ -43,7 +43,7 @@ class qformat_coursetestmanager extends qformat_default {
         if ((PHP_OS == "Linux") and !isset($hostname)) {
             // copy the file to a semi-permanent location
             if (! $basedir = make_upload_directory("$COURSE->id")) {
-                print_error("The site administrator needs to fix the file permissions for the data directory");
+                print_error('cannotcreateuploaddir');
             }
             if (!isset($hostname_access_error)) {
                 $bname=basename($filename);
@@ -101,7 +101,7 @@ class qformat_coursetestmanager extends qformat_default {
             if (PHP_OS == "WINNT") {
             // copy the file to a semi-permanent location
                 if (! $basedir = make_upload_directory("$COURSE->id")) {
-                    print_error("The site administrator needs to fix the file permissions for the data directory");
+                    print_error('cannotcreateuploaddir');
                 }
                 $bname=basename($filename);
                 $cleanfilename = clean_filename($bname);
@@ -124,7 +124,7 @@ class qformat_coursetestmanager extends qformat_default {
             }
             // print the intermediary form
             if (!$categories = question_category_options($COURSE->id, true)) {
-                print_error("No categories!");
+                print_error('nocate', 'debug');
             }
             print_heading_with_help($strimportquestions, "import", "quiz");
             print_simple_box_start("center");
@@ -264,7 +264,7 @@ class qformat_coursetestmanager extends qformat_default {
             $question->createdby = $USER->id;
             $question->timecreated = time();
             if (!$question->id = insert_record("question", $question)) {
-                print_error("Could not insert new question!");
+                print_error('cannotinsertquestion', 'question');
             }
             $this->questionids[] = $question->id;
             // Now to save all the answers and type-specific options
index 03765607380bbf9b5bd134ef836d2e3b94a9e61f..cfca4103304c0a0f4f7401e8ab5f7873b7fc4351 100644 (file)
@@ -110,7 +110,7 @@ class qformat_qti2 extends qformat_default {
     function importpreprocess() {
         global $CFG;
 
-        print_error("Sorry, importing this format is not yet implemented!", '', 
+        print_error('cannotimportformat', '', 
             "$CFG->wwwroot/mod/quiz/import.php?category=$category->id");
     }
 
@@ -274,13 +274,13 @@ function handle_questions_media(&$questions, $path, $courseid) {
         $expout = $smarty->fetch('imsmanifest.tpl');
         $filepath = $path.'/imsmanifest.xml';
         if (empty($expout)) {
-            print_error("Unkown error - empty imsmanifest.xml");
+            print_error('emptyxml', 'question');
         }
         if (!$fh=fopen($filepath,"w")) {
-            print_error("Cannot open for writing: $filepath");
+            print_error('cannotopenforwrit', '', '', $filepath);
         }
         if (!fwrite($fh, $expout)) {
-            print_error("Cannot write exported questions to $filepath");
+            print_error('cannotwriteto', 'question', '', $filepath);
         }
         fclose($fh);
 
@@ -295,10 +295,10 @@ function handle_questions_media(&$questions, $path, $courseid) {
             
             $filepath = $path.'/'.$this->get_assesment_item_id($question) . ".xml";
             if (!$fh=fopen($filepath,"w")) {
-                print_error("Cannot open for writing: $filepath");
+                print_error('cannotopenforwrit', '', '', $filepath);
             }
             if (!fwrite($fh, $expout)) {
-                print_error("Cannot write exported questions to $filepath");
+                print_error('cannotwriteto', 'question', '', $filepath);
             }
             fclose($fh);
             
@@ -332,13 +332,13 @@ function handle_questions_media(&$questions, $path, $courseid) {
         $this->xml_entitize($result);
         $this->xml_entitize($submiturl);
         if (! $this->exportpreprocess(0, $course)) {   // Do anything before that we need to
-            print_error("Error occurred during pre-processing!", '', $redirect);
+            print_error('errorduringpre', 'question', $redirect);
         }
         if (! $this->exportprocess_quiz($quiz, $questions, $result, $submiturl, $course)) {         // Process the export data
-            print_error("Error occurred during processing!", '', $redirect);
+            print_error('errorduringproc', 'question', $redirect);
         }
         if (! $this->exportpostprocess()) {                    // In case anything needs to be done after
-            print_error("Error occurred during post-processing!", '', $redirect);
+            print_error('errorduringpost', 'question', $redirect);
         }
 
     }
@@ -675,7 +675,7 @@ function xml_entitize(&$collection) {
         $path = $CFG->dataroot."/smarty_c";
         if (!is_dir($path)) {
             if (!mkdir($path, $CFG->directorypermissions)) {
-              print_error("Cannot create path: $path");
+              print_error('nopermissiontomkdir');
             }
         }
         $smarty = new Smarty;
index 85cf161c963a422444b4e6cea2c5f8872515e594..8c82cce178fa8a23096982cfaad04d0023003c2c 100644 (file)
@@ -106,21 +106,21 @@ function qformat_webct_convert_formula($formula) {
             for ($i = 1 ; $deep ; ++$i) {
                 if (!ereg('^(.*[^[:alnum:]_])?([[:alnum:]_]*([)(])([^)(]*[)(]){'.$i.'})$',
                         $splits[0], $regs)) {
-                    print_error("Parenthesis before ** is not properly started in $splits[0]**");
+                    print_error("parenthesisinproperstart", 'question', '', $splits[0]);
                 }
                 if ('(' == $regs[3]) {
                     --$deep;
                 } else if (')' == $regs[3]) {
                     ++$deep;
                 } else {
-                    print_error("Impossible character $regs[3] detected as parenthesis character");
+                    print_error('impossiblechar', 'question', '', $regs[3]);
                 }
             }
             $base = $regs[2];
             $splits[0] = $regs[1];
 
         } else {
-            print_error("Bad base before **: $splits[0]**");
+            print_error('badbase', 'question', '', $splits[0]);
         }
 
         // Find $exp (similar to above but a little easier)
@@ -136,14 +136,14 @@ function qformat_webct_convert_formula($formula) {
             for ($i = 1 ; $deep ; ++$i) {
                 if (!ereg('^([+-]?[[:alnum:]_]*([)(][^)(]*){'.$i.'}([)(]))(.*)',
                         $splits[1], $regs)) {
-                    print_error("Parenthesis after ** is not properly closed in **$splits[1]");
+                    print_error("parenthesisinproperclose", 'question', '', $splits[1]);
                 }
                 if (')' == $regs[3]) {
                     --$deep;
                 } else if ('(' == $regs[3]) {
                     ++$deep;
                 } else {
-                    print_error("Impossible character $regs[3] detected as parenthesis character");
+                    print_error("impossiblechar", 'question');
                 }
             }
             $exp = $regs[1];
index 39fbb7c25dde0a66246f3f6f430db0d70badf946..b66ba7d72a93426c2be4c8b7ee76395e90319590 100644 (file)
@@ -41,7 +41,7 @@ if ($cmid){
     $module = null;
     $cm = null;
 } else {
-    print_error('Need to pass courseid or cmid to this script.');
+    print_error('missingcourseorcmid', 'question');
 }
 $contexts = new question_edit_contexts($thiscontext);
 
index 1cd757d29f17dfe32e2b1c4086cdc1159860709e..3e01c27dcaf141811cbf4d5eed255e73f5aa6db1 100644 (file)
@@ -12,7 +12,7 @@
         $currenttab = '';
     }
     if (!isset($COURSE)) {
-        print_error('No course specified');
+        print_error('invalidcourse');
     }
 
     $tabs = array();