]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Fri, 13 Jun 2008 05:12:50 +0000 (05:12 +0000)
committerdongsheng <dongsheng>
Fri, 13 Jun 2008 05:12:50 +0000 (05:12 +0000)
mod/lesson/edit.php
mod/lesson/essay.php
mod/lesson/grade.php
mod/lesson/import.php
mod/lesson/locallib.php
mod/lesson/tabs.php

index a04ae8947e219a86f5cd2f2ff1f606123b94d9e7..cd4b993ac46df2bfcf8d9fe18c6b33c22a6ef8bc 100644 (file)
     
     if ($firstpage = $DB->get_record('lesson_pages', array('lessonid' => $lesson->id, 'prevpageid' => 0))) {
         if (!$pages = $DB->get_records('lesson_pages', array('lessonid' => $lesson->id))) {
-            print_error('Could not find lesson pages');
+            print_error('cannotfindrecords', 'lesson');
         }
     }
     
     if ($pageid) {
         if (!$singlepage = $DB->get_record('lesson_pages', array('id' => $pageid))) {
-            print_error('Could not find page ID: '.$pageid);
+            print_error('invalidpageid', 'lesson');
         }
     }
 
index 2cc6a2596999a24f72e4d1236ca246564a8f80f4..26da46fb0ac97038fab39d9dc4e6b5832495b5d3 100644 (file)
             $attemptid = required_param('attemptid', PARAM_INT);
 
             if (!$attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid))) {
-                print_error('Error: could not find attempt');
+                print_error('cannotfindattempt', 'lesson');
             }
             if (!$page = $DB->get_record('lesson_pages', array('id' => $attempt->pageid))) {
-                print_error('Error: could not find lesson page');
+                print_error('cannotfindpages', 'lesson');
             }
             if (!$user = $DB->get_record('user', array('id' => $attempt->userid))) {
-                print_error('Error: could not find users');
+                print_error('cannotfinduser', 'lesson');
             }
             if (!$answer = $DB->get_record('lesson_answers', array('lessonid' => $lesson->id, 'pageid' => $page->id))) {
-                print_error('Error: could not find answer');
+                print_error('cannotfindanswer', 'lesson');
             }
             break;
         case 'update':
                 $attemptid = required_param('attemptid', PARAM_INT);
                 
                 if (!$attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid))) {
-                    print_error('Error: could not find essay');
+                    print_error('cannotfindattempt', 'lesson');
                 }
                 $params = array ("lessonid" => $lesson->id, "userid" => $attempt->userid);
                 if (!$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid and userid = :userid", $params, 'completed', '*', $attempt->retry, 1)) {
-                    print_error('Error: could not find grades');
+                    print_error('cannotfindgrade', 'lesson');
                 }
 
                 $essayinfo = new stdClass;
                 $attempt->useranswer = serialize($essayinfo);
 
                 if (!$DB->update_record('lesson_attempts', $attempt)) {
-                    print_error('Could not update essay score');
+                    print_error('cannotupdateessayscore', 'lesson');
                 }
                 
                 // Get grade information
 
                 redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id");
             } else {
-                print_error('Something is wrong with the form data');
+                print_error('invalidformdata');
             }
             break;
         case 'email': // Sending an email(s) to a single user or all
             if ($userid = optional_param('userid', 0, PARAM_INT)) {
                 $queryadd = " AND userid = :userid";
                 if (! $users = $DB->get_records('user', array('id' => $userid))) {
-                    print_error('Error: could not find users');
+                    print_error('cannotfinduser', 'lesson');
                 }
             } else {
                 $queryadd = '';
                                          WHERE a.lessonid = :lessonid and
                                                u.id = a.userid
                                          ORDER BY u.lastname", $params)) {
-                    print_error('Error: could not find users');
+                    print_error('cannotfinduser', 'lesson');
                 }
             }
 
             // Get lesson pages that are essay
             $params = array ("lessonid" => $lesson->id, "qtype" => LESSON_ESSAY);
             if (!$pages = $DB->get_records_select('lesson_pages', "lessonid = :lessonid AND qtype = :qtype", $params)) {
-                print_error('Error: could not find lesson pages');
+                print_error('cannotfindpages', 'lesson');
             }
 
             // Get only the attempts that are in response to essay questions
                         // Log it
                         add_to_log($course->id, 'lesson', 'update email essay grade', "essay.php?id=$cm->id", format_string($pages[$attempt->pageid]->title,true).': '.fullname($users[$attempt->userid]), $cm->id);
                     } else {
-                        print_error('Emailing Failed');
+                        print_error('emailfail');
                     }
                 }
             }
     }
     
     print_footer($course);
-?>
\ No newline at end of file
+?>
index 179cfdf66dcbe61832d8c0f58f7c59b036c755dc..9f1836f97560f7a5279960a3f8534e93d8a149e5 100644 (file)
@@ -5,15 +5,15 @@
     $id   = required_param('id', PARAM_INT);          // Course module ID
 
     if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        print_error("Course Module ID was incorrect");
