From b3c4db7c1a8691d8b2f6b5a5e27db35a3d14ddab Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sun, 15 Jun 2008 08:34:35 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- mod/lesson/importppt.php | 24 ++++++++++++------------ mod/lesson/index.php | 2 +- mod/lesson/mediafile.php | 10 +++++----- mod/lesson/pagelib.php | 4 ++-- mod/lesson/restorelib.php | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/mod/lesson/importppt.php b/mod/lesson/importppt.php index 668cf33196..b2931044cd 100644 --- a/mod/lesson/importppt.php +++ b/mod/lesson/importppt.php @@ -21,20 +21,20 @@ 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); @@ -68,10 +68,10 @@ $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 "
"; @@ -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; diff --git a/mod/lesson/index.php b/mod/lesson/index.php index 96915e7b72..f0c02f37da 100644 --- a/mod/lesson/index.php +++ b/mod/lesson/index.php @@ -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); diff --git a/mod/lesson/mediafile.php b/mod/lesson/mediafile.php index 356a140b8a..26fd50ca00 100644 --- a/mod/lesson/mediafile.php +++ b/mod/lesson/mediafile.php @@ -19,15 +19,15 @@ $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); @@ -142,7 +142,7 @@ //} 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 @@ -213,4 +213,4 @@ } print_footer(); -?> \ No newline at end of file +?> diff --git a/mod/lesson/pagelib.php b/mod/lesson/pagelib.php index c1291bd111..c309433f43 100644 --- a/mod/lesson/pagelib.php +++ b/mod/lesson/pagelib.php @@ -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 +?> diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index 99fe4b9c61..c71e3902e3 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -182,7 +182,7 @@ //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; @@ -252,7 +252,7 @@ $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'); } } } -- 2.39.5