]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Sun, 8 Jun 2008 09:08:25 +0000 (09:08 +0000)
committerdongsheng <dongsheng>
Sun, 8 Jun 2008 09:08:25 +0000 (09:08 +0000)
mod/hotpot/attempt.php
mod/hotpot/index.php
mod/hotpot/lib.php
mod/hotpot/review.php
mod/hotpot/show.php

index 5cd04241fd9caeb6919a1197c35cdc3db6c2b7a1..48c6102d351202f6ba13ade9b7eb8f4d999ea064 100644 (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 {
 
     // 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
             $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
index 4d63ad520ca044d73682da8e3a31bc7f506d0284..930c5657b1dab944ed62c8877be1fe20bb329be1 100644 (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);
                             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++;
index e32a96927d5ed7dbcabe257cb0c34414aef30fd8..5b26ae5ec4a7df2e5b03bf442e6ac4cbb679c0bd 100644 (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');
             }
         }
     }
index 583cf178574f498c1ed8a4d61130f7849dd2938e..71b673dec0c01ea1e6fde21932f4b58820d5a46b 100644 (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");
index 6b9761103e7e2355178f218d6d18693848598e98..8a8bdd99028ab16033c5a2c14b77e3d0bcffc9a9 100644 (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);