]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18293 removed obsoleted checking of return values from insert and update_record...
authorskodak <skodak>
Sat, 13 Jun 2009 17:47:18 +0000 (17:47 +0000)
committerskodak <skodak>
Sat, 13 Jun 2009 17:47:18 +0000 (17:47 +0000)
21 files changed:
auth/mnet/auth.php
lang/en_utf8/error.php
lang/en_utf8/forum.php
lang/en_utf8/hotpot.php
lang/en_utf8/lesson.php
lang/en_utf8/resource.php
login/forgot_password.php
mod/chat/lib.php
mod/data/import.php
mod/forum/lib.php
mod/glossary/import.php
mod/hotpot/attempt.php
mod/hotpot/index.php
mod/hotpot/lib.php
mod/lesson/action/continue.php
mod/lesson/essay.php
mod/lesson/locallib.php
mod/quiz/locallib.php
mod/quiz/processattempt.php
mod/resource/lib.php
mod/scorm/lib.php

index da5a9492e104e039759ebd998ff66c5cde9828d3..fb3e924f7f18803779060bc1eff67c36f7b23a6d 100644 (file)
@@ -373,12 +373,7 @@ class auth_plugin_mnet extends auth_plugin_base {
 
         $localuser->mnethostid = $remotepeer->id;
 
-        $bool = $DB->update_record('user', $localuser);
-        if (!$bool) {
-            // TODO: Jonathan to clean up mess
-            // Actually, this should never happen (modulo race conditions) - ML
-            print_error("cannotupdateuser");
-        }
+        $DB->update_record('user', $localuser);
 
         // set up the session
         $mnet_session = $DB->get_record('mnet_session',
index af0f09d9ad10855679b6b8525d7ae7805173da69..9582662c15a03e30dd709cf61143c97cfc1d1c50 100644 (file)
@@ -124,13 +124,11 @@ $string['cannotshowhidecoursesincategory'] = 'Cannot show/hide the courses in ca
 $string['cannotunzipfile'] = 'Cannot unzip file';
 $string['cannotupdaterecord'] = 'Could not update record ID $a';
 $string['cannotupdatemod'] = 'Could not update $a';
-$string['cannotupdateuser'] = 'Updating user failed';
 $string['cannotupdateusermsgpref'] = 'Cannot update user message preferences';
 $string['cannotupdateuseronexauth'] = 'Failed to update user data on external auth: $a. See the server logs for more details.';
 $string['cannotupdatepasswordonextauth'] = 'Failed to update password on external auth: $a. See the server logs for more details.';
 $string['cannotupdateprofile'] = 'Error updating user record';
 $string['cannotupdaterss'] = 'Cannot update RSS';
-$string['cannotupdatesecret'] = 'Error resetting user secret string';
 $string['cannotupdatesubcourse'] = 'Could not update a child course!';
 $string['cannotuploadfile'] = 'Error processing upload file';
 $string['cannotunassignrolefrom'] = 'Cannot unassign this user from role id: $a';
index 93869e4ec53a57c7af87734137889f72a8e367ec..87848f4f77c7fa613128ad59026f56a3a3a78979 100644 (file)
@@ -44,7 +44,6 @@ $string['cannoteditposts'] = 'You can\'t edit other people\'s posts!';
 $string['cannotsubscribe'] = 'Sorry, but you must be a group member to subscribe.';
 $string['cannotsplit'] = 'Discussions from this forum cannot be split';
 $string['cannotunsubscribe'] = 'Could not unsubscribe you from that forum';
-$string['cannotupdatecoursemoudle'] = 'Could not update course module with section id';
 $string['cannotupdatepost'] = 'You can not update this post';
 $string['cannotremovesubscriber'] = 'Could not remove subscriber with id $a from this forum!';
 $string['cannotreply'] = 'You cannot reply to this post';
index 78f9b073d959cf7bf15d5e1bfb9f013e06040c78..5b0bb345ca1d50c4cdeee56b62f41754cf7bc955 100644 (file)
@@ -16,7 +16,6 @@ $string['cannotaddresprecord'] = 'Could not add response record';
 $string['cannotaddstrrecord'] = 'Could not add string record';
 $string['cannotfindmethod'] = 'Template block expand method not found: ($a)';
 $stirng['cannotinsertattempt'] = 'Could not insert attempt record: $a';
-$string['cannotupdateattempt'] = 'Could not update attempt record: $a';
 $string['checks'] = 'Checks';
 $string['clickreporting'] = 'Enable click reporting';
 $string['clues'] = 'Clues';
index ed9355fdf5503976427478ae6908fd2072b2544a..0d84488a58bc2d0ddf3013fbf3da3df42f988447 100644 (file)
@@ -35,7 +35,6 @@ $string['branchtable'] = 'Branch Table';
 $string['cannotfindanswer'] = 'Cannot find answer';
 $string['cannotfindattempt'] = 'Error: could not find attempt';
 $string['cannotfindessay'] = 'Error: could not find essay';
-$string['cannotupdateessayscore'] = 'Could not update essay score';
 $string['cannotfindfirstpage'] = 'Could not find first page';
 $string['cannotfindfirstgrade'] = 'Error: could not find grades';
 $string['cannotfindgrade'] = 'Could not find Grade Records';
index 04ec1c0e31e6fa36009b8ba574320fa61cf8dc79..31feddfcdadd20c177e4a0810b353ddab1bd21ad 100644 (file)
@@ -9,7 +9,6 @@ $string['autofilerename'] = 'Update link if file renamed';
 $string['back'] = 'Back';
 $string['blockdeletingfile'] = 'Block deleting of referenced files';
 $string['browserepository'] = 'Browse repository';
-$string['cannotupdate'] = 'Cannot update resource.';
 $string['choose'] = 'Choose';
 $string['chooseafile'] = 'Choose or upload a file';
 $string['chooseparameter'] = 'Choose parameter';
index 1598ca6d89599a6bbc36c06769ef1ad2de18a17c..36441b25596d090ab106df0d4f03d8e2b00dee13 100644 (file)
@@ -62,9 +62,7 @@ if ($p_secret !== false) {
 
         // Clear secret so that it can not be used again
         $user->secret = '';
-        if (!$DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id))) {
-            print_error('cannotupdatesecret');
-        }
+        $DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id));
 
         reset_login_count();
 
