From: dongsheng Date: Fri, 13 Jun 2008 05:12:50 +0000 (+0000) Subject: "MDL-14129, fix print_error" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=86f9334590b6d939f629c9f16ead1616dcb0f60e;p=moodle.git "MDL-14129, fix print_error" --- diff --git a/mod/lesson/edit.php b/mod/lesson/edit.php index a04ae8947e..cd4b993ac4 100644 --- a/mod/lesson/edit.php +++ b/mod/lesson/edit.php @@ -24,13 +24,13 @@ 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'); } } diff --git a/mod/lesson/essay.php b/mod/lesson/essay.php index 2cc6a25969..26da46fb0a 100644 --- a/mod/lesson/essay.php +++ b/mod/lesson/essay.php @@ -68,16 +68,16 @@ $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': @@ -89,11 +89,11 @@ $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; @@ -112,7 +112,7 @@ $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 @@ -136,7 +136,7 @@ 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 @@ -146,7 +146,7 @@ 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 = ''; @@ -157,14 +157,14 @@ 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 @@ -226,7 +226,7 @@ // 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'); } } } @@ -379,4 +379,4 @@ } print_footer($course); -?> \ No newline at end of file +?> diff --git a/mod/lesson/grade.php b/mod/lesson/grade.php index 179cfdf66d..9f1836f975 100644 --- a/mod/lesson/grade.php +++ b/mod/lesson/grade.php @@ -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); diff --git a/mod/lesson/import.php b/mod/lesson/import.php index 25b4102020..48a59a8fa4 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -16,15 +16,15 @@ $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 @@ -62,15 +62,15 @@ $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 "
"; diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index be962dadf8..6cb9da60de 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -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 diff --git a/mod/lesson/tabs.php b/mod/lesson/tabs.php index eb98cfd4b3..c822231096 100644 --- a/mod/lesson/tabs.php +++ b/mod/lesson/tabs.php @@ -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 = '';