]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Thu, 12 Jun 2008 11:52:15 +0000 (11:52 +0000)
committerdongsheng <dongsheng>
Thu, 12 Jun 2008 11:52:15 +0000 (11:52 +0000)
15 files changed:
mod/lesson/action/addbranchtable.php
mod/lesson/action/addcluster.php
mod/lesson/action/addendofbranch.php
mod/lesson/action/addendofcluster.php
mod/lesson/action/confirmdelete.php
mod/lesson/action/editpage.php
mod/lesson/action/insertpage.php
mod/lesson/action/move.php
mod/lesson/action/updatepage.php
mod/lesson/backuplib.php
mod/lesson/format.php
mod/lesson/highscores.php
mod/lesson/lesson.php
mod/lesson/report.php
mod/lesson/view.php

index e8f1148cb0a7d1731c325afed5b49f6c6a99406b..29e914b69788cfcd8539ecba58aee1e8e25cc9d3 100644 (file)
@@ -20,7 +20,7 @@
     $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
     if (!optional_param('firstpage', 0, PARAM_INT)) {
         if (!$apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) {
-            print_error("Add page: first page not found");
+            print_error('cannotfindfirstpage', 'lesson');
         }
         while (true) {
             if ($apageid) {
index e61fdf75300585a011433530130073b79e8d2469..e2ed47da33808124ae0c746ea9654754e80cf3a4 100644 (file)
     
     if ($pageid == 0) {
         if (!$page = $DB->get_record("lesson_pages", array("prevpageid" => 0, "lessonid" => $lesson->id))) {
-            print_error("Error: Add cluster: page record not found");
+            print_error('cannotfindpagerecord', 'lesson');
         }
     } else {
         if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
-            print_error("Error: Add cluster: page record not found");
+            print_error('cannotfindpagerecord', 'lesson');
         }
     }
     $newpage = new stdClass;
     $newpage->title = get_string("clustertitle", "lesson");
     $newpage->contents = get_string("clustertitle", "lesson");
     if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) {
-        print_error("Insert page: new page not inserted");
+        print_error('cannotinsertpage', 'lesson');
     }
     // update the linked list...
     if ($pageid != 0) {
         if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) {
-            print_error("Add cluster: unable to update link");
+            print_error('cannotupdatelink', 'lesson');
         }
     }
     
@@ -51,7 +51,7 @@
     if ($page->nextpageid) {
         // the new page is not the last page
         if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) {
-            print_error("Insert page: unable to update previous link");
+            print_error('cannotupdatelink', 'lesson');
         }
     }
     // ..and the single "answer"
@@ -61,8 +61,8 @@
     $newanswer->timecreated = $timenow;
     $newanswer->jumpto = LESSON_CLUSTERJUMP;
     if(!$newanswerid = $DB->insert_record("lesson_answers", $newanswer)) {
-        print_error("Add cluster: answer record not inserted");
+        print_error('cannotinsertanswer', 'lesson');
     }
     lesson_set_message(get_string('addedcluster', 'lesson'), 'notifysuccess');
     redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
-?>
\ No newline at end of file
+?>
index 3839b9befe9b7cc7d9ea54cf6e03f7287eee825f..1419094a6866d55e885e480cb163828221f9309d 100644 (file)
 
     // the new page is not the first page (end of branch always comes after an existing page)
     if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
-        print_error("Add end of branch: page record not found");
+        print_error('cannotfindpagerecord', 'lesson');
     }
     // chain back up to find the (nearest branch table)
     $btpageid = $pageid;
     if (!$btpage = $DB->get_record("lesson_pages", array("id" => $btpageid))) {
-        print_error("Add end of branch: btpage record not found");
+        print_error('cannotfindpagerecord', 'lesson');
     }
     while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) {
         $btpageid = $btpage->prevpageid;
         if (!$btpage = $DB->get_record("lesson_pages", array("id" => $btpageid))) {
-            print_error("Add end of branch: btpage record not found");
+            print_error('cannotfindpagerecord', 'lesson');
         }
     }
     if ($btpage->qtype == LESSON_BRANCHTABLE) {
         $newpage->title = get_string("endofbranch", "lesson");
         $newpage->contents = get_string("endofbranch", "lesson");
         if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) {
-            print_error("Insert page: new page not inserted");
+            print_error('cannotinsertpage', 'lesson');
         }
         // update the linked list...
         if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) {
-            print_error("Add end of branch: unable to update link");
+            print_error('cannotupdatelink', 'lesson');
         }
         if ($page->nextpageid) {
             // the new page is not the last page
             if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) {
-                print_error("Insert page: unable to update previous link");
+                print_error('cannotupdatelink', 'lesson');
             }
         }
         // ..and the single "answer"
