From 50fb3673ba2660307f36cba401bc3945af87af37 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Thu, 29 May 2008 02:49:39 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- mod/hotpot/grade.php | 6 +++--- mod/hotpot/lib.php | 17 +++++++++-------- mod/hotpot/report.php | 16 ++++++++-------- mod/hotpot/view.php | 16 ++++++++-------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/mod/hotpot/grade.php b/mod/hotpot/grade.php index 0b7e9eef47..843414c916 100644 --- a/mod/hotpot/grade.php +++ b/mod/hotpot/grade.php @@ -5,15 +5,15 @@ $id = required_param('id', PARAM_INT); // Course module ID if (! $cm = get_coursemodule_from_id('hotpot', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { - print_error("hotpot ID was incorrect"); + print_error('invalidhotpotid', 'hotpot'); } if (! $course = get_record("course", "id", $hotpot->course)) { - print_error("Course is misconfigured"); + print_error("invalidcourse"); } require_login($course->id, false, $cm); diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index 925b7dc72f..ca894eb20d 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -455,7 +455,7 @@ function hotpot_is_visible(&$cm) { if (!isset($cm->sectionvisible)) { if (! $section = get_record('course_sections', 'id', $cm->section)) { - print_error('Course module record contains invalid section'); + print_error('invalidsection'); } $cm->sectionvisible = $section->visible; } @@ -569,7 +569,7 @@ function hotpot_add_chain(&$hotpot) { $hotpot->reference = addslashes($hotpot->reference); if (!$hotpot->instance = insert_record("hotpot", $hotpot)) { - print_error("Could not add a new instance of $hotpot->modulename", '', "view.php?id=$hotpot->course"); + print_error('cannotaddnewinstance', '', 'view.php?id='.$hotpot->course, $hotpot->modulename); } // store (hotpot table) id of start of chain @@ -582,14 +582,14 @@ function hotpot_add_chain(&$hotpot) { } if (! $hotpot->coursemodule = add_course_module($hotpot)) { - print_error("Could not add a new course module"); + print_error('cannotaddcoursemodule'); } if (! $sectionid = add_mod_to_section($hotpot) ) { - print_error("Could not add the new course module to that section"); + print_error('cannotaddcoursemoduletosection'); } - if (! set_field("course_modules", "section", $sectionid, "id", $hotpot->coursemodule)) { - print_error("Could not update the course module with the correct section"); + if (! set_field('course_modules', 'section', $sectionid, "id", $hotpot->coursemodule)) { + print_error('cannotupdatecoursemodule'); } add_to_log($hotpot->course, "course", "add mod", @@ -868,7 +868,8 @@ function hotpot_update_chain(&$hotpot) { // update $thishotpot, if required if ($require_update && !update_record("hotpot", $thishotpot)) { - print_error("Could not update the $hotpot->modulename", '', "view.php?id=$hotpot->course"); + print_error('cannotupdatemod', '', + 'view.php?id='.$hotpot->course, $hotpot->modulename); } } } // end foreach $ids @@ -1586,7 +1587,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree { // check xmlize functions are available if (! function_exists("xmlize")) { - print_error('xmlize functions are not available'); + print_error('xmlizeunavailable', 'debug'); } $this->read_file = $read_file; diff --git a/mod/hotpot/report.php b/mod/hotpot/report.php index 61b2a597af..8e4ab16db2 100644 --- a/mod/hotpot/report.php +++ b/mod/hotpot/report.php @@ -10,24 +10,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('hotpot', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = get_record("course", "id", $cm->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { - print_error("Course module is incorrect"); + print_error('invalidhotpotid', 'hotpot'); } } else { if (! $hotpot = get_record("hotpot", "id", $hp)) { - print_error("Course module is incorrect"); + print_error('invalidhotpotid', 'hotpot'); } if (! $course = get_record("course", "id", $hotpot->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } } @@ -331,7 +331,7 @@ /// Open the selected hotpot report and display it if (! is_readable("report/$mode/report.php")) { - print_error("Report not known (".clean_text($mode).")", '', $course_homeurl); + print_error('unknownreport', 'hotpot', $course_homeurl, clean_text($mode)); } include("report/default.php"); // Parent class @@ -340,7 +340,7 @@ $report = new hotpot_report(); if (! $report->display($hotpot, $cm, $course, $users, $attempts, $questions, $formdata)) { - print_error("Error occurred during report processing!", '', $course_homeurl); + print_error('error_processreport', 'hotpot', $course_homeurl); } if ($formdata['reportformat']=='htm') { diff --git a/mod/hotpot/view.php b/mod/hotpot/view.php index 3c9ddf3271..c3411a10b0 100644 --- a/mod/hotpot/view.php +++ b/mod/hotpot/view.php @@ -13,24 +13,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('hotpot', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = get_record("course", "id", $cm->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { - print_error("Course module is incorrect"); + print_error('invalidcoursemodule'); } } else { if (! $hotpot = get_record("hotpot", "id", $hp)) { - print_error("Course module is incorrect"); + print_error('invalidhotpotid', 'hotpot'); } if (! $course = get_record("course", "id", $hotpot->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } } @@ -113,7 +113,7 @@ } // open and parse the source file if(!$hp = new hotpot_xml_quiz($hotpot)) { - print_error("Quiz is unavailable at the moment"); + print_error('quizunavailable', 'hotpot'); } $get_js = optional_param('js', '', PARAM_ALPHA); $get_css = optional_param('css', '', PARAM_ALPHA); @@ -146,7 +146,7 @@ $attemptid = hotpot_add_attempt($hotpot->id); if (! is_numeric($attemptid)) { - print_error('Could not insert attempt record: '.$DB->get_last_error()); + print_error('cannotinsertattempt', 'hotpot', '', $DB->get_last_error()); } } $hp->adjust_media_urls(); -- 2.39.5