@@ -118,9 +116,7 @@ if ($mform->is_cancelled()) {
 
             // set 'secret' string
             $user->secret = random_string(15);
-            if (!$DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id))) {
-                print_error('cannotupdatesecret');
-            }
+            $DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id));
 
             if (!send_password_change_confirmation_email($user)) {
                 print_error('cannotmailconfirm');
index 883ab4b87cc5fb54c0671af1baa30a74be3d5580..530a92a059d2078f51e3246c032743b540167242 100644 (file)
@@ -605,9 +605,8 @@ function chat_login_user($chatid, $version, $groupid, $course) {
         if (($chatuser->course != $course->id) or ($chatuser->userid != $USER->id)) {
             return false;
         }
-        if (!$DB->update_record('chat_users', $chatuser)) {
-            return false;
-        }
+        $DB->update_record('chat_users', $chatuser);
+
     } else {
         $chatuser = new object();
         $chatuser->chatid   = $chatid;
@@ -631,9 +630,7 @@ function chat_login_user($chatid, $version, $groupid, $course) {
         }
 
 
-        if (!$DB->insert_record('chat_users', $chatuser)) {
-            return false;
-        }
+        $DB->insert_record('chat_users', $chatuser);
 
         if ($version == 'sockets') {
             // do not send 'enter' message, chatd will do it
index 5ebe3408d00f1b70c8eecaa9a3b5aeef495de1c3..b665814ef3f50b633573f59dbb8623779f7ebe7d 100755 (executable)
                         }
                         $oldcontent = $DB->get_record('data_content', array('fieldid'=>$field->id, 'recordid'=>$recordid));
                         $content->id = $oldcontent->id;
-                        if (! $DB->update_record('data_content', $content)) {
-                            print_error('cannotupdaterecord', '', '', $recordid);
-                        }
+                        $DB->update_record('data_content', $content);
                     }
                     $recordsadded++;
                     print get_string('added', 'moodle', $recordsadded) . ". " . get_string('entry', 'data') . " (ID $recordid)<br />\n";
index ae707a68a31e5e483e9ba7355a303d64b8e6b6e9..990bc3ddf7c01b04ddd787067dc96b98e5a17eac 100644 (file)
@@ -7672,9 +7672,7 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
                 if (!$sectionid = add_mod_to_section($mod)) {
                     print_error('cannotaddteacherforumto', 'forum');
                 } else {
-                    if (!$DB->set_field('course_modules', 'section', $sectionid, array('id' => $cmid))) {
-                        print_error('cannotupdatecoursemoudle', 'forum');
-                    }
+                    $DB->set_field('course_modules', 'section', $sectionid, array('id' => $cmid));
                 }
             }
 