@@ -57,7 +57,7 @@
         $newanswer->timecreated = $timenow;
         $newanswer->jumpto = $btpageid;
         if(!$newanswerid = $DB->insert_record("lesson_answers", $newanswer)) {
-            print_error("Add end of branch: answer record not inserted");
+            print_error('cannotinsertanswer', 'lesson');
         }
         
         lesson_set_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess');
index 9656fe92d920969230420b4934ae79b34ccddb66..be6a346a8f843aa8c587329673aa010f96650d85 100644 (file)
@@ -15,7 +15,7 @@
     
     // the new page is not the first page (end of cluster always comes after an existing page)
     if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
-        print_error("Error: Could not find page");
+        print_error('cannotfindpages', 'lesson');
     }
     
     // could put code in here to check if the user really can insert an end of cluster
     $newpage->title = get_string("endofclustertitle", "lesson");
     $newpage->contents = get_string("endofclustertitle", "lesson");
     if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) {
-        print_error("Insert page: end of cluster page not inserted");
+        print_error('cannotinsertpage', 'lesson');
     }
     // update the linked list...
     if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) {
-        print_error("Add end of cluster: unable to update link");
+        print_error('cannotupdatelink', 'lesson');
     }
     if ($page->nextpageid) {
         // the new page is not the last page
         if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) {
-            print_error("Insert end of cluster: unable to update previous link");
+            print_error('cannotupdatelink', 'lesson');
         }
     }
     // ..and the single "answer"
@@ -48,7 +48,7 @@
     $newanswer->timecreated = $timenow;
     $newanswer->jumpto = LESSON_NEXTPAGE;
     if(!$newanswerid = $DB->insert_record("lesson_answers", $newanswer)) {
-        print_error("Add end of cluster: answer record not inserted");
+        print_error('cannotinsertanswer', 'lesson');
     }
     lesson_set_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess');
-    redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
\ No newline at end of file
+    redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
index 70a4b11ca62fd610583d9bbccc36d53f46a52805..6b1b10d6ba4d654d095bb5d6944f2e6479829fd6 100644 (file)
@@ -10,7 +10,7 @@
 
     $pageid = required_param('pageid', PARAM_INT);
     if (!$thispage = $DB->get_record("lesson_pages", array ("id" => $pageid))) {
-        print_error("Confirm delete: the page record not found");
+        print_error('cannotfindpages', 'lesson');
     }
     print_heading(get_string("deletingpage", "lesson", format_string($thispage->title)));
     // print the jumps to this page
@@ -20,7 +20,7 @@
         echo "<p align=\"center\">\n";
         foreach ($answers as $answer) {
             if (!$title = $DB->get_field("lesson_pages", "title", array("id" => $answer->pageid))) {
-                print_error("Confirm delete: page title not found");
+                print_error('cannotfindpagetitle', 'lesson');
             }
             echo $title."<br />\n";
         }
index c431a82aad617e8c4b0492a71db756aab4f79498..432bd6af697b6f5ea3cb7e6918a221be98b935d4 100644 (file)
@@ -12,7 +12,7 @@
     $redirect = optional_param('redirect', '', PARAM_ALPHA);
     
     if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
