"MDL-14129, fix print_error"

This commit is contained in:
dongsheng
2008-06-08 09:08:25 +00:00
parent 200a3c35e7
commit 334f186d61
5 changed files with 24 additions and 24 deletions
+10 -10
View File
@@ -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
+2 -2
View File
@@ -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++;
+3 -3
View File
@@ -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');
}
}
}
+8 -8
View File
@@ -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");
+1 -1
View File
@@ -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);