+        print_error('invalidcoursemodule');
     }
 
     if (! $lesson = $DB->get_record("lesson", array("id" => $cm->instance))) {
-        print_error("lesson ID was incorrect");
+        print_error('invalidlessonid', 'lesson');
     }
 
     if (! $course = $DB->get_record("course", array("id" => $lesson->course))) {
-        print_error("Course is misconfigured");
+        print_error('coursemisconf');
     }
 
     require_login($course->id, false, $cm);
index 25b41020208c6938e565301492ad87e0e9e65325..48a59a8fa4f2481976ceac27bb34f7d4a888f5f8 100644 (file)
     $pageid = optional_param('pageid', '', PARAM_INT); // Page ID
 
     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');
     }
 
 
@@ -52,7 +52,7 @@
         } else {  // Valid file is found
 
             if (! is_readable("$CFG->dirroot/question/format/$form->format/format.php")) {
-                print_error("Format not known ($form->format)");
+                print_error('unknowformat','', '', $form->format);
             }
 
             require("format.php");  // Parent class
             $format = new $classname();
 
             if (! $format->importpreprocess()) {             // Do anything before that we need to
-                print_error("Error occurred during pre-processing!");
+                print_error('preprocesserror', 'lesson');
             }
 
             if (! $format->importprocess($_FILES['newfile']['tmp_name'], $lesson, $pageid)) {    // Process the uploaded file
-                print_error("Error occurred during processing!");
+                print_error('processerror', 'lesson');
             }
 
             if (! $format->importpostprocess()) {                     // In case anything needs to be done after
-                print_error("Error occurred during post-processing!");
+                print_error('postprocesserror', 'lesson');
             }
 
             echo "<hr>";
index be962dadf801deadf06cc7fa311277693ec39a3c..6cb9da60de1856232accea58691ff4a7e33cf7d5 100644 (file)
@@ -272,26 +272,26 @@ function lesson_get_basics($cmid = 0, $lessonid = 0) {
     
     if ($cmid) {
         if (!$cm = get_coursemodule_from_id('lesson', $cmid)) {
-            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');
         }
     } else if ($lessonid) {
         if (!$lesson = $DB->get_record('lesson', array('id' => $lessonid))) {
-            print_error('Course module is incorrect');
+            print_error('invalidcoursemodule');
         }
         if (!$course = $DB->get_record('course', array('id' => $lesson->course))) {
-            print_error('Course is misconfigured');
+            print_error('coursemisconf');
         }
         if (!$cm = get_coursemodule_from_instance('lesson', $lesson->id, $course->id)) {
-            print_error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
     } else {
-        print_error('No course module ID or lesson ID were passed');
+        print_error('invalidid', 'lesson');
     }
     
     return array($cm, $course, $lesson);
@@ -1082,7 +1082,7 @@ function lesson_cluster_jump($lessonid, $userid, $pageid) {
 
     // get the lesson pages
     if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
-        print_error("Error: could not find records in lesson_pages table");
+        print_error('cannotfindrecords', 'lesson');
     }
     // find the start of the cluster
     while ($pageid != 0) { // this condition should not be satisfied... should be a cluster page
@@ -1213,7 +1213,7 @@ function lesson_unseen_question_jump($lesson, $user, $pageid) {
 
     // get the lesson pages
     if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
-        print_error("Error: could not find records in lesson_pages table");
+        print_error('cannotfindpages', 'lesson');
     }
     
     if ($pageid == LESSON_UNSEENBRANCHPAGE) {  // this only happens when a student leaves in the middle of an unseen question within a branch series
@@ -1273,12 +1273,12 @@ function lesson_unseen_branch_jump($lessonid, $userid) {
     $params = array ("lessonid" => $lessonid, "userid" => $userid, "retry" => $retakes);
     if (!$seenbranches = $DB->get_records_select("lesson_branch", "lessonid = :lessonid AND userid = :userid AND retry = :retry", $params,
                 "timeseen DESC")) {
-        print_error("Error: could not find records in lesson_branch table");
+        print_error('cannotfindrecords', 'lesson');
     }
 
     // get the lesson pages
     if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
-        print_error("Error: could not find records in lesson_pages table");
+        print_error('cannotfindpages', 'lesson');
     }
     
     // this loads all the viewed branch tables into $seen untill it finds the branch table with the flag
@@ -1328,7 +1328,7 @@ function lesson_random_question_jump($lessonid, $pageid) {
     // get the lesson pages
     $params = array ("lessonid" => $lessonid);
     if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
-        print_error("Error: could not find records in lesson_pages table");
+        print_error('cannotfindpages', 'lesson');
     }
 
     // go up the pages till branch table
index eb98cfd4b36c77fadcdf284ee7324094640f3dd4..c8222310966ec8aaeb0f5250babb343997410b8d 100644 (file)
@@ -12,7 +12,7 @@
 /// This file to be included so we can assume config.php has already been included.
     global $DB;
     if (empty($lesson)) {
-        print_error('You cannot call this script in that way');
+        print_error('cannotcallscript');
     }
     if (!isset($currenttab)) {
         $currenttab = '';