-        print_error("Edit page: page record not found");
+        print_error('cannotfindpages', 'lesson');
     }
 
     $page->qtype = optional_param('qtype', $page->qtype, PARAM_INT);
     }
     $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
     if (!$apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) {
-        print_error("Edit page: first page not found");
+        print_error('cannotfindfirstpage', 'lesson');
     }
     while (true) {
         if ($apageid) {
             if (!$apage = $DB->get_record("lesson_pages", array("id" => $apageid))) {
-                print_error("Edit page: apage record not found");
+                print_error('cannotfindpages', 'lesson');
             }
             // removed != LESSON_ENDOFBRANCH...
             if (trim($page->title)) { // ...nor nuffin pages
index 819e46704cf4e2691136f7b8ddcf3587c5fc5248..63a6d3b4fd3a289d7a9b94b070edb290b80a59a3 100644 (file)
@@ -21,7 +21,7 @@
     if ($form->pageid) {
         // the new page is not the first page
         if (!$page = $DB->get_record("lesson_pages", array("id" => $form->pageid))) {
-            print_error("Insert page: page record not found");
+            print_error('cannotfindpages', 'lesson');
         }
         $newpage->lessonid = clean_param($lesson->id, PARAM_INT);
         $newpage->prevpageid = clean_param($form->pageid, PARAM_INT);
         $newpage->title = $newpage->title;
         $newpageid = $DB->insert_record("lesson_pages", $newpage);
         if (!$newpageid) {
-            print_error("Insert page: new page not inserted");
+            print_error('cannotinsertpage', 'lesson');
         }
         // update the linked list (point the previous page to this new one)
         if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $newpage->prevpageid))) {
-            print_error("Insert page: unable to update next link");
+            print_error('cannotupdatelink', 'lesson');
         }
         if ($page->nextpageid) {
             // new page is not the last page
             if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) {
-                print_error("Insert page: unable to update previous link");
+                print_error('cannotupdatelink', 'lesson');
             }
         }
     } else {
@@ -91,7 +91,7 @@
             $newpage->title = $newpage->title;
             $newpageid = $DB->insert_record("lesson_pages", $newpage);
             if (!$newpageid) {
-                print_error("Insert page: new first page not inserted");
+                print_error('cannotinsertpage', 'lesson');
             }
         } else {
             // there are existing pages put this at the start
             $newpage->title = $newpage->title;
             $newpageid = $DB->insert_record("lesson_pages", $newpage);
             if (!$newpageid) {
-                print_error("Insert page: first page not inserted");
+                print_error('cannotfindfirstpage', 'lesson');
             }
             // update the linked list
             if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $newpage->nextpageid))) {
-                print_error("Insert page: unable to update link");
+                print_error('cannotupdatelink', 'lesson');
             }
         }
     }
         }
         $newanswerid = $DB->insert_record("lesson_answers", $newanswer);
         if (!$newanswerid) {
-            print_error("Insert Page: answer record not inserted");
+            print_error('cannotinsertanswer', 'lesson');
         }
     } else {
         if ($form->qtype == LESSON_MATCHING) {
                 }
                 $newanswerid = $DB->insert_record("lesson_answers", $newanswer);
                 if (!$newanswerid) {
-                    print_error("Insert Page: answer record $i not inserted");
+                    print_error('cannotinsertanswer', 'lesson');
                 }
             } else {
                 if ($form->qtype == LESSON_MATCHING) {
                         $newanswer->timecreated = $timenow;
                         $newanswerid = $DB->insert_record("lesson_answers", $newanswer);
                         if (!$newanswerid) {
-                            print_error("Insert Page: answer record $i not inserted");
+                            print_error('cannotinsertanswer', 'lesson');
                         }
                     }
                 } else {
index 518f81c5feea405a2f192aab5b02ad9b61237fb4..217528f0c5377a832c14859ba0982640352ae1f9 100644 (file)
@@ -13,7 +13,7 @@
    
     $params = array ("lessonid" => $lesson->id, "prevpageid" => 0);
     if (!$page = $DB->get_record_select("lesson_pages", "lessonid = :lessonid AND prevpageid = :prevpageid", $params)) {
-        print_error("Move: first page not found");
+        print_error('cannotfindfirstpage', 'lesson');
     }
 
     echo "<center><table cellpadding=\"5\" border=\"1\">\n";
@@ -30,7 +30,7 @@
         }
         if ($page->nextpageid) {
             if (!$page = $DB->get_record("lesson_pages", array("id" => $page->nextpageid))) {
-                print_error("Teacher view: Next page not found!");
+                print_error('cannotfindnextpage', 'lesson');
             }
         } else {
             // last page reached
index d7d26dccc945a8f95889c28fc5eeff986d07978e..576c740bede100ca08613d2962c8d49f5033ac04 100644 (file)
@@ -48,7 +48,7 @@
     $page->title = $page->title;
     
     if (!$DB->update_record("lesson_pages", $page)) {
-        print_error("Update page: page not updated");
+        print_error('cannotupdatepage', 'lesson');
     }
     if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_ESSAY || $page->qtype == LESSON_CLUSTER || $page->qtype == LESSON_ENDOFCLUSTER) {
         // there's just a single answer with a jump
             foreach ($answers as $answer) {
                 if ($answer->id != clean_param($form->answerid[0], PARAM_INT)) {
                     if (!$DB->delete_records("lesson_answers", array("id" => $answer->id))) {
-                        print_error("Update page: unable to delete answer record");
+                        print_error('cannotdeleteanswer', 'lesson');
                     }
                 }
             }
         }        
         if (!$DB->update_record("lesson_answers", $oldanswer)) {
-            print_error("Update page: EOB not updated");
+            print_error('cannotupdateanswer', 'lesson');
         }
     } else {
         // it's an "ordinary" page
                         $oldanswer->score = clean_param($form->score[$i], PARAM_INT);
                     }
                     if (!$DB->update_record("lesson_answers", $oldanswer)) {
-                        print_error("Update page: answer $i not updated");
+                        print_error('cannotupdateanswer', 'lesson');
                     }
                 } else {
                     // it's a new answer
                     }
                     $newanswerid = $DB->insert_record("lesson_answers", $newanswer);
                     if (!$newanswerid) {
-                        print_error("Update page: answer record not inserted");
+                        print_error('cannotinsertanswer', 'lesson');
                     }
                 }
             } else {
                         if ($form->answerid[$i]) {
                             // need to delete blanked out answer
                             if (!$DB->delete_records("lesson_answers", array("id" => clean_param($form->answerid[$i], PARAM_INT)))) {
-                                print_error("Update page: unable to delete answer record");
+                                print_error('cannotdeleteanswer', 'lesson');
                             }
                         }
                     } else {
                         $oldanswer->timemodified = $timenow;
                         $oldanswer->answer = NULL;
                         if (!$DB->update_record("lesson_answers", $oldanswer)) {
-                            print_error("Update page: answer $i not updated");
+                            print_error('cannotupdateanswer', 'lesson');
                         }
                     }                        
                 } elseif (!empty($form->answerid[$i])) {
                     // need to delete blanked out answer
                     if (!$DB->delete_records("lesson_answers", array("id" => clean_param($form->answerid[$i], PARAM_INT)))) {
-                        print_error("Update page: unable to delete answer record");
+                        print_error('cannotdeleteanswer', 'lesson');
                     }
                 }
             }