index e47d60bf4c54e007a08353b714683373e9f31c8a..89a22126ec0152721f6fce2e0cae9768628ce35c 100644 (file)
                     //We get the section's visible field status
                     $visible = $DB->get_field("course_sections", "visible", array("id"=>$sectionid));
 
-                    if (! $DB->set_field("course_modules", "visible", $visible, array("id"=>$mod->coursemodule))) {
-                        print_error('cannotupdatemod', '', '', $mod->coursemodule);
-                    }
+                    $DB->set_field("course_modules", "visible", $visible, array("id"=>$mod->coursemodule));
+                    $DB->set_field("course_modules", "section", $sectionid, array("id"=>$mod->coursemodule));
 
-                    if (! $DB->set_field("course_modules", "section", $sectionid, array("id"=>$mod->coursemodule))) {
-                        print_error('cannotupdatemod', '', '', $mod->coursemodule);
-                    }
                     add_to_log($course->id, "course", "add mod",
                                "../mod/$mod->modulename/view.php?id=$mod->coursemodule",
                                "$mod->modulename $mod->instance");
index ab189ec2930fdaf85aa882ea3f9313239d33ae4f..8fab8e96781220f4a21ff0597d1d6d641b642803 100644 (file)
     $attempt->details = $attempt->details;
 
     // update the attempt record
-    if (! $DB->update_record("hotpot_attempts", $attempt)) {
-        print_error('cannotupdateattempt', 'hotpot', $next_url, $DB->get_last_error());
-    }
+    $DB->update_record("hotpot_attempts", $attempt);
 
     // update grades for this user
     hotpot_update_grades($hotpot, $attempt->userid);
index d5dfce79bd039ec6a7420c0167359b30a60b0b0d..8f7d04aebf602c3c61b64277abb24fd08211e0cc 100644 (file)
                             $attempt->details = $DB->get_field('hotpot_details', 'details', array('attempt'=>$attempt->id));
                             if ($attempt->details) {
                                 hotpot_add_attempt_details($attempt);
-                                if (! $DB->update_record('hotpot_attempts', $attempt)) {
-                                    print_error('cannotupdateattempt', 'hotpot', $next_url, $DB->get_last_error());
-                                }
+                                $DB->update_record('hotpot_attempts', $attempt);
                             }
                             $attemptcount++;
                         }
index a459a10d4c64eb40f34a14395374a60a88f2b210..1b37f5d2108753d4178ed268384ac15218dd2c96 100644 (file)
@@ -939,9 +939,8 @@ function hotpot_update_chain(&$hotpot) {
                 }
 
                 // update $thishotpot, if required
