From 334f186d61fb3233e98ad2052f1e1353ca8ddd2c Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sun, 8 Jun 2008 09:08:25 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- mod/hotpot/attempt.php | 20 ++++++++++---------- mod/hotpot/index.php | 4 ++-- mod/hotpot/lib.php | 6 +++--- mod/hotpot/review.php | 16 ++++++++-------- mod/hotpot/show.php | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mod/hotpot/attempt.php b/mod/hotpot/attempt.php index 5cd04241fd..48c6102d35 100644 --- a/mod/hotpot/attempt.php +++ b/mod/hotpot/attempt.php @@ -6,19 +6,19 @@ // get attempt, hotpot, course and course_module records if (! $attempt = get_record("hotpot_attempts", "id", $attemptid)) { - print_error("Hot Potatoes attempt record $attemptid could not be accessed: ".$DB->get_last_error()); + print_error('invalidattemptid', 'hotpot'); } if ($attempt->userid != $USER->id) { - print_error("User ID is incorrect"); + print_error("invaliduserid"); } if (! $hotpot = get_record("hotpot", "id", $attempt->hotpot)) { - print_error("Hot Potatoes ID is incorrect (attempt id = $attempt->id)"); + print_error('invalidhotpotid', 'hotpot'); } if (! $course = get_record("course", "id", $hotpot->course)) { - print_error("Course ID is incorrect (hotpot id = $hotpot->id)"); + print_error('invalidcourseid'); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { - print_error("Course Module ID is incorrect"); + print_error("invalidcoursemodule"); } // make sure this user is enrolled in this course @@ -82,7 +82,7 @@ $attempt->id = insert_record("hotpot_attempts", $attempt); if (empty($attempt->id)) { - print_error("Could not insert attempt record: ".$DB->get_last_error(), '', $next_url); + print_error('cannotinsertattempt', 'hotpot', $next_url, $DB->get_last_error()); } // add attempt details record, if necessary @@ -91,7 +91,7 @@ $details->attempt = $attempt->id; $details->details = $attempt->details; if (! insert_record("hotpot_details", $details, false)) { - print_error("Could not insert attempt details record: ".$DB->get_last_error(), '', $next_url); + print_error('cannotinsertattempt', 'hotpot', $next_url, $DB->get_last_error()); } } } else { @@ -112,7 +112,7 @@ // update the attempt record if (! update_record("hotpot_attempts", $attempt)) { - print_error("Could not update attempt record: ".$DB->get_last_error(), '', $next_url); + print_error('cannotupdateattempt', 'hotpot', $next_url, $DB->get_last_error()); } // update grades for this user @@ -134,7 +134,7 @@ $details->attempt = $attempt->id; $details->details = $attempt->details; if (! insert_record("hotpot_details", $details)) { - print_error("Could not insert attempt details record: ".$DB->get_last_error(), '', $next_url); + print_error('cannotinsertattempt', 'hotpot', $next_url, $DB->get_last_error()); } } } @@ -214,7 +214,7 @@ function hotpot_set_attempt_details(&$attempt) { } if (!$ok) { return; - // print_error('Quiz type is missing or invalid'); + // print_error('QuizTypeIsMissingOrInvalid'); // print_error('error_invalidquiztype', 'hotpot'); // // script finishes here if quiztype is invalid diff --git a/mod/hotpot/index.php b/mod/hotpot/index.php index 4d63ad520c..930c5657b1 100644 --- a/mod/hotpot/index.php +++ b/mod/hotpot/index.php @@ -8,7 +8,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); @@ -163,7 +163,7 @@ if ($attempt->details) { hotpot_add_attempt_details($attempt); if (! update_record('hotpot_attempts', $attempt)) { - print_error("Could not update attempt record: ".$DB->get_last_error(), '', $next_url); + print_error('cannotupdateattempt', 'hotpot', $next_url, $DB->get_last_error()); } } $attemptcount++; diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index e32a96927d..5b26ae5ec4 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -2214,7 +2214,7 @@ function hotpot_add_response(&$attempt, &$question, &$response) { if (!$question->id = get_field('hotpot_questions', 'id', 'hotpot', $attempt->hotpot, 'md5key', $question->md5key, 'name', $question->name)) { // add question record if (!$question->id = insert_record('hotpot_questions', $question)) { - print_error("Could not add question record (attempt_id=$attempt->id): ".$DB->get_last_error(), '', $next_url); + print_error('cannotaddquestionrecord', 'hotpot', $next_url); } } @@ -2239,7 +2239,7 @@ function hotpot_add_response(&$attempt, &$question, &$response) { // add response record if(!$response->id = insert_record('hotpot_responses', $response)) { - print_error("Could not add response record (attempt_id=$attempt->id, question_id=$question->id): ".$DB->get_last_error(), '', $next_url); + print_error('cannotaddresprecord', 'hotpot', $next_url); } // we can stop looping now @@ -2393,7 +2393,7 @@ function hotpot_string_id($str) { // try and add the new string record if (!$id = insert_record('hotpot_strings', $record)) { global $DB; - print_error("Could not add string record for '".htmlspecialchars($str)."': ".$DB->get_last_error()); + print_error('cannotaddstrrecord', 'hotpot'); } } } diff --git a/mod/hotpot/review.php b/mod/hotpot/review.php index 583cf17857..71b673dec0 100644 --- a/mod/hotpot/review.php +++ b/mod/hotpot/review.php @@ -9,27 +9,27 @@ 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('invalidcoursemodule'); } 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'); } } if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) { - print_error("Attempt ID was incorrect"); + print_error('invalidattemptid', 'hotpot'); } require_login($course, true, $cm); @@ -43,7 +43,7 @@ // print_error("noreviewuntil", "quiz", '', userdate($hotpot->timeclose)); //} if ($attempt->userid != $USER->id) { - print_error("This is not your attempt!"); + print_error('notyourattempt', 'hotpot'); } } add_to_log($course->id, "hotpot", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id"); diff --git a/mod/hotpot/show.php b/mod/hotpot/show.php index 6b9761103e..8a8bdd9902 100644 --- a/mod/hotpot/show.php +++ b/mod/hotpot/show.php @@ -11,7 +11,7 @@ require_login($params->course); if (!has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $params->course))) { - print_error("You are not allowed to view this page!"); + print_error('nopermissiontoviewpage'); } if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM))) { $params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES, PARAM_INT); -- 2.39.5