index ee73d3e82ba149e5bc40c5e6376976cbc2c4c503..4f4a2e8be0e4edbe20df5012b04a4e4c3905591d 100644 (file)
                 // move to the next (logical) page
                 if ($page->nextpageid) {
                     if (!$page = $DB->get_record("lesson_pages", array ("id" => $page->nextpageid))) {
-                        print_error("Lesson Backup: Next page not found!");
+                        print_error('cannotfindnextpage', 'lesson');
                     }
                 } else {
                     // last page reached
index 7891a8eff0872e77eec3992a8dba02e0423d9a8c..eb3573236f3fb6ba54ef06cb1cc6ec3b2244d707 100644 (file)
@@ -94,11 +94,11 @@ class qformat_default {
                         $newpage->nextpageid = $page->nextpageid;
                         // insert the page and reset $pageid
                         if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) {
-                            print_error("Format: Could not insert new page!");
+                            print_error('cannotinsertpage', 'lesson');
                         }
                         // update the linked list
                         if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) {
-                            print_error("Format: unable to update link");
+                            print_error('cannotupdateanswer', 'lesson');
                         }
 
                     } else {
@@ -111,7 +111,7 @@ class qformat_default {
                             $newpage->nextpageid = 0; // this is the only page
                             $newpageid = $DB->insert_record("lesson_pages", $newpage);
                             if (!$newpageid) {
-                                print_error("Insert page: new first page not inserted");
+                                print_error('cannotinsertpage', 'lesson');
                             }
                         } else {
                             // there are existing pages put this at the start
@@ -119,11 +119,11 @@ class qformat_default {
                             $newpage->nextpageid = $page->id;
                             $newpageid = $DB->insert_record("lesson_pages", $newpage);
                             if (!$newpageid) {
-                                print_error("Insert page: first page not inserted");
+                                print_error('cannotinsertpage', 'lesson');
                             }
                             // update the linked list
                             if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->id))) {
-                                print_error("Insert page: unable to update link");
+                                print_error('cannotupdatelink', 'lesson');
                             }
                         }
                     }
index 9ef4e8bc46b272a0c70f0e8da2c1630540660bac..25ff04d32534a440a5a32485bca545dd452751e3 100644 (file)
@@ -26,7 +26,7 @@
         case 'add':
             // Ensure that we came from view.php
             if (!confirm_sesskey() or !data_submitted()) {
-                print_error('Incorrect Form Data');
+                print_error('invalidformdata');
             }
             break;
             