-                if ($require_update && !$DB->update_record("hotpot", $thishotpot)) {
-                    print_error('cannotupdatemod', '',
-                            'view.php?id='.$hotpot->course, $hotpot->modulename);
+                if ($require_update) {
+                    $DB->update_record("hotpot", $thishotpot);
                 }
             }
         } // end foreach $ids
index ee0b10e83673d49da97259d0fd886bb104a960b4..4b5bf4b190ea080ec807b2e0f6fbb822e4de74ff 100644 (file)
@@ -40,9 +40,7 @@
         }
         
         $timer->lessontime = time();
-        if (!$DB->update_record("lesson_timer", $timer)) {
-            print_error("Error: could not update lesson_timer table");
-        }
+        $DB->update_record("lesson_timer", $timer);
     }
 
     // record answer (if necessary) and show response (if none say if answer is correct or not)
index 0f4fcb7dc3a11bf97d9430f6d5399bb2c488f78c..aa7f08c2b88385f0d9720ad25f7dc5d073c88f42 100644 (file)
 
                 $attempt->useranswer = serialize($essayinfo);
 
-                if (!$DB->update_record('lesson_attempts', $attempt)) {
-                    print_error('cannotupdateessayscore', 'lesson');
-                }
+                $DB->update_record('lesson_attempts', $attempt);
                 
                 // Get grade information
                 $grade = current($grades);
                 // Set and update
                 $updategrade->id = $grade->id;
                 $updategrade->grade = $gradeinfo->grade;
-                if($DB->update_record('lesson_grades', $updategrade)) {
-                    // Log it
-                    add_to_log($course->id, 'lesson', 'update grade', "essay.php?id=$cm->id", $lesson->name, $cm->id);
-                    
-                    lesson_set_message(get_string('changessaved'), 'notifysuccess');
-                } else {
-                    lesson_set_message(get_string('updatefailed', 'lesson'));
-                }
+                $DB->update_record('lesson_grades', $updategrade);
+                // Log it
+                add_to_log($course->id, 'lesson', 'update grade', "essay.php?id=$cm->id", $lesson->name, $cm->id);
+                
+                lesson_set_message(get_string('changessaved'), 'notifysuccess');
 
                 // update central gradebook
                 lesson_update_grades($lesson, $grade->userid);
index cedadc60fe426d7ee34549e554f152bc561a6cd9..d263d29510ca279e5ac4d10988f0a3a1f471fa67 100644 (file)
@@ -875,15 +875,9 @@ function lesson_save_question_options($question) {
             $options->choose = $question->choose;
             if ($existing = $DB->get_record("quiz_randomsamatch", array("question" => $options->question))) {
                 $options->id = $existing->id;
-                if (!$DB->update_record("quiz_randomsamatch", $options)) {
-                    $result->error = "Could not update quiz randomsamatch options!";
-                    return $result;
-                }
+                $DB->update_record("quiz_randomsamatch", $options);
             } else {
-                if (!$DB->insert_record("quiz_randomsamatch", $options)) {
-                    $result->error = "Could not insert quiz randomsamatch options!";
-                    return $result;
-                }
+                $DB->insert_record("quiz_randomsamatch", $options);
             }
         break;
 
@@ -907,10 +901,7 @@ function lesson_save_question_options($question) {
                         $result->error = "Could not update multianswer alternatives! (id=$multianswer->id)";
                         return $result;
                     }
-                    if (!$DB->update_record("quiz_multianswers", $multianswer)) {
-                        $result->error = "Could not update quiz multianswer! (id=$multianswer->id)";
-                        return $result;
-                    }
+                    $DB->update_record("quiz_multianswers", $multianswer);
                 } else {    // This is a completely new answer
                     $multianswer = new stdClass;
                     $multianswer->question = $question->id;
@@ -925,10 +916,7 @@ function lesson_save_question_options($question) {
                         $result->error = "Could not insert multianswer alternatives! (questionid=$question->id)";
                         return $result;
                     }
-                    if (!$DB->insert_record("quiz_multianswers", $multianswer)) {
-                        $result->error = "Could not insert quiz multianswer!";
-                        return $result;
-                    }
+                    $DB->insert_record("quiz_multianswers", $multianswer);
                 }
             }
         break;
