]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Sun, 15 Jun 2008 08:34:35 +0000 (08:34 +0000)
committerdongsheng <dongsheng>
Sun, 15 Jun 2008 08:34:35 +0000 (08:34 +0000)
mod/lesson/importppt.php
mod/lesson/index.php
mod/lesson/mediafile.php
mod/lesson/pagelib.php
mod/lesson/restorelib.php

index 668cf331968d5426917f2c7507812f057a47e3b9..b2931044cdf3d449b53d5e5d6a1c0dba18ceee6e 100644 (file)
     global $matches;
     
     if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        print_error("Course Module ID was incorrect");
+        print_error('invalidcoursemodule');
     }
 
     if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
-        print_error("Course is misconfigured");
+        print_error('coursemisconf');
     }
     
     // allows for adaption for multiple modules
     if(! $modname = $DB->get_field('modules', 'name', array('id' => $cm->module))) {
-        print_error("Could not find module name");
+        print_error('invalidmoduleid', '', '', $cm->module);
     }
 
     if (! $mod = $DB->get_record($modname, array("id" => $cm->instance))) {
-        print_error("Course module is incorrect");
+        print_error('invalidcoursemodule');
     }
 
     require_login($course->id, false, $cm);
                 $objects = $mod_create_objects($pageobjects, $mod->id);  // function to preps the data to be sent to DB
                 
                 if(! $mod_save_objects($objects, $mod->id, $pageid)) {  // sends it to DB
-                    print_error("could not save");
+                    print_error('cannotsavedata');
                 }
             } else {
-                print_error('could not get data');
+                print_error('cannotgetdata');
             }
 
             echo "<hr>";
@@ -324,7 +324,7 @@ function build_list($list, &$i, $depth) {
                 // set the depth number.  So B1 is depth 1 and B2 is depth 2 and so on
                 $this_depth = substr($class, 1);
                 if (!is_numeric($this_depth)) {
-                    print_error("Depth not parsed!");
+                    print_error('invalidnum');
                 }
             }
             if ($this_depth < $depth) {
@@ -547,13 +547,13 @@ function lesson_save_objects($branchtables, $lessonid, $after) {
         
         // insert the page
         if(!$id = $DB->insert_record('lesson_pages', $branchtable->page)) {
-            print_error("insert page");
+            print_error('cannotinsertpage', 'lesson');
         }
     
         // update the link of the page previous to the one we just updated
         if ($prevpageid != 0) {  // if not the first page
             if (!$DB->set_field("lesson_pages", "nextpageid", $id, array("id" => $prevpageid))) {
-                print_error("Insert page: unable to update next link $prevpageid");
+                print_error('cannotupdatepage', 'lesson');
             }
         }
 
@@ -561,7 +561,7 @@ function lesson_save_objects($branchtables, $lessonid, $after) {
         foreach ($branchtable->answers as $answer) {
             $answer->pageid = $id;
             if(!$DB->insert_record('lesson_answers', $answer)) {
-                print_error("insert answer $id");
+                print_error('cannotinsertanswer', 'lesson');
             }
         }
         
@@ -571,7 +571,7 @@ function lesson_save_objects($branchtables, $lessonid, $after) {
     // all done with inserts.  Now check to update our last page (this is when we import between two lesson pages)
     if ($nextpageid != 0) {  // if the next page is not the end of lesson
         if (!$DB->set_field("lesson_pages", "prevpageid", $id, array("id" => $nextpageid))) {
-            print_error("Insert page: unable to update next link $prevpageid");
+            print_error('cannotupdatepage', 'lesson');
         }
     }
     
@@ -587,7 +587,7 @@ function book_save_objects($chapters, $bookid, $pageid='0') {
     // nothing fancy, just save them all in order
     foreach ($chapters as $chapter) {
         if (!$chapter->id = $DB->insert_record('book_chapters', $chapter)) {
-            print_error('Could not update your book');
+            print_error('cannotupdatebook', 'lesson');
         }
     }
     return true;
index 96915e7b7279267a2f759283e6529214348a2901..f0c02f37da637fa49a73b9fe7968aea47b8dabe8 100644 (file)
@@ -14,7 +14,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (!$course = $DB->get_record("course", array("id" => $id))) {
-        print_error("Course ID is incorrect");
+        print_error('invalidcourseid');
     }
 
     require_login($course->id);
index 356a140b8abac8484a835d3ca3f3095ebc86a3f8..26fd50ca008adaf203223ec9fc8f0e2d56cc3553 100644 (file)
     $printclose = optional_param('printclose', 0, PARAM_INT);
     
     if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        print_error('Course Module ID was incorrect');
+        print_error('invalidcoursemodule');
     }
 
     if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
-        print_error('Course is misconfigured');
+        print_error('coursemisconf');
     }
 
     if (! $lesson = $DB->get_record('lesson', array('id' => $cm->instance))) {
-        print_error('Course module is incorrect');
+        print_error('invalidcoursemodule');
     }
 
     require_login($course->id, false, $cm);
     
     //} else if ($mimetype == "application/x-shockwave-flash") {   // It's a flash file
     
-    //    print_error('Flash is not supported yet');
+    //    print_error('noflash');
     
     } else if ($mimetype == "audio/x-pn-realaudio") {   // It's a realmedia file
         
     }
     
     print_footer();
-?>
\ No newline at end of file
+?>
index c1291bd111b30e96e6e72b85e98f3a5aa717f16f..c309433f43d45799d4d14ce0a203be8bf0da5086 100644 (file)
@@ -70,7 +70,7 @@ class page_lesson extends page_generic_activity {
         $activityname = format_string($this->activityrecord->name);
 
         if ($this->lessonpageid === NULL) {
-            print_error('Programmer error: must set the lesson page ID');
+            print_error('invalidpageid', 'lesson');
         }
         if (empty($title)) {
             $title = "{$this->courserecord->shortname}: $activityname";
@@ -180,4 +180,4 @@ class page_lesson extends page_generic_activity {
         $this->lessonpageid = $pageid;
     }
 }
-?>
\ No newline at end of file
+?>
index 99fe4b9c61ac7bae0deec08b9ebda3b9ae0f9028..c71e3902e31fe20950772feb7967e5bfc9b897a7 100644 (file)
             //Fix the forwards link of the previous page
             if ($prevpageid) {
                 if (!$DB->set_field("lesson_pages", "nextpageid", $newid, array("id"=>$prevpageid))) {
-                    print_error("Lesson restorelib: unable to update link");
+                    print_error('cannotupdatepage', 'lesson');
                 }
             }
             $prevpageid = $newid;
                     $page = backup_getid($restore->backup_unique_code,"lesson_pages",$answer->jumpto);
                     if ($page) {
                         if (!$DB->set_field("lesson_answers", "jumpto", $page->new_id, array("id"=>$answer->id))) {
-                            print_error("Lesson restorelib: unable to reset jump");
+                            print_error('cannotresetjump', 'lesson');
                         }
                     }
                 }