@@ -55,7 +55,7 @@
                 }
                 $params = array ("lessonid" => $lesson->id, "userid" => $USER->id);
                 if (!$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid", $params, 'completed')) {
-                    print_error('Error: could not find grades');
+                    print_error('cannotfindfirstgrade', 'lesson');
                 }
                 
                 if (!$newgrade = $DB->get_record_sql("SELECT * 
                                                   WHERE lessonid = :lessonid
                                                     AND userid = :userid 
                                                ORDER BY completed DESC", $params, true)) {
-                    print_error('Error: could not find newest grade');
+                    print_error('cannotfindnewestgrade', 'lesson');
                 }
                 
                 // Check for multiple submissions
                 if ($DB->record_exists('lesson_high_scores', array('gradeid' => $newgrade->id))) {
-                    print_error('Only one posting per grade');
+                    print_error('onpostperpage', 'lesson');
                 }
                 
                 // Find out if we need to delete any records
                 $newhighscore->nickname = $name;
 
                 if (!$DB->insert_record('lesson_high_scores', $newhighscore)) {
-                    print_error("Insert of new high score Failed!");
+                    print_error('cannotinserthighscore', 'lesson');
                 }
                 
                 // Log it
                 lesson_set_message(get_string('postsuccess', 'lesson'), 'notifysuccess');
                 redirect("$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id&amp;link=1");
             } else {
-                print_error('Something is wrong with the form data');
+                print_error('invalidformdata');
             }
             break;
     }
     
     print_footer($course);
 
-?>
\ No newline at end of file
+?>
index f4c0e194423d539cbfbd1592dd96179f36bf73b6..9f3f338f3aaa33efab894cda26d16922ad59e6c9 100644 (file)
@@ -55,7 +55,7 @@
             include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php');
             break;
         default:
-            print_error("Fatal Error: Unknown action\n");
+            print_error('unknowaction');
     }
 
     print_footer($course);
index 43e1fcff21034249f38b718b1e0a38288632300f..f7eae99f59bfed91def7a8ad90308f8b04398e5b 100644 (file)
         $try    = optional_param('try', NULL, PARAM_INT);
 
         if (! $lessonpages = $DB->get_records("lesson_pages", array("lessonid" => $lesson->id))) {
-            print_error("Could not find Lesson Pages");
+            print_error('cannotfindpages', 'lesson');
         }
         if (! $pageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) {
-            print_error("Could not find first page");
+            print_error('cannotfindfirstpage', 'lesson');
         }
 
         // now gather the stats into an object
     }
 
     else {
-        print_error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error('unknowaction');
     }
 
 /// Finish the page