index 8ec712059b80faa5d6686cc43e8cbc740619e288..b5510be11c5b292fe60bc317889ed3d657090f0e 100644 (file)
@@ -614,19 +614,13 @@ function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
     if ($grade = $DB->get_record('quiz_grades', array('quiz' => $quiz->id, 'userid' => $userid))) {
         $grade->grade = $bestgrade;
         $grade->timemodified = time();
-        if (!$DB->update_record('quiz_grades', $grade)) {
-            notify('Could not update best grade');
-            return false;
-        }
+        $DB->update_record('quiz_grades', $grade);
     } else {
         $grade->quiz = $quiz->id;
         $grade->userid = $userid;
         $grade->grade = $bestgrade;
         $grade->timemodified = time();
-        if (!$DB->insert_record('quiz_grades', $grade)) {
-            notify('Could not insert new best grade');
-            return false;
-        }
+        $DB->insert_record('quiz_grades', $grade);
     }
 
     quiz_update_grades($quiz, $userid);
index e1a1d1e961201f1119c8deacdadd6f9d676ea28e..afd5df40289e8f45b771252a591aa5b0e18bc5ad 100644 (file)
@@ -156,9 +156,7 @@ if (!$success) {
 /// save the attempt and redirect to the next page.
 if (!$finishattempt) {
     $attempt->timemodified = $timenow;
-    if (!$DB->update_record('quiz_attempts', $attempt)) {
-        quiz_error($attemptobj->get_quiz(), 'saveattemptfailed');
-    }
+    $DB->update_record('quiz_attempts', $attempt);
 
     redirect($nexturl);
 }
@@ -199,9 +197,7 @@ add_to_log($attemptobj->get_courseid(), 'quiz', 'close attempt',
 /// Update the quiz attempt record.
 $attempt->timemodified = $timenow;
 $attempt->timefinish = $timenow;
-if (!$DB->update_record('quiz_attempts', $attempt)) {
-    quiz_error($attemptobj->get_quiz(), 'saveattemptfailed');
-}
+$DB->update_record('quiz_attempts', $attempt);
 
 if (!$attempt->preview) {
 /// Record this user's best grade (if this is not a preview).
index 7f35f1b84c3ed777728d967eecd5db1e44de777b..1feece92930a4766b9afd5dc79e7ccdcaa8e96e0 100644 (file)
@@ -733,9 +733,7 @@ function resource_renamefiles($course, $wdir, $oldname, $name) {
                 $updates = true;
                 $status .= "<li><a href=\"$CFG->wwwroot/mod/resource/view.php?id=$resource->cmid\" target=\"_blank\">$resource->name</a>: $resource->reference ==> $r->reference</li>";
                 if (!empty($CFG->resource_autofilerename)) {
-                    if (!$DB->update_record('resource', $r)) {
-                        print_error('cannotupdate', 'resource');
-                    }
+                    $DB->update_record('resource', $r);
                 }
             }
         }
index 4d952c8193459810e4bd3f73c70b07404ebd8812..a894d719323857f797c7eea511366ab82db4970c 100755 (executable)
@@ -192,9 +192,7 @@ function scorm_update_instance($scorm, $mform=null) {
     }
     $scorm->grademethod  = ($scorm->whatgrade * 10) + $scorm->grademethod;
 
-    if (!$DB->update_record('scorm', $scorm)) {
-        return false;
-    }
+    $DB->update_record('scorm', $scorm);
 
     $scorm = $DB->get_record('scorm', array('id'=>$scorm->id));