index 7b927382b54e3b21534cbd19b5b87598f0d79e36..fb45236cdbe0b9a77637024e2c86b27187a3e47d 100644 (file)
             // get the first page
             if (!$firstpageid = $DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id,
                         'prevpageid' => 0))) {
-                print_error('Navigation: first page not found');
+                print_error('cannotfindfirstpage', 'lesson');
             }
             lesson_print_header($cm, $course, $lesson);
             if ($lesson->timed) {
         }
         // start at the first page
         if (!$pageid = $DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id, 'prevpageid' => 0))) {
-                print_error('Navigation: first page not found');
+                print_error('cannotfindfirstpage', 'lesson');
         }
         /// This is the code for starting a timed test
         if(!isset($USER->startlesson[$lesson->id]) && !has_capability('mod/lesson:manage', $context)) {
             $startlesson->lessontime = time();
             
             if (!$DB->insert_record('lesson_timer', $startlesson)) {
-                print_error('Error: could not insert row into lesson_timer table');
+                print_error('cannotinserttimer', 'lesson');
             }
             if ($lesson->timed) {
                 lesson_set_message(get_string('maxtimewarning', 'lesson', $lesson->maxtime), 'center');
                     $retries = 0;
                 }
                 if (!$DB->delete_records('lesson_attempts', array('userid' => $USER->id, 'lessonid' => $lesson->id, 'retry' => $retries))) {
-                    print_error('Error: could not delete old attempts');
+                    print_error('cannotdeleteattempt', 'lesson');
                 }
                 if (!$DB->delete_records('lesson_branch', array('userid' => $USER->id, 'lessonid' => $lesson->id, 'retry' => $retries))) {
-                    print_error('Error: could not delete old seen branches');
+                    print_error('cannotdeletebranch', 'lesson');
                 }
             }
         }
         add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id);
         
         if (!$page = $DB->get_record('lesson_pages', array('id' => $pageid))) {
-            print_error('Navigation: the page record not found');
+            print_error('cannotfindpages', 'lesson');
         }
 
         if ($page->qtype == LESSON_CLUSTER) {  //this only gets called when a user starts up a new lesson and the first page is a cluster page
                 $pageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid);
                 // get new page info
                 if (!$page = $DB->get_record('lesson_pages', array('id' => $pageid))) {
-                    print_error('Navigation: the page record not found');
+                    print_error('cannotfindpages', 'lesson');
                 }
                 add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id);
             } else {
                 // get the next page
                 $pageid = $page->nextpageid;
                 if (!$page = $DB->get_record('lesson_pages', array('id' => $pageid))) {
-                    print_error('Navigation: the page record not found');
+                    print_error('cannotfindpages', 'lesson');
                 }
             }
         } elseif ($page->qtype == LESSON_ENDOFCLUSTER) { // Check for endofclusters
                     break;
                 } 
             } else {
-                print_error('Navigation: No answers on EOB');
+                print_error('cannotfindanswer', 'lesson');
             }
         }
         
         if(!has_capability('mod/lesson:manage', $context)) {
             $params = array ("lessonid" => $lesson->id, "userid" => $USER->id);
             if (!$timer = $DB->get_records_select('lesson_timer', "lessonid = :lessonid AND userid = :userid", $params, 'starttime')) {
-                print_error('Error: could not find records');
+                print_error('cannotfindtimer', 'lesson');
             } else {
                 $timer = array_pop($timer); // this will get the latest start time record
             }
         if (!has_capability('mod/lesson:manage', $context)) {
             $timer->lessontime = time();
             if (!$DB->update_record('lesson_timer', $timer)) {
-                print_error('Error: could not update lesson_timer table');
+                print_error('cannotupdatetimer', 'lesson');
             }
         }
 
             $retries--;
             $params = array ("lessonid" => $lesson->id, "userid" => $USER->id, "pageid" => $page->id, "retry" => $retries);
             if (! $attempts = $DB->get_records_select("lesson_attempts", "lessonid = :lessonid AND userid = :userid AND pageid = :pageid AND retry = :retry", $params, "timeseen")) {
-                print_error("Previous attempt record could not be found!");
+                print_error('cannotfindpreattempt', 'lesson');
             }
             $attempt = end($attempts);
         }
             unset($USER->startlesson[$lesson->id]);
             $params = array ("lessonid" => $lesson->id, "userid" => $USER->id);
             if (!$timer = $DB->get_records_select('lesson_timer', "lessonid = :lessonid AND userid = :userid", $params, 'starttime')) {
-                print_error('Error: could not find records');
+                print_error('cannotfindtimer', 'lesson');
             } else {
                 $timer = array_pop($timer); // this will get the latest start time record
             }
             $timer->lessontime = time();
             
             if (!$DB->update_record("lesson_timer", $timer)) {
-                print_error("Error: could not update lesson_timer table");
+                print_error('cannotupdatetimer', 'lesson');
             }
         }
         
                     if (isset($USER->modattempts[$lesson->id])) { // if reviewing, make sure update old grade record
                         $params = array ("lessonid" => $lesson->id, "userid" => $USER->id);
                         if (!$grades = $DB->get_records_select("lesson_grades", "lessonid = :lessonid and userid = :userid", $params, "completed")) {
-                            print_error("Could not find Grade Records");
+                            print_error('cannotfindgrade', 'lesson');
                         }
                         $oldgrade = end($grades);
                         $grade->id = $oldgrade->id;
                         if (!$update = $DB->update_record("lesson_grades", $grade)) {
-                            print_error("Navigation: grade not updated");
+                            print_error('cannotupdategrade', 'lesson');
                         }
                     } else {
                         if (!$newgradeid = $DB->insert_record("lesson_grades", $grade)) {
-                            print_error("Navigation: grade not inserted");
+                            print_error('cannotinsertgrade', 'lesson');
                         }
                     }
                 } else {
                     if (!$DB->delete_records("lesson_attempts", array("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $ntries))) {
-                        print_error("Could not delete lesson attempts");
+                        print_error('cannotdeleteattempt', 'lesson');
                     }
                 }
             } else {
                         $grade->completed = time();
                         if (!$lesson->practice) {
                             if (!$newgradeid = $DB->insert_record("lesson_grades", $grade)) {
-                                print_error("Navigation: grade not inserted");
+                                print_error('cannotinsertgrade', 'lesson');
                             }
                         }
                         echo get_string("eolstudentoutoftimenoanswers", "lesson");