]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14129, remove all the other error() call
authordongsheng <dongsheng>
Fri, 4 Apr 2008 02:54:20 +0000 (02:54 +0000)
committerdongsheng <dongsheng>
Fri, 4 Apr 2008 02:54:20 +0000 (02:54 +0000)
422 files changed:
admin/auth_config.php
admin/block.php
admin/blocks.php
admin/cliupgrade.php
admin/delete.php
admin/filter.php
admin/filters.php
admin/index.php
admin/lang.php
admin/langdoc.php
admin/langimport.php
admin/maintenance.php
admin/mnet/index.php
admin/mnet/peers.php
admin/modules.php
admin/multilangupgrade.php
admin/register.php
admin/replace.php
admin/report/stats/index.php
admin/roles/assign.php
admin/roles/manage.php
admin/roles/override.php
admin/roles/tabs.php
admin/upgradeforumread.php
admin/upgradelogs.php
admin/uploadpicture.php
admin/uploaduser.php
admin/user.php
admin/user/user_bulk_message.php
admin/xmldb/actions/edit_field_save/edit_field_save.class.php
admin/xmldb/actions/edit_index_save/edit_index_save.class.php
admin/xmldb/actions/edit_key_save/edit_key_save.class.php
admin/xmldb/actions/edit_table_save/edit_table_save.class.php
admin/xmldb/actions/edit_xml_file_save/edit_xml_file_save.class.php
admin/xmldb/index.php
auth/ldap/ntlmsso_attempt.php
auth/ldap/ntlmsso_finish.php
auth/mnet/auth.php
auth/mnet/jump.php
auth/mnet/land.php
auth/shibboleth/login.php
backup/backup.php
backup/backup_check.html
backup/backup_execute.html
backup/backup_form.html
backup/lib.php
backup/restore.php
backup/restore_check.html
backup/restore_execute.html
backup/restore_form.html
backup/restore_precheck.html
backup/restorelib.php
backup/try.php
blocks/rss_client/block_rss_client_action.php
blog/blogpage.php
blog/edit.php
blog/header.php
blog/index.php
blog/preferences.php
calendar/event.php
calendar/lib.php
course/category.php
course/delete.php
course/edit.php
course/editcategory.php
course/editsection.php
course/enrol.php
course/format/lams/format.php
course/format/topics/format.php
course/import.php
course/import/activities/index.php
course/import/groups/index.php
course/importstudents.php
course/index.php
course/info.php
course/lib.php
course/loginas.php
course/mod.php
course/modedit.php
course/recent.php
course/report.php
course/report/log/graph.php
course/report/log/index.php
course/report/log/live.php
course/report/outline/index.php
course/report/stats/graph.php
course/report/stats/index.php
course/report/stats/report.php
course/request.php
course/reset.php
course/scales.php
course/search.php
course/unenrol.php
course/user.php
course/view.php
enrol/authorize/enrol.php
enrol/authorize/enrol_form.php
enrol/authorize/index.php
enrol/authorize/locallib.php
enrol/authorize/uploadcsv.php
enrol/manual/enrol.php
enrol/mnet/enrol.php
enrol/paypal/ipn.php
error/index.php
file.php
files/index.php
filter/algebra/pix.php
filter/tex/lib.php
filter/tex/pix.php
grade/edit/letter/edit.php
grade/edit/letter/index.php
grade/edit/outcome/edit.php
grade/edit/outcome/index.php
grade/edit/scale/edit.php
grade/edit/scale/index.php
grade/edit/tree/action.php
grade/edit/tree/calculation.php
grade/edit/tree/category.php
grade/edit/tree/grade.php
grade/edit/tree/index.php
grade/export/key.php
grade/export/ods/dump.php
grade/export/txt/dump.php
grade/export/xls/dump.php
grade/export/xml/dump.php
grade/export/xml/grade_export_xml.php
grade/import/csv/index.php
grade/import/key.php
grade/import/xml/fetch.php
grade/import/xml/import.php
grade/report/grader/lib.php
grade/report/index.php
grade/report/overview/index.php
grade/report/user/index.php
group/assign.php
group/autogroup.php
group/group.php
group/grouping.php
group/index.php
group/members.php
group/overview.php
help.php
index.php
iplookup/index.php
lib/accesslib.php
lib/adminlib.php
lib/ajax/ajaxlib.php
lib/authlib.php
lib/blocklib.php
lib/csvlib.class.php
lib/deprecatedlib.php
lib/dmllib.php
lib/editor/htmlarea/coursefiles.php
lib/editorlib.php
lib/filelib.php
lib/form/editorhelp.php
lib/formslib.php
lib/grade/grade_category.php
lib/grade/grade_grade.php
lib/grade/grade_item.php
lib/grade/grade_object.php
lib/gradelib.php
lib/grouplib.php
lib/locallib.php
lib/moodlelib.php
lib/pagelib.php
lib/questionlib.php
lib/simpletest/testeventslib.php
lib/speller/server-scripts/spellchecker.php
lib/weblib.php
login/change_password.php
login/confirm.php
login/forgot_password.php
login/index.php
login/signup.php
message/discussion.php
message/history.php
message/index.php
message/refresh.php
message/send.php
message/user.php
mod/assignment/delete.php
mod/assignment/grade.php
mod/assignment/index.php
mod/assignment/lib.php
mod/assignment/mod_form.php
mod/assignment/submissions.php
mod/assignment/type/online/db/mysql.php
mod/assignment/type/online/db/postgres7.php
mod/assignment/type/online/file.php
mod/assignment/type/upload/assignment.class.php
mod/assignment/type/upload/notes.php
mod/assignment/upload.php
mod/assignment/view.php
mod/chat/gui_basic/index.php
mod/chat/gui_header_js/chatinput.php
mod/chat/gui_header_js/index.php
mod/chat/gui_header_js/insert.php
mod/chat/gui_header_js/jsupdate.php
mod/chat/gui_header_js/jsupdated.php
mod/chat/gui_header_js/users.php
mod/chat/gui_sockets/chatinput.php
mod/chat/gui_sockets/index.php
mod/chat/index.php
mod/chat/lib.php
mod/chat/pagelib.php
mod/chat/report.php
mod/chat/view.php
mod/choice/index.php
mod/choice/lib.php
mod/choice/report.php
mod/choice/view.php
mod/data/comment.php
mod/data/edit.php
mod/data/field.php
mod/data/field/file/field.class.php
mod/data/field/latlong/kml.php
mod/data/import.php
mod/data/index.php
mod/data/lib.php
mod/data/pagelib.php
mod/data/preset.php
mod/data/preset_new.php
mod/data/rate.php
mod/data/report.php
mod/data/tabs.php
mod/data/templates.php
mod/data/view.php
mod/exercise/assessments.php
mod/exercise/index.php
mod/exercise/lib.php
mod/exercise/locallib.php
mod/exercise/submissions.php
mod/exercise/upload.php
mod/exercise/view.php
mod/forum/discuss.php
mod/forum/index.php
mod/forum/lib.php
mod/forum/markposts.php
mod/forum/post.php
mod/forum/rate.php
mod/forum/report.php
mod/forum/search.php
mod/forum/settracking.php
mod/forum/subscribe.php
mod/forum/subscribers.php
mod/forum/user.php
mod/forum/view.php
mod/glossary/approve.php
mod/glossary/comment.php
mod/glossary/comments.php
mod/glossary/deleteentry.php
mod/glossary/edit.php
mod/glossary/editcategories.php
mod/glossary/export.php
mod/glossary/exportentry.php
mod/glossary/exportfile.php
mod/glossary/import.php
mod/glossary/index.php
mod/glossary/lib.php
mod/glossary/print.php
mod/glossary/rate.php
mod/glossary/report.php
mod/glossary/showentry.php
mod/glossary/view.php
mod/hotpot/attempt.php
mod/hotpot/grade.php
mod/hotpot/index.php
mod/hotpot/lib.php
mod/hotpot/report.php
mod/hotpot/review.php
mod/hotpot/show.php
mod/hotpot/template/default.php
mod/hotpot/view.php
mod/journal/edit.php
mod/journal/index.php
mod/journal/lib.php
mod/journal/report.php
mod/journal/view.php
mod/label/view.php
mod/lams/index.php
mod/lams/view.php
mod/lesson/action/addbranchtable.php
mod/lesson/action/addcluster.php
mod/lesson/action/addendofbranch.php
mod/lesson/action/addendofcluster.php
mod/lesson/action/confirmdelete.php
mod/lesson/action/continue.php
mod/lesson/action/delete.php
mod/lesson/action/editpage.php
mod/lesson/action/insertpage.php
mod/lesson/action/move.php
mod/lesson/action/moveit.php
mod/lesson/action/updatepage.php
mod/lesson/backuplib.php
mod/lesson/edit.php
mod/lesson/essay.php
mod/lesson/format.php
mod/lesson/grade.php
mod/lesson/highscores.php
mod/lesson/import.php
mod/lesson/importppt.php
mod/lesson/index.php
mod/lesson/lesson.php
mod/lesson/locallib.php
mod/lesson/mediafile.php
mod/lesson/pagelib.php
mod/lesson/report.php
mod/lesson/restorelib.php
mod/lesson/tabs.php
mod/lesson/view.php
mod/quiz/attempt.php
mod/quiz/comment.php
mod/quiz/edit.php
mod/quiz/editlib.php
mod/quiz/grade.php
mod/quiz/index.php
mod/quiz/locallib.php
mod/quiz/pagelib.php
mod/quiz/quizfile.php
mod/quiz/report.php
mod/quiz/report/analysis/report.php
mod/quiz/report/grading/report.php
mod/quiz/report/overview/report.php
mod/quiz/report/regrade/report.php
mod/quiz/review.php
mod/quiz/reviewquestion.php
mod/quiz/tabs.php
mod/quiz/view.php
mod/resource/index.php
mod/resource/lib.php
mod/resource/mod_form.php
mod/resource/type/directory/resource.class.php
mod/resource/type/file/localfile.php
mod/resource/view.php
mod/scorm/aicc.php
mod/scorm/api.php
mod/scorm/datamodel.php
mod/scorm/index.php
mod/scorm/loadSCO.php
mod/scorm/locallib.php
mod/scorm/player.php
mod/scorm/report.php
mod/scorm/view.php
mod/survey/download.php
mod/survey/graph.php
mod/survey/index.php
mod/survey/mod_form.php
mod/survey/report.php
mod/survey/save.php
mod/survey/view.php
mod/wiki/admin.php
mod/wiki/ewiki/ewiki.php
mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php
mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php
mod/wiki/index.php
mod/wiki/lib.php
mod/wiki/overridelock.php
mod/wiki/view.php
mod/workshop/assess.php
mod/workshop/assessments.php
mod/workshop/index.php
mod/workshop/lib.php
mod/workshop/locallib.php
mod/workshop/submissions.php
mod/workshop/upload.php
mod/workshop/view.php
mod/workshop/viewassessment.php
notes/add.php
notes/delete.php
notes/edit.php
notes/index.php
question/category.php
question/category_class.php
question/contextmove.php
question/contextmoveq.php
question/editlib.php
question/export.php
question/file.php
question/format.php
question/format/blackboard_6/format.php
question/format/coursetestmanager/format.php
question/format/qti2/format.php
question/format/webct/format.php
question/format/xml/format.php
question/import.php
question/preview.php
question/question.php
question/restorelib.php
question/tabs.php
question/type/calculated/questiontype.php
question/type/datasetdependent/abstractqtype.php
question/type/description/questiontype.php
question/type/match/questiontype.php
question/type/multianswer/edit_multianswer_form.php
question/type/multianswer/questiontype.php
question/type/multichoice/questiontype.php
question/type/numerical/questiontype.php
question/type/questiontype.php
question/type/random/questiontype.php
search/tests/index.php
tag/edit.php
tag/user.php
theme/chameleon/ui/css.php
theme/index.php
theme/preview.php
user/addnote.php
user/edit.php
user/editadvanced.php
user/extendenrol.php
user/filters/lib.php
user/groupaddnote.php
user/groupextendenrol.php
user/index.php
user/messageselect.php
user/policy.php
user/profile/definelib.php
user/profile/lib.php
user/tabs.php
user/view.php
userpix/index.php
userpix/upgrade.php

index e8190c3e23d59f01d71c0b1a45ca924ea8d18ea8..d0bc55d7635690504869db6527067c5e40b6a2cb 100644 (file)
@@ -34,7 +34,7 @@ if ($frm = data_submitted() and confirm_sesskey()) {
                     $plugin = "auth/$auth";
                     $name   = $matches[1];
                     if (!set_config($name, $value, $plugin)) {
-                        error("Problem saving config $name as $value for plugin $plugin");
+                        print_error("Problem saving config $name as $value for plugin $plugin");
                     }
                 }
             }
index d21218f23c7d105ab5936493868729f482e2a5c1..ffe68d0d77b74315fa4a21802dea9952d341e32a 100644 (file)
@@ -9,14 +9,14 @@
     $blockid = required_param('block', PARAM_INT);
 
     if(!$blockrecord = blocks_get_record($blockid)) {
-        error('This block does not exist');
+        print_error('This block does not exist');
     }
 
     admin_externalpage_setup('blocksetting'.$blockrecord->name);
 
     $block = block_instance($blockrecord->name);
     if($block === false) {
-        error('Problem in instantiating block object');
+        print_error('Problem in instantiating block object');
     }
 
     // Define the data we're going to silently include in the instance config form here,
     if ($config = data_submitted()) {
 
         if (!confirm_sesskey()) {
-             error(get_string('confirmsesskeybad', 'error'));
+             print_error('confirmsesskeybad', 'error');
         }
         if(!$block->has_config()) {
-            error('This block does not support global configuration');
+            print_error('This block does not support global configuration');
         }
         $remove = array_keys($hiddendata);
         foreach($remove as $item) {
index 277645a49b289469a7f4a48e67d34b3d20a51b70..05131c396ede036f2a8d61942baeb217d295cabd 100644 (file)
@@ -33,7 +33,7 @@
 
     if (!empty($hide) && confirm_sesskey()) {
         if (!$block = get_record('block', 'id', $hide)) {
-            error("Block doesn't exist!");
+            print_error("Block doesn't exist!");
         }
         set_field('block', 'visible', '0', 'id', $block->id);      // Hide block
         admin_get_root(true, false);  // settings not required - only pages
@@ -41,7 +41,7 @@
 
     if (!empty($show) && confirm_sesskey() ) {
         if (!$block = get_record('block', 'id', $show)) {
-            error("Block doesn't exist!");
+            print_error("Block doesn't exist!");
         }
         set_field('block', 'visible', '1', 'id', $block->id);      // Show block
         admin_get_root(true, false);  // settings not required - only pages
@@ -49,7 +49,7 @@
 
     if (!empty($multiple) && confirm_sesskey()) {
         if (!$block = blocks_get_record($multiple)) {
-            error("Block doesn't exist!");
+            print_error("Block doesn't exist!");
         }
         $block->multiple = !$block->multiple;
         update_record('block', $block);
@@ -61,7 +61,7 @@
         print_heading($strmanageblocks);
 
         if (!$block = blocks_get_record($delete)) {
-            error("Block doesn't exist!");
+            print_error("Block doesn't exist!");
         }
 
         if (!block_is_compatible($block->name)) {
 /// Get and sort the existing blocks
 
     if (false === ($blocks = get_records('block'))) {
-        error('No blocks found!');  // Should never happen
+        print_error('No blocks found!');  // Should never happen
     }
 
     $incompatible = array();
     }
 
     if(empty($blockbyname)) {
-        error('One or more blocks are registered in the database, but they all failed to load!');
+        print_error('One or more blocks are registered in the database, but they all failed to load!');
     }
 
     ksort($blockbyname);
index c8a7b710c4c385aac1ad6c38f05179a05b2990e7..c5035da6b3d6daf2a7d56fe3a37e643c8a310b91 100644 (file)
@@ -1234,10 +1234,10 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
                 mark_context_dirty('/'.SYSCONTEXTID);
                 // do nothing
             } else {
-                error("Serious Error! Could not set up a default course category!");
+                print_error("Serious Error! Could not set up a default course category!");
             }
         } else {
-            error("Serious Error! Could not set up the site!");
+            print_error("Serious Error! Could not set up the site!");
         }
     }
 
index 1498dbfcaa29d7cb7800404e10c2ae6fc3f00448..bc70d504813e5ff3533106a33f8002c4a340e948 100644 (file)
@@ -37,7 +37,7 @@
     }
 
     if (!confirm_sesskey()) {
-        error('This script was called wrongly');
+        print_error('This script was called wrongly');
     }
 
     /// OK, here goes ...
index ce75068ef8385ae9a558a1b176cde0f48c373170..8c51c70f4ecbfc5eee6d5fae0d88da25eaae984b 100644 (file)
@@ -31,7 +31,7 @@
 
         // check session key
         if (!confirm_sesskey()) {
-             error( get_string('confirmsesskeybad', 'error' ) );
+             print_error('confirmsesskeybad', 'error');
         }
 
         $configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
index 57d6c7c4c2b0ab6a911f2116e99185d65a9da941..acfad110568cb0f7491d2689391a457cc57681c8 100644 (file)
@@ -53,7 +53,7 @@
     case 'show':
         // check filterpath is valid
         if (!array_key_exists($filterpath, $installedfilters)) {
-            error("Filter $filterpath is not currently installed", $url);
+            print_error("Filter $filterpath is not currently installed", '', $url);
         } elseif (array_search($filterpath,$activefilters)) {
             // filterpath is already active - doubleclick??
         } else {
@@ -67,7 +67,7 @@
         $key=array_search($filterpath, $activefilters);
         // check filterpath is valid
         if ($key===false) {
-            error("Filter $filterpath is not currently active", $url);
+            print_error("Filter $filterpath is not currently active", '', $url);
         } elseif ($key>=(count($activefilters)-1)) {
             // cannot be moved any further down - doubleclick??
         } else {
@@ -82,7 +82,7 @@
         $key=array_search($filterpath, $activefilters);
         // check filterpath is valid
         if ($key===false) {
-            error("Filter $filterpath is not currently active", $url);
+            print_error("Filter $filterpath is not currently active", '', $url);
         } elseif ($key<1) {
             //cannot be moved any further up - doubleclick??
         } else {
index c429aa018ba430fa9ba021198b467a6056fa13bf..4cea1b6b7cd54ed1837181ccbeb7d087f8ec4983 100644 (file)
     $documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
 
     if (ini_get_bool('session.auto_start')) {
-        error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
+        print_error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
     }
 
     if (ini_get_bool('magic_quotes_runtime')) {
-        error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
+        print_error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
     }
 
     if (!ini_get_bool('file_uploads')) {
-        error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
+        print_error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
     }
 
     if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') {  //Enforce prefixes for everybody but mysql
-        error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
+        print_error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
     }
 
     if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
-        error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
+        print_error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
     }
 
 /// Check that config.php has been edited
 
     if ($CFG->wwwroot == "http://example.com/moodle") {
-        error("Moodle has not been configured yet.  You need to edit config.php first.");
+        print_error("Moodle has not been configured yet.  You need to edit config.php first.");
     }
 
 
@@ -80,7 +80,7 @@
 
     $dirroot = dirname(realpath("../index.php"));
     if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
-        error("Please fix your settings in config.php:
+        print_error("Please fix your settings in config.php:
               <p>You have:
               <p>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
               <p>but it should be:
     }
 
     if (is_readable("$CFG->dirroot/version.php")) {
-        include_once("$CFG->dirroot/version.php");              # defines $version
+        include_once("$CFG->dirroot/version.php");              // defines $version
     }
 
     if (!$version or !$release) {
-        error('Main version.php was not readable or specified');# without version, stop
+        print_error('Main version.php was not readable or specified'); // without version, stop
     }
 
 /// Check if the main tables have been installed yet or not.
         } else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
             $status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method
         } else {
-            error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present.  See the lib/db directory.");
+            print_error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present.  See the lib/db directory.");
         }
 
         // all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
             notify($strdatabasesuccess, "green");
             require_once $CFG->dirroot.'/mnet/lib.php';
         } else {
-            error("Error: Main databases NOT set up successfully");
+            print_error("Error: Main databases NOT set up successfully");
         }
         print_continue('index.php');
         print_footer('none');
                         moodle_install_roles();
                         set_config('rolesactive', 1);
                     } else if (!update_capabilities()) {
-                        error('Had trouble upgrading the core capabilities for the Roles System');
+                        print_error('Had trouble upgrading the core capabilities for the Roles System');
                     }
                     // update core events
                     events_update_definition();
                         print_footer('none');
                         exit;
                     } else {
-                        error('Upgrade failed!  (Could not update version in config table)');
+                        print_error('Upgrade failed!  (Could not update version in config table)');
                     }
             /// Main upgrade not success
                 } else {
         }
     } else {
         if (!set_config("version", $version)) {
-            error("A problem occurred inserting current version into databases");
+            print_error("A problem occurred inserting current version into databases");
         }
     }
 
 
     if ($release <> $CFG->release) {  // Update the release version
         if (!set_config("release", $release)) {
-            error("ERROR: Could not update release version in database!!");
+            print_error("ERROR: Could not update release version in database!!");
         }
     }
 
         $newsite->timemodified = time();
 
         if (!$newid = insert_record('course', $newsite)) {
-            error("Serious Error! Could not set up the site!");
+            print_error("Serious Error! Could not set up the site!");
         }
         // make sure course context exists
         get_context_instance(CONTEXT_COURSE, $newid);
         $cat->name = get_string('miscellaneous');
         $cat->depth = 1;
         if (!$catid = insert_record('course_categories', $cat)) {
-            error("Serious Error! Could not set up a default course category!");
+            print_error("Serious Error! Could not set up a default course category!");
         }
         // make sure category context exists
         get_context_instance(CONTEXT_COURSECAT, $catid);
index 830c3e0863d25cf64b6459d9c2cc6e5ab96e7b69..ebec49bbbeec58ac54b1da96f0a1500b06e2d729 100644 (file)
             $stringfiles += lang_extra_locations();
         }
         if (count($stringfiles) == 0) {
-            error("Could not find English language pack!");
+            print_error("Could not find English language pack!");
         }
     } elseif ($mode == 'helpfiles') {
         $helpfiles = lang_help_standard_locations();
             $helpfiles += lang_help_extra_locations();
         }
         if (count($helpfiles) == 0) {
-            error("Could not find help files in the English language pack!");
+            print_error("Could not find help files in the English language pack!");
         }
     }
 
         echo $o;
 
         if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
-            error("Could not find English language help files!");
+            print_error("Could not find English language help files!");
         }
 
         foreach ($files as $filekey => $file) {    // check all the help files.
         }
 
         if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
-            error("Could not find English language docs files!");
+            print_error("Could not find English language docs files!");
         }
         foreach ($files as $filekey => $file) {    // check all the docs files.
             if (!file_exists("$langdir/docs/$file")) {
 
         if (!file_exists($langbase) ){
             if (!lang_make_directory($langbase) ){
-                error('ERROR: Could not create base lang directory ' . $langbase);
+                print_error('ERROR: Could not create base lang directory ' . $langbase);
             } else {
                 echo '<div class="notifysuccess">Created directory '.
                                                      $langbase .'</div>'."<br />\n";
         }
         if (!$uselocal && !file_exists($langdir)) {
             if (!lang_make_directory($langdir)) {
-                error('ERROR: Could not create directory '.$langdir);
+                print_error('ERROR: Could not create directory '.$langdir);
             } else {
                 echo '<div class="notifysuccess">Created directory '.
                                                      $langdir .'</div>'."<br />\n";
 
         if ($currentfile <> '') {
             if (!$fileinfo = lang_get_file_info($currentfile, $stringfiles)) {
-                error('Unable to find info for: '.$currentfile);
+                print_error('Unable to find info for: '.$currentfile);
             }
             // check the filename is set up correctly, prevents bugs similar to MDL-10920
             $location = $fileinfo['location'];
             if ($location || $plugin) {
                 // file in an extra location
                 if ($currentfile != "{$prefix}{$plugin}.php") {
-                    error("Non-core filename mismatch. The file $currentfile should be {$prefix}{$plugin}.php");
+                    print_error("Non-core filename mismatch. The file $currentfile should be {$prefix}{$plugin}.php");
                 }
                 if (!$uselocal) {
                     notify($streditingnoncorelangfile);
             } else {
                 // file in standard location
                 if ($currentfile != $filename) {
-                    error("Core filename mismatch. The file $currentfile should be $filename");
+                    print_error("Core filename mismatch. The file $currentfile should be $filename");
                 }
             }
 
 
         if (isset($_POST['currentfile'])){   // Save a file
             if (!confirm_sesskey()) {
-                error(get_string('confirmsesskeybad', 'error'));
+                print_error('confirmsesskeybad', 'error');
             }
 
             $newstrings = array();
             if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) {
                 notify(get_string("changessaved")." ($saveinto/$currentfile)", "notifysuccess");
             } else {
-                error("Could not save the file '$saveinto/$currentfile'!", "lang.php?mode=compare&amp;currentfile=$currentfile");
+                print_error("Could not save the file '$saveinto/$currentfile'!", '', "lang.php?mode=compare&amp;currentfile=$currentfile");
             }
             unset($packstring);
         }
 
         if (isset($_POST['currentfile'])) {  // Save a file
             if (!confirm_sesskey()) {
-                error(get_string('confirmsesskeybad', 'error'));
+                print_error('confirmsesskeybad', 'error');
             }
             if (lang_help_save_file($saveto, $currentfile, $_POST['filedata'])) {
                 notify(get_string("changessaved")." ($saveto/$currentfile)", "notifysuccess");
             } else {
-                error("Could not save the file '$currentfile'!", "lang.php?mode=helpfiles&amp;currentfile=$currentfile&amp;sesskey=$USER->sesskey");
+                print_error("Could not save the file '$currentfile'!", '', "lang.php?mode=helpfiles&amp;currentfile=$currentfile&amp;sesskey=$USER->sesskey");
             }
         }
 
index e04fc68169659079483c304232a9d55052a4440e..b456ac1961afa255ae605c58ff6596ba590f3c20 100755 (executable)
@@ -51,7 +51,7 @@
             if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
                 notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
             } else {
-                error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
+                print_error("Could not save the file '$currentfile'!", '', "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
             }
         }
     }
@@ -63,7 +63,7 @@
     // Get all files from /docs directory
 
     if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
-        error("Could not find English language docs files!");
+        print_error("Could not find English language docs files!");
     }
 
     $options = array();
@@ -83,7 +83,7 @@
     // Get all files from /help directory
 
     if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
-        error("Could not find English language help files!");
+        print_error("Could not find English language help files!");
     }
 
     foreach ($files as $filekey => $file) {    // check all the help files.
index 6ace99dcc43027c96498864dc0d3e28fb1de102d..d5d3d2d1f1f3934035c7beb2397518705c6827bf 100755 (executable)
@@ -30,7 +30,7 @@
     //reset and diagnose lang cache permissions
     @unlink($CFG->dataroot.'/cache/languages');
     if (file_exists($CFG->dataroot.'/cache/languages')) {
-        error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!');
+        print_error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!');
     }
     get_list_of_languages(true); //refresh lang cache
 
index aecd668f836cc89b6e571d97ef251e40a10d1c9d..6f0498d3ebbe8331ebe98497b588905117881363 100644 (file)
@@ -10,7 +10,7 @@
 
     //Check folder exists
     if (! make_upload_directory(SITEID)) {   // Site folder
-            error("Could not create site folder.  The site administrator needs to fix the file permissions");
+            print_error("Could not create site folder.  The site administrator needs to fix the file permissions");
         }
 
     $filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
index ee017d9bfa1799c66fe1db6fbf7319e022dc4141..65117677f4d7dfc075fb72949676594e9fbe6390 100644 (file)
     if (!extension_loaded('openssl')) {
         admin_externalpage_print_header();
         set_config('mnet_dispatcher_mode', 'off');
-        print_error('requiresopenssl', 'mnet', '', NULL, true);
+        print_error('requiresopenssl', 'mnet');
     }
 
     if (!$site = get_site()) {
         admin_externalpage_print_header();
         set_config('mnet_dispatcher_mode', 'off');
-        print_error('nosite', '', '', NULL, true);
+        print_error('nosite');
     }
 
     if (!function_exists('curl_init') ) {
         admin_externalpage_print_header();
         set_config('mnet_dispatcher_mode', 'off');
-        print_error('nocurl', 'mnet', '', NULL, true);
+        print_error('nocurl', 'mnet');
     }
 
     if (!isset($CFG->mnet_dispatcher_mode)) {
@@ -43,7 +43,7 @@
                 if (set_config('mnet_dispatcher_mode', $form->mode)) {
                     redirect('index.php', get_string('changessaved'));
                 } else {
-                    error('Invalid action parameter.', 'index.php');
+                    print_error('Invalid action parameter.', '', 'index.php');
                 }
             }
         } elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
index 09ae5d314aa22b208aec115e7fa634a66569aa6f..2448c6441baf353315edfba1f932dba6b220e4b8 100644 (file)
@@ -15,17 +15,17 @@ require_capability('moodle/site:config', $context, $USER->id, true, "nopermissio
 
 if (!extension_loaded('openssl')) {
     admin_externalpage_print_header();
-    print_error('requiresopenssl', 'mnet', '', NULL, true);
+    print_error('requiresopenssl', 'mnet');
 }
 
 if (!$site = get_site()) {
     admin_externalpage_print_header();
-    print_error('nosite', '', '', NULL, true);
+    print_error('nosite', '');
 }
 
 if (!function_exists('curl_init') ) {
     admin_externalpage_print_header();
-    print_error('nocurl', 'mnet', '', NULL, true);
+    print_error('nocurl', 'mnet');
 }
 
 /// Initialize variables.
@@ -59,7 +59,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
 
     if(!function_exists('xmlrpc_encode_request')) {
         trigger_error("You must have xml-rpc enabled in your PHP build to use this feature.");
-        error(get_string('xmlrpc-missing', 'mnet'),'peers.php');
+        print_error('xmlrpc-missing', 'mnet','peers.php');
         exit;
     }
 
@@ -82,7 +82,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
             $temp_wwwroot = clean_param($form->wwwroot, PARAM_URL);
             if ($temp_wwwroot !== $form->wwwroot) {
                 trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc.");
-                error(get_string("invalidurl", 'mnet'),'peers.php');
+                print_error("invalidurl", 'mnet','peers.php');
                 exit;
             }
             unset($temp_wwwroot);
@@ -103,7 +103,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
         if (isset($form->public_key)) {
             $form->public_key = clean_param($form->public_key, PARAM_PEM);
             if (empty($form->public_key)) {
-                error(get_string("invalidpubkey", 'mnet'),'peers.php?step=update&amp;hostid='.$mnet_peer->id);
+                print_error("invalidpubkey", 'mnet', 'peers.php?step=update&amp;hostid='.$mnet_peer->id);
                 exit;
             } else {
                 $oldkey = $mnet_peer->public_key;
@@ -116,7 +116,8 @@ if (($form = data_submitted()) && confirm_sesskey()) {
                     foreach ($mnet_peer->error as $err) {
                         $errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
                     }
-                    error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&amp;hostid='.$mnet_peer->id);
+                    //error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&amp;hostid='.$mnet_peer->id);
+                    print_error("invalidpubkey", 'mnet', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $errmsg);
                     exit;
                 }
             }
@@ -127,7 +128,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
         // PREVENT DUPLICATE RECORDS ///////////////////////////////////////////
         if ('input' == $form->step) {
             if ( isset($mnet_peer->id) && $mnet_peer->id > 0 ) {
-                error(get_string("hostexists", 'mnet', $mnet_peer->id),'peers.php?step=update&amp;hostid='.$mnet_peer->id);
+                print_error("hostexists", 'mnet', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $mnet_peer->id);
             }
         }
 
@@ -138,7 +139,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
             if ($bool) {
                 redirect('peers.php?step=update&amp;hostid='.$mnet_peer->id, get_string('changessaved'));
             } else {
-                error('Invalid action parameter.', 'index.php');
+                print_error('Invalid action parameter.', '', 'index.php');
             }
         }
     }
index 1050864500733dd592801e3797d0eaefa62a7763..8c53465b2d7a948baf499e0d2b7aaf4e5ec24cb0 100644 (file)
@@ -34,7 +34,7 @@
 
     if (!empty($hide) and confirm_sesskey()) {
         if (!$module = get_record("modules", "name", $hide)) {
-            error("Module doesn't exist!");
+            print_error("Module doesn't exist!");
         }
         set_field("modules", "visible", "0", "id", $module->id); // Hide main module
         // Remember the visibility status in visibleold
@@ -57,7 +57,7 @@
 
     if (!empty($show) and confirm_sesskey()) {
         if (!$module = get_record("modules", "name", $show)) {
-            error("Module doesn't exist!");
+            print_error("Module doesn't exist!");
         }
         set_field("modules", "visible", "1", "id", $module->id); // Show main module
         set_field('course_modules', 'visible', '1', 'visibleold',
         } else {  // Delete everything!!
 
             if ($delete == "forum") {
-                error("You can not delete the forum module!!");
+                print_error("You can not delete the forum module!!");
             }
 
             if (!$module = get_record("modules", "name", $delete)) {
-                error("Module doesn't exist!");
+                print_error("Module doesn't exist!");
             }
 
             // OK, first delete all the relevant instances from all course sections
 /// Get and sort the existing modules
 
     if (!$modules = get_records("modules")) {
-        error("No modules found!!");        // Should never happen
+        print_error("No modules found!!");        // Should never happen
     }
 
     foreach ($modules as $module) {
index 1ab04d54170e43817e83ae2fb9077fd72c8e406d..257bea2c721515a1a4887a9a48d2798067ce959b 100644 (file)
@@ -25,7 +25,7 @@ if (!$go or !data_submitted() or !confirm_sesskey()) {   /// Print a form
 
 
 if (!$tables = $db->Metatables() ) {    // No tables yet at all.
-    error("no tables");
+    print_error("no tables");
 }
 
 print_simple_box_start('center');
index ce558f4824b0c0d33fcc1bbd9f9fc51dea5ef74b..877b787a1f7ca17dae886166b9278f5c400c5111 100644 (file)
     }
 
     if (!confirm_sesskey()) {
-        error(get_string('confirmsesskeybad', 'error'));
+        print_error('confirmsesskeybad', 'error');
     }
 
     if (!$admin = get_admin()) {
-        error("No admins");
+        print_error("No admins");
     }
 
     if (!$admin->country and $CFG->country) {
index 064b024c7a61ead619b83386e54c3c1f892ccc1a..98783ca50760e1c3371bd9d7091b910f91e43794 100644 (file)
@@ -35,7 +35,7 @@ if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) {   /// Pr
 print_simple_box_start('center');
 
 if (!db_replace($search, $replace)) {
-    error('An error has occured during this process'); 
+    print_error('An error has occured during this process'); 
 }
 
 print_simple_box_end();
index 0cfd68de5584489286d7873674377748e92299ba..149f769af2cb0f95d3329e0bc0dc1dcbcad46181 100644 (file)
     }
 
     if (!$course = get_record("course","id",$courseid)) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     if (!empty($userid)) {
         if (!$user = get_record('user','id',$userid)) {
-            error("That's an invalid user id");
+            print_error("That's an invalid user id");
         }
     }
 
index fe574597abc0da3ce3ecd48f39e93c1beabf83f0..435b1a818c1e74294e71aa28db9766115d7c41c7 100755 (executable)
@@ -34,7 +34,7 @@
     }
 
     if (! $context = get_context_instance_by_id($contextid)) {
-        error("Context ID was incorrect (can't find it)");
+        print_error("Context ID was incorrect (can't find it)");
     }
 
     $inmeta = 0;
         if ($course = get_record('course', 'id', $courseid)) {
             $inmeta = $course->metacourse;
         } else {
-            error('Invalid course id');
+            print_error('Invalid course id');
         }
         $coursecontext = $context;
 
     } else if (!empty($courseid)){ // we need this for user tabs in user context
         if (!$course = get_record('course', 'id', $courseid)) {
-            error('Invalid course id');
+            print_error('Invalid course id');
         }
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
 
index c362ecebfe5b9522c67f6ad3a6cc998466932f5e..727ca64baa9a8f3174beb4646ddd9a42f879a91c 100755 (executable)
                     $role->description = $description;
 
                     if (!update_record('role', $role)) {
-                        error('Could not update role!');
+                        print_error('Could not update role!');
                     }
 
                     // set proper legacy type
 
         case 'delete':
             if (in_array($roleid, $defaultroles)) {
-                error('This role is used as one of the default system roles, it can not be deleted');
+                print_error('This role is used as one of the default system roles, it can not be deleted');
             }
             if ($confirm and data_submitted() and confirm_sesskey()) {
                 if (!delete_role($roleid)) {
                     // partially deleted a role sitewide...?
                     mark_context_dirty($sitecontext->path);
 
-                    error('Could not delete role with ID '.$roleid);
+                    print_error('Could not delete role with ID '.$roleid);
                 }
                 // deleted a role sitewide...
                 mark_context_dirty($sitecontext->path);
                     $above = $roles[$rolesort[$role->sortorder - 1]];
 
                     if (!switch_roles($role, $above)) {
-                        error("Cannot move role with ID $roleid");
+                        print_error("Cannot move role with ID $roleid");
                     }
                 }
             }
                     $below = $roles[$rolesort[$role->sortorder + 1]];
 
                     if (!switch_roles($role, $below)) {
-                        error("Cannot move role with ID $roleid");
+                        print_error("Cannot move role with ID $roleid");
                     }
                 }
             }
                 $role = stripslashes_safe($newrole);
         } else {
             if(!$role = get_record('role', 'id', $roleid)) {
-                error('Incorrect role ID!');
+                print_error('Incorrect role ID!');
             }
             $role->legacytype = get_legacy_type($role->id);
         }
index 27a6c8518dfd3f93849d685b5e8bc5e904b9c7bc..a49409ad774a917f8194c3e3a9f194501cf9e37e 100755 (executable)
@@ -9,24 +9,24 @@
     $cancel    = optional_param('cancel', 0, PARAM_BOOL);
 
     if (!$context = get_record('context', 'id', $contextid)) {
-        error('Bad context ID');
+        print_error('Bad context ID');
     }
 
     if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) {
-        error('No site ID');
+        print_error('No site ID');
     }
 
     if ($context->id == $sitecontext->id) {
-        error('Can not override base role capabilities');
+        print_error('Can not override base role capabilities');
     }
 
     if (!has_capability('moodle/role:override', $context)) {
-        error('You do not have permission to change overrides in this context!');
+        print_error('You do not have permission to change overrides in this context!');
     }
 
     if ($courseid) {
         if (!$course = get_record('course', 'id', $courseid)) {
-            error('Bad course ID');
+            print_error('Bad course ID');
         }
 
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
index be51f4a714b0b83c17853fc02bc9637c59471936..e19b81c704c3eb2a468f66b15a40eb338fe92349 100755 (executable)
@@ -61,16 +61,16 @@ if ($currenttab != 'update') {
         case CONTEXT_MODULE:
             // get module type?
             if (!$cm = get_record('course_modules','id',$context->instanceid)) {
-                error('Bad course module ID');
+                print_error('Bad course module ID');
             }
             if (!$module = get_record('modules','id',$cm->module)) {  //$module->name;
-                error('Bad module ID');
+                print_error('Bad module ID');
             }
             if (!$course = get_record('course','id',$cm->course)) {
-                error('Bad course ID');
+                print_error('Bad course ID');
             }
             if (!$instance = get_record($module->name, 'id', $cm->instance)) {
-                error("The required instance of this module doesn't exist");
+                print_error("The required instance of this module doesn't exist");
             }
 
             require_login($course);
index c8db682c7803603164c8964a41d3df0d21960699..edf0c4d791c83a99162f914ee787bf00acefddd4 100644 (file)
@@ -9,7 +9,7 @@
     $confirm = optional_param('confirm', 0, PARAM_BOOL);
 
     if ($CFG->version < 2005042300) {
-        error("This script does not work with this old version of Moodle");
+        print_error("This script does not work with this old version of Moodle");
     }
 
     if (!$site = get_site()) {
index 2803e2c2370ddd2d256da944d31e66a9dd5d11ff..fa27125d0abf7ef1ae08bb3793a07776e33d75fa 100644 (file)
@@ -8,7 +8,7 @@
     $confirm = optional_param('confirm', 0, PARAM_BOOL);
 
     if ($CFG->version < 2004013101) {
-        error("This script does not work with this old version of Moodle");
+        print_error("This script does not work with this old version of Moodle");
     }
 
     if (!$site = get_site()) {
index c785b02ac0c1b383b099f3c910fc1fbe8852a1b7..99dce0de52c1a11897faa32029ca1a7e4703ec6b 100644 (file)
@@ -35,11 +35,11 @@ require_login();
 require_capability('moodle/site:uploadusers', get_context_instance(CONTEXT_SYSTEM, SITEID));
 
 if (!$site = get_site()) {
-    error("Could not find site-level course");
+    print_error("Could not find site-level course");
 }
 
 if (!$adminuser = get_admin()) {
-    error("Could not find site admin");
+    print_error("Could not find site admin");
 }
 
 $strfile = get_string('file');
index 550c1992e680203e4aa7f1a74e29f4c34aa2364e..b8f8854d9f8f0f8404f57d57c20226f030902fc5 100755 (executable)
@@ -92,9 +92,9 @@ if (empty($iid)) {
         unset($content);
 
         if ($readcount === false) {
-            error($cir->get_error(), $returnurl);
+            print_error($cir->get_error(), '', $returnurl);
         } else if ($readcount == 0) {
-            error(get_string('csvemptyfile', 'error'), $returnurl);
+            print_error('csvemptyfile', 'error', $returnurl);
         }
         // continue to form2
 
@@ -110,7 +110,7 @@ if (empty($iid)) {
 }
 
 if (!$columns = $cir->get_columns()) {
-    error('Error reading temporary file', $returnurl);
+    print_error('Error reading temporary file', '', $returnurl);
 }
 $mform = new admin_uploaduser_form2(null, $columns);
 // get initial date from form1
index 9ae92ee2bfe5bd7049d95b813d6dbb7136bc7a67..eb1fd6f559796f579923f90a56e9b7803439de14 100644 (file)
@@ -22,7 +22,7 @@
     $site = get_site();
 
     if (!has_capability('moodle/user:update', $sitecontext) and !has_capability('moodle/user:delete', $sitecontext)) {
-        error('You do not have the required permission to edit/delete users.');
+        print_error('You do not have the required permission to edit/delete users.');
     }
 
     $stredit   = get_string('edit');
@@ -40,7 +40,7 @@
 
     if ($confirmuser and confirm_sesskey()) {
         if (!$user = get_record('user', 'id', $confirmuser)) {
-            error("No such user!", '', true);
+            print_error("No such user!");
         }
 
         $auth = get_auth_plugin($user->auth);
     } else if ($delete and confirm_sesskey()) {              // Delete a selected user, after confirmation
 
         if (!has_capability('moodle/user:delete', $sitecontext)) {
-            error('You do not have the required permission to delete a user.');
+            print_error('You do not have the required permission to delete a user.');
         }
 
         if (!$user = get_record('user', 'id', $delete)) {
-            error("No such user!", '', true);
+            print_error("No such user!");
         }
 
         if (is_primary_admin($user->id)) {
-            error("You are not allowed to delete the primary admin user!", '', true);
+            print_error("You are not allowed to delete the primary admin user!");
         }
 
         if ($confirm != md5($delete)) {
     } else if ($acl and confirm_sesskey()) {
         if (!has_capability('moodle/user:delete', $sitecontext)) {
             // TODO: this should be under a separate capability
-            error('You are not permitted to modify the MNET access control list.');
+            print_error('You are not permitted to modify the MNET access control list.');
         }
         if (!$user = get_record('user', 'id', $acl)) {
-            error("No such user.", '', true);
+            print_error("No such user.");
         }
         if (!is_mnet_remote_user($user)) {
-            error('Users in the MNET access control list must be remote MNET users.');
+            print_error('Users in the MNET access control list must be remote MNET users.');
         }
         $accessctrl = strtolower(required_param('accessctrl', PARAM_ALPHA));
         if ($accessctrl != 'allow' and $accessctrl != 'deny') {
-            error('Invalid access parameter.');
+            print_error('Invalid access parameter.');
         }
         $aclrecord = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid);
         if (empty($aclrecord)) {
             $aclrecord->username = $user->username;
             $aclrecord->accessctrl = $accessctrl;
             if (!insert_record('mnet_sso_access_control', $aclrecord)) {
-                error("Database error - Couldn't modify the MNET access control list.", '', true);
+                print_error("Database error - Couldn't modify the MNET access control list.");
             }
         } else {
             $aclrecord->accessctrl = $accessctrl;
             if (!update_record('mnet_sso_access_control', $aclrecord)) {
-                error("Database error - Couldn't modify the MNET access control list.", '', true);
+                print_error("Database error - Couldn't modify the MNET access control list.");
             }
         }
         $mnethosts = get_records('mnet_host', '', '', 'id', 'id,wwwroot,name');
index 42751ccca0defefe99a55b1da4bad2a50e402505..0015219a21bde913719466945219848f92fbd58b 100755 (executable)
@@ -17,7 +17,7 @@ if (empty($SESSION->bulk_users)) {
 }
 
 if (empty($CFG->messaging)) {
-    error("Messaging is disabled on this site");
+    print_error("Messaging is disabled on this site");
 }
 
 //TODO: add support for large number of users
index 41c2a8dd86acd1234a9290a0a93e747b7a3fe36e..2d991345aa749f6758b99d4695820584c4b5fdf0 100644 (file)
@@ -76,7 +76,7 @@ class edit_field_save extends XMLDBAction {
     /// Do the job, setting result as needed
 
         if (!data_submitted('nomatch')) { ///Basic prevention
-            error('Wrong action call');
+            print_error('Wrong action call');
         }
 
     /// Get parameters
index 2c2276d095862fdcce49c70a239a48eb0b8992db..5dee7f1f4b58758f11277a38204a827d8ebceb67 100644 (file)
@@ -70,7 +70,7 @@ class edit_index_save extends XMLDBAction {
     /// Do the job, setting result as needed
 
         if (!data_submitted('nomatch')) { ///Basic prevention
-            error('Wrong action call');
+            print_error('Wrong action call');
         }
 
     /// Get parameters
index 3ca892a568d760292af82caddf0cd37803e1ada1..1fb2c47433a2833e0ee4db898215a7efa13d7ad6 100644 (file)
@@ -76,7 +76,7 @@ class edit_key_save extends XMLDBAction {
     /// Do the job, setting result as needed
 
         if (!data_submitted('nomatch')) { ///Basic prevention
-            error('Wrong action call');
+            print_error('Wrong action call');
         }
 
     /// Get parameters
index 19f4c3c84517723ada19cdfe5680c3e53f6f5826..a6429c5863bd0496408a67a99602b7edab7521ab 100644 (file)
@@ -66,7 +66,7 @@ class edit_table_save extends XMLDBAction {
     /// Do the job, setting result as needed
 
         if (!data_submitted('nomatch')) { ///Basic prevention
-            error('Wrong action call');
+            print_error('Wrong action call');
         }
 
     /// Get parameters
index 2147a7953ed2bb454dd90770be61116eee66e4b7..b989394ea4fa4c8eeacf18c983838e08e8a0108e 100644 (file)
@@ -62,7 +62,7 @@ class edit_xml_file_save extends XMLDBAction {
     /// Do the job, setting result as needed
 
         if (!data_submitted('nomatch')) { ///Basic prevention
-            error('Wrong action call');
+            print_error('Wrong action call');
         }
 
     /// Get parameters
index 55d098aadffd58361e0a48e65d57972b76980d29..58964ccccf686a2d805fdad3335b9da9c8c9eec6 100644 (file)
                         break;
                 }
             } else {
-                error($xmldb_action->getError());
+                print_error($xmldb_action->getError());
             }
         } else {
             error ("Error: cannot instantiate class (actions/$action/$actionclass)");
index c9fc4695e2bfa719e01443aa2d71dec3626a509e..959f8dc6bf57c3ef48909e1779782c928b9966d8 100644 (file)
@@ -7,7 +7,7 @@ httpsrequired();
 
 /// Define variables used in page
 if (!$site = get_site()) {
-    error("No site found!");
+    print_error("No site found!");
 }
 
 $authsequence = get_enabled_auth_plugins(true); // auths, in sequence
index c64e75570fd53dfab04e2d3d7997331ce83a11fa..92b22ee8e4d9a07fa44d5b9bb1e641086348a5a2 100644 (file)
@@ -7,7 +7,7 @@ httpsrequired();
 
 /// Define variables used in page
 if (!$site = get_site()) {
-    error("No site found!");
+    print_error("No site found!");
 }
 
 $authsequence = get_enabled_auth_plugins(true); // auths, in sequence
index 87360ed576466282cf65fed6da22d9c5e5241bb5..d9e89e167c4224f543510e0db938f45c1188584c 100644 (file)
@@ -62,7 +62,7 @@ class auth_plugin_mnet extends auth_plugin_base {
      * @return bool Authentication success or failure.
      */
     function user_login($username, $password) {
-        return false; // error("Remote MNET users cannot login locally.");
+        return false; // print_error("Remote MNET users cannot login locally.");
     }
 
     /**
@@ -175,12 +175,12 @@ class auth_plugin_mnet extends auth_plugin_base {
                 or is_mnet_remote_user($USER)
                 or $USER->username == 'guest'
                 or empty($USER->id)) {
-            error(get_string('notpermittedtojump', 'mnet'));
+            print_error('notpermittedtojump', 'mnet');
         }
 
         // check for SSO publish permission first
         if ($this->has_service($mnethostid, 'sso_sp') == false) {
-            error(get_string('hostnotconfiguredforsso', 'mnet'));
+            print_error('hostnotconfiguredforsso', 'mnet');
         }
 
         // set RPC timeout to 30 seconds if not configured
@@ -209,7 +209,7 @@ class auth_plugin_mnet extends auth_plugin_base {
             $mnet_session->expires = time() + (integer)ini_get('session.gc_maxlifetime');
             $mnet_session->session_id = session_id();
             if (! $mnet_session->id = insert_record('mnet_session', addslashes_object($mnet_session))) {
-                error(get_string('databaseerror', 'mnet'));
+                print_error('databaseerror', 'mnet');
             }
         } else {
             $mnet_session->useragent = sha1($_SERVER['HTTP_USER_AGENT']);
@@ -218,7 +218,7 @@ class auth_plugin_mnet extends auth_plugin_base {
             $mnet_session->expires = time() + (integer)ini_get('session.gc_maxlifetime');
             $mnet_session->session_id = session_id();
             if (false == update_record('mnet_session', addslashes_object($mnet_session))) {
-                error(get_string('databaseerror', 'mnet'));
+                print_error('databaseerror', 'mnet');
             }
         }
 
@@ -245,7 +245,7 @@ class auth_plugin_mnet extends auth_plugin_base {
 
         // verify the remote host is configured locally before attempting RPC call
         if (! $remotehost = get_record('mnet_host', 'wwwroot', $remotewwwroot)) {
-            error(get_string('notpermittedtoland', 'mnet'));
+            print_error('notpermittedtoland', 'mnet');
         }
 
         // get the originating (ID provider) host info
@@ -268,12 +268,12 @@ class auth_plugin_mnet extends auth_plugin_base {
                 list($code, $message) = array_map('trim',explode(':', $errormessage, 2));
                 if($code == 702) {
                     $site = get_site();
-                    print_error('mnet_session_prohibited','mnet', $remotewwwroot, format_string($site->fullname));
+                    print_error('mnet_session_prohibited', 'mnet', $remotewwwroot, format_string($site->fullname));
                     exit;
                 }
                 $message .= "ERROR $code:<br/>$errormessage<br/>";
             }
-            error("RPC auth/mnet/user_authorise:<br/>$message");
+            print_error("RPC auth/mnet/user_authorise:<br/>$message");
         }
         unset($mnetrequest);
 
@@ -291,15 +291,15 @@ class auth_plugin_mnet extends auth_plugin_base {
         // TODO: refactor into a separate function
         if (empty($localuser) || ! $localuser->id) {
             if (empty($this->config->auto_add_remote_users)) {
-                error(get_string('nolocaluser', 'mnet'));
+                print_error('nolocaluser', 'mnet');
             }
             $remoteuser->mnethostid = $remotehost->id;
             if (! insert_record('user', addslashes_object($remoteuser))) {
-                error(get_string('databaseerror', 'mnet'));
+                print_error('databaseerror', 'mnet');
             }
             $firsttime = true;
             if (! $localuser = get_record('user', 'username', addslashes($remoteuser->username), 'mnethostid', $remotehost->id)) {
-                error(get_string('nolocaluser', 'mnet'));
+                print_error('nolocaluser', 'mnet');
             }
         }
 
@@ -372,7 +372,7 @@ class auth_plugin_mnet extends auth_plugin_base {
         if (!$bool) {
             // TODO: Jonathan to clean up mess
             // Actually, this should never happen (modulo race conditions) - ML
-            error("updating user failed in mnet/auth/confirm_mnet_session ");
+            print_error("updating user failed in mnet/auth/confirm_mnet_session ");
         }
 
         // set up the session
@@ -392,7 +392,7 @@ class auth_plugin_mnet extends auth_plugin_base {
             $mnet_session->expires = time() + (integer)$session_gc_maxlifetime;
             $mnet_session->session_id = session_id();
             if (! $mnet_session->id = insert_record('mnet_session', addslashes_object($mnet_session))) {
-                error(get_string('databaseerror', 'mnet'));
+                print_error('databaseerror', 'mnet');
             }
         } else {
             $mnet_session->expires = time() + (integer)$session_gc_maxlifetime;
index f05d7152fdd84107ab3e8eb98c001f6e221ab4a2..0058e5caafd9ad11e23d41a65b6e3af55343cc80 100644 (file)
@@ -15,7 +15,7 @@
 require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
 
 if (!is_enabled_auth('mnet')) {
-    error('mnet is disabled');
+    print_error('mnet is disabled');
 }
 
 // grab the GET params - wantsurl could be anything - take it
@@ -28,7 +28,7 @@ $mnetauth = get_auth_plugin('mnet');
 $url      = $mnetauth->start_jump_session($hostid, $wantsurl);
 
 if (empty($url)) {
-    error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors
+    print_error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors
 }
 redirect($url);
 
index 82ddd167c7eb92f6d57aaffaed21212b695d63a2..3836d56e5ad26bb6dc2e4b61d2778c90bf0b1092 100644 (file)
@@ -20,7 +20,7 @@ if (!$site = get_site()) {
 }
 
 if (!is_enabled_auth('mnet')) {
-    error('mnet is disabled');
+    print_error('mnet is disabled');
 }
 // grab the GET params
 $token         = required_param('token',    PARAM_BASE64);
index 32c14781204d87e4ba3542d135ca6d0aa3a3281b..e81b802224f33efb636f918006f43344e387993f 100644 (file)
@@ -21,7 +21,7 @@ httpsrequired();
 
 /// Define variables used in page
     if (!$site = get_site()) {
-        error("No site found!");
+        print_error("No site found!");
     }
 
     if (empty($CFG->langmenu)) {
index 3e45cc4cfd0dc3dfbc8daf62b7814f130f3b7844..a4c352e6bc669055d11150b4673f4c62fc9b3e9c 100644 (file)
     if (!empty($id)) {
         require_login($id);
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $id))) {
-            error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     } else {
         require_login();
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
     if (!empty($to)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-            error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     //Check necessary functions exists. Thanks to gregb@crowncollege.edu
@@ -96,7 +96,7 @@
 
     //Get and check course
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID was incorrect (can't find it)");
+        print_error("Course ID was incorrect (can't find it)");
     }
 
     //Print header
index 8b26f7ab13fcbdbc29ddb9cfb47fbfe0c0e7ed48..3ac2d23da4ee6c425d4a1d76aa0552f2cf4d4687 100644 (file)
@@ -7,16 +7,16 @@
     if (!empty($course->id)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
             if (empty($to)) {
-                error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
             } else {
                 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-                    error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                    print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
     if ($count == 0) {
         notice("No backupable modules are installed!");
     }
 
     if (!execute_sql("DELETE FROM {$CFG->prefix}backup_ids WHERE backup_code = '{$backupprefs->backup_unique_code}'",false)){
-        error('Couldn\'t delete previous backup ids.');
+        print_error('Couldn\'t delete previous backup ids.');
     }
 
 ?>
index 16abc3a81ccb42e7534b2adda59b779fca283b53..65fada8ab7746a948db94e79587ca7113a65ff61 100644 (file)
@@ -7,23 +7,23 @@
     if (!empty($course->id)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
             if (empty($to)) {
-                error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
             } else {
                 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-                    error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                    print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     $preferences = new StdClass;
index d16477508461f031d7d13d6bcf71690b50b733cf..934eff03ca2722d456b6da374e3479749cc64f5a 100644 (file)
@@ -7,22 +7,22 @@
     if (!empty($course->id)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
             if (empty($to)) {
-                error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
             } else {
                 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-                    error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                    print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     //Checks for the required files/functions to backup every mod
index 1d9cfa12e82521af7e003ccb14d19e3bce2bfc2c..f54eef308d1434dc7a849c67be1f26b4126607ac 100644 (file)
                     }
                 }
                 } else {
-                    error("Upgrade of backup system failed! (Could not update version in config table)");
+                    print_error("Upgrade of backup system failed! (Could not update version in config table)");
                 }
             } else {
-                error("Backup tables could NOT be set up successfully!");
+                print_error("Backup tables could NOT be set up successfully!");
             }
         }
 
                     }
                 }
                 } else {
-                    error("Upgrade of backup system failed! (Could not update version in config table)");
+                    print_error("Upgrade of backup system failed! (Could not update version in config table)");
                 }
             } else {
-                error("Upgrade failed!  See backup/version.php");
+                print_error("Upgrade failed!  See backup/version.php");
             }
 
         } else if ($backup_version < $CFG->backup_version) {
 
         if(!function_exists('utf8_encode')) {
             if (empty($justcheck)) {
-                error('You need to add XML support to your PHP installation');
+                print_error('You need to add XML support to your PHP installation');
             } else {
                 return false;
             }
index 0e4d82c2986cbd14fd4410c37cb34f09b2d966e2..826bb96ce5727bfd894bf24df9828b75fc00f06e 100644 (file)
         require_login($id);
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
             if (empty($to)) {
-                error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
             } else {
                 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
                     && !has_capability('moodle/site:import',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                    print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     //Check necessary functions exists. Thanks to gregb@crowncollege.edu
 
     //Get and check course
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID was incorrect (can't find it)");
+        print_error("Course ID was incorrect (can't find it)");
     }
 
     //Print header
     } else if ($launch == "execute") {
         //Prevent multiple restore executions...
         if (empty($SESSION->cancontinue)) {
-            error("Multiple restore execution not allowed!");
+            print_error("Multiple restore execution not allowed!");
         }
         //Unset this for the future
         unset($SESSION->cancontinue);
index 58ceac76f100fcf7e6d11f7e31124037bf281f38..710b708139375e8e29a1618b7a4d5b11a08db5e1 100644 (file)
@@ -45,7 +45,7 @@
 
     // check for session objects
     if (empty($info) or empty($course_header)) {
-      error( 'important information missing from SESSION' );
+      print_error( 'important information missing from SESSION' );
     }
 
 
     //Check admin
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
-            error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     //Depending the selected restoreto:
     } else if ((($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id != 0)) or ($restore->restoreto == 2)) {
         //Final access control check
         if ($restore->course_id == 0 and !user_can_create_courses()) {
-            error("You need to be a creator or admin to restore into new course!");
+            print_error("You need to be a creator or admin to restore into new course!");
         } else if ($restore->course_id != 0 and !has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $restore->course_id))) {
-            error("You need to be an edit teacher or admin to restore into selected course!");
+            print_error("You need to be an edit teacher or admin to restore into selected course!");
         }
         $show_continue_button = true;
         //Check if we've selected any mod's user info and restore->users
index 3406d7777cbf64f76f3cd3a62ff6bb5c217a69df..d87a8fc9d987cbc886f15b7abd9e094b28f4bf48 100644 (file)
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
             if (empty($to)) {
-                error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
             } else {
                 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to)) 
                     && !has_capability('moodle/site:import',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                    print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
     $errorstr = '';
 
     $status = restore_execute($restore,$info,$course_header,$errorstr);
 
     if (!$status) {
-        error ("An error has occurred and the restore could not be completed!");
+        print_error ("An error has occurred and the restore could not be completed!");
     }
 
     if (empty($restore->importing)) {
index 9ee95c35d05689b1e88b1b337708b1026b9085c8..31fb63d28ea6fcb9fd8ef2afeb2104e4642704a2 100644 (file)
@@ -6,10 +6,10 @@
 
     //Get objects from session
     if (!($info = $SESSION->info)) {
-      error( 'info object missing from session' );
+      print_error( 'info object missing from session' );
     }
     if (!($course_header = $SESSION->course_header)) {
-      error( 'course_header object missing from session' );
+      print_error( 'course_header object missing from session' );
     }
 
     $restore_gradebook_history =  optional_param('restore_gradebook_history', 0, PARAM_INT);
     //Check admin
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
-            error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
         }
     }
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     //Checks for the required files/functions to restore every mod
@@ -757,4 +757,4 @@ function restore_is_samerole($testroleid, $rolefromxml) {
     }
     return true;
 }
-?>
\ No newline at end of file
+?>
index 2f213a4ec92ea2604c8ad58d617edc3e342dfc41..a63ab16938031dbce3d3693ce3eca4d74222e558 100644 (file)
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
             if (empty($to)) {
-                error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
             } else {
                 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
                     && !has_capability('moodle/site:import',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+                    print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-            error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");   
+            print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");   
         }
     }
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     $errorstr = '';
@@ -42,7 +42,7 @@
     $status = restore_precheck($id,$file,$errorstr);
  
     if (!$status) {
-        error("An error occured");
+        print_error("An error occured");
     }
 
 ?>
index 70207df345e8664a4e149264e4c19140ffa80f2a..424e46fffb0c2c7048b38409913f44f92bcc3b62 100644 (file)
@@ -2426,7 +2426,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3);
                     } else {
                         // should not happen, as we check in restore_chech.php
                         // but handle the error if it does
-                        error("This backup file contains external Moodle Network Hosts that are not configured locally.");
+                        print_error("This backup file contains external Moodle Network Hosts that are not configured locally.");
                     }
                 }
                 unset($user->mnethosturl);
@@ -6925,7 +6925,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3);
 
     /**
      * @param string $errorstr passed by reference, if silent is true,
-     * errorstr will be populated and this function will return false rather than calling error() or notify()
+     * errorstr will be populated and this function will return false rather than calling print_error() or notify()
      * @param boolean $noredirect (optional) if this is passed, this function will not print continue, or
      * redirect to the next step in the restore process, instead will return $backup_unique_code
      */
@@ -7951,7 +7951,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3);
         //Open file for writing
         //First, we check the course_id backup data folder exists and create it as necessary in CFG->dataroot
         if (!$dest_dir = make_upload_directory("$restore->course_id/backupdata")) {   // Backup folder
-            error("Could not create backupdata folder.  The site administrator needs to fix the file permissions");
+            print_error("Could not create backupdata folder.  The site administrator needs to fix the file permissions");
         }
         $status = check_dir_exists($dest_dir,true);
         $restorelog_file = fopen("$dest_dir/restorelog.html","a");
index 92960c015e641cfb719b28f6c03c75196c6966e7..16d0c0e077d10871bc0f48f0dbcad55ec0ac5d7a 100644 (file)
@@ -11,7 +11,7 @@
 
     //Check site
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     //Check necessary functions exists. Thanks to gregb@crowncollege.edu
index 049722c0061f20a95db5da608df8b2e27f53b03d..ad4c0d26681ec186c9646e39fc15abc9dac3e326 100644 (file)
@@ -27,7 +27,7 @@ if (isset($_SERVER['HTTP_REFERER'])) {
 
 // Ensure that the logged in user is not using the guest account
 if (isguest()) {
-    error(get_string('noguestpost', 'forum'), $referrer);
+    print_error('noguestpost', 'forum', $referrer);
 }
 
 
@@ -99,14 +99,15 @@ if (isset($rss_record)) {
 if ($act == 'updfeed') {
 
     if (!$managefeeds) {
-        error(get_string('noguestpost', 'forum').
-                ' You are not allowed to make modifications to this RSS feed at this time.',
-                $referrer);
+        //print_error(get_string('noguestpost', 'forum').
+        //        ' You are not allowed to make modifications to this RSS feed at this time.',
+        //        $referrer);
+        print_error('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.');
     }
 
 
     if (empty($url)) {
-        error( 'URL not defined for rss feed' );
+        print_error( 'URL not defined for rss feed' );
     }
 
     // By capturing the output from fetch_rss this way
@@ -141,7 +142,7 @@ if ($act == 'updfeed') {
     $dataobject->url = addslashes($url);
 
     if (!update_record('block_rss_client', $dataobject)) {
-        error('There was an error trying to update rss feed with id:'. $rssid);
+        print_error('There was an error trying to update rss feed with id:'. $rssid);
     }
 
     $message .= '<br />'. get_string('feedupdated', 'block_rss_client');
@@ -153,11 +154,11 @@ if ($act == 'updfeed') {
     $canaddsharedfeeds = has_capability('block/rss_client:createsharedfeeds', $context);
 
     if (!$canaddprivfeeds && !$canaddsharedfeeds) {
-        error('You do not have the permission to add RSS feeds');
+        print_error('You do not have the permission to add RSS feeds');
     }
 
     if (empty($url)) {
-        error('URL not defined for rss feed');
+        print_error('URL not defined for rss feed');
     }
     $dataobject->userid = $USER->id;
     $dataobject->description = '';
@@ -173,7 +174,7 @@ if ($act == 'updfeed') {
 
     $rssid = insert_record('block_rss_client', $dataobject);
     if (!$rssid) {
-        error('There was an error trying to add a new rss feed:'. $url);
+        print_error('There was an error trying to add a new rss feed:'. $url);
     }
 
     // By capturing the output from fetch_rss this way
@@ -199,7 +200,7 @@ if ($act == 'updfeed') {
             $dataobject->title = addslashes($rss->channel['title']);
         }
         if (!update_record('block_rss_client', $dataobject)) {
-            error('There was an error trying to update rss feed with id:'. $rssid);
+            print_error('There was an error trying to update rss feed with id:'. $rssid);
         }
         $message .= '<br />'. get_string('feedadded', 'block_rss_client');
     }
@@ -222,9 +223,10 @@ if ($act == 'updfeed') {
 } else if ($act == 'delfeed') {
 
     if (!$managefeeds) {
-        error(get_string('noguestpost', 'forum').
-                ' You are not allowed to make modifications to this RSS feed at this time.',
-                $referrer);
+        //print_error(get_string('noguestpost', 'forum').
+        //        ' You are not allowed to make modifications to this RSS feed at this time.',
+        //        $referrer);
+        print_error('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.');
     }
 
     $file = $CFG->dataroot .'/cache/rsscache/'. $rssid .'.xml';
index 7e6366d99dd15171863b358df02c68e2190d842a..2d4fca3b62c9b17c4913cfc75c2a8902a1ce14bf 100644 (file)
@@ -57,7 +57,7 @@ class page_blog extends page_base {
             $courserecord = NULL;
         } else {
             if (! ($courserecord = get_record('course', 'id', $this->courseid)) ) {
-                error( 'You are tring to view an invalid course. Id: ('. $this->courseid .')' );
+                print_error( 'You are tring to view an invalid course. Id: ('. $this->courseid .')' );
             }
         }
         $this->full_init_done = true;
index ee2b426c09d505b489a31e689f75bc7326954fcb..0e858febfaba69288cde7c295afcb2fe3bc98260 100755 (executable)
@@ -12,32 +12,32 @@ $courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tab - d
 require_login($courseid);
 
 if (empty($CFG->bloglevel)) {
-    error('Blogging is disabled!');
+    print_error('Blogging is disabled!');
 }
 
 if (isguest()) {
-    error(get_string('noguestpost', 'blog'));
+    print_error('noguestpost', 'blog');
 }
 
 $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
 if (!has_capability('moodle/blog:create', $sitecontext) and !has_capability('moodle/blog:manageentries', $sitecontext)) {
-    error('You can not post or edit blogs.');
+    print_error('You can not post or edit blogs.');
 }
 
 // Make sure that the person trying to edit have access right
 if ($id) {
     if (!$existing = get_record('post', 'id', $id)) {
-        error('Wrong blog post id');
+        print_error('Wrong blog post id');
     }
 
     if (!blog_user_can_edit_post($existing)) {
-        error(get_string('notallowedtoedit', 'blog'));
+        print_error('notallowedtoedit', 'blog');
     }
     $userid    = $existing->userid;
     $returnurl = $CFG->wwwroot.'/blog/index.php?userid='.$existing->userid;
 } else {
     if (!has_capability('moodle/blog:create', $sitecontext)) {
-        error(get_string('nopost', 'blog')); // manageentries is not enough for adding
+        print_error('nopost', 'blog'); // manageentries is not enough for adding
     }
     $existing  = false;
     $userid    = $USER->id;
@@ -52,7 +52,7 @@ $strblogs = get_string('blogs','blog');
 
 if ($action=='delete'){
     if (!$existing) {
-        error('Incorrect blog post id');
+        print_error('Incorrect blog post id');
     }
     if (data_submitted() and $confirm and confirm_sesskey()) {
         do_delete($existing);
@@ -83,12 +83,12 @@ if ($blogeditform->is_cancelled()){
 
         case 'edit':
             if (!$existing) {
-                error('Incorrect blog post id');
+                print_error('Incorrect blog post id');
             }
             do_edit($fromform, $blogeditform);
         break;
         default :
-            error('Unknown action!');
+            print_error('Unknown action!');
     }
     redirect($returnurl);
 }
@@ -105,7 +105,7 @@ switch ($action) {
 
     case 'edit':
         if (!$existing) {
-            error('Incorrect blog post id');
+            print_error('Incorrect blog post id');
         }
         $post->id           = $existing->id;
         $post->subject      = $existing->subject;
@@ -124,12 +124,12 @@ switch ($action) {
         }
     break;
     default :
-        error('Unknown action!');
+        print_error('Unknown action!');
 }
 
 // done here in order to allow deleting of posts with wrong user id above
 if (!$user = get_record('user', 'id', $userid)) {
-    error('Incorrect user id');
+    print_error('Incorrect user id');
 }
 $navlinks = array();
 $navlinks[] = array('name' => fullname($user), 'link' => "$CFG->wwwroot/user/view.php?id=$userid", 'type' => 'misc');
@@ -164,7 +164,7 @@ function do_delete($post) {
     add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id);
 
     if (!$status) {
-        error('Error occured while deleting post', $returnurl);
+        print_error('Error occured while deleting post', '', $returnurl);
     }
 }
 
@@ -191,7 +191,7 @@ function do_add($post, $blogeditform) {
         add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject);
 
     } else {
-        error('There was an error adding this post in the database', $returnurl);
+        print_error('There was an error adding this post in the database', '', $returnurl);
     }
 
 }
@@ -226,7 +226,7 @@ function do_edit($post, $blogeditform) {
         add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$USER->id.'&postid='.$post->id, $post->subject);
 
     } else {
-        error('There was an error updating this post in the database', $returnurl);
+        print_error('There was an error updating this post in the database', '', $returnurl);
     }
 }
 
index deb58421fc68f34d624124b08830577d78d002f3..7835ede37ca349dd123ce44af45d7676249269ed 100755 (executable)
@@ -17,7 +17,7 @@ blog_check_and_install_blocks();
 
 
 if (!$course = get_record('course', 'id', $courseid)) {
-    error('The course number was incorrect ('. $courseid .')');
+    print_error('The course number was incorrect ('. $courseid .')');
 }
 
 // Bounds for block widths
@@ -99,7 +99,7 @@ $tagstring = get_string('tag');
 
 // needed also for user tabs later
 if (!$course = get_record('course', 'id', $courseid)) {
-    error('Wrong course id');
+    print_error('Wrong course id');
 }
 
 $navlinks = array();
@@ -165,7 +165,7 @@ $navlinks = array();
         case 'user':
             $participants = get_string('participants');
             if (!$user = get_record('user', 'id', $filterselect)) {
-               error('Wrong user id');
+               print_error('Wrong user id');
             }
 
             if ($course->id != SITEID) {
index f0b21b2a3a0407cbee8910b107d15e51f9a77871..71ea5b705065de2825c702e8a151bbad99e06c19 100755 (executable)
@@ -24,7 +24,7 @@ $courseid     = optional_param('courseid', 0, PARAM_INT); // needed for user tab
 
 
 if (empty($CFG->bloglevel)) {
-    error('Blogging is disabled!');
+    print_error('Blogging is disabled!');
 }
 
 $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
@@ -55,48 +55,48 @@ switch ($filtertype) {
 
     case 'site':
         if ($CFG->bloglevel < BLOG_SITE_LEVEL) {
-            error('Site blogs is not enabled');
+            print_error('Site blogs is not enabled');
         }
         if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
             require_login();
         }
         if (!has_capability('moodle/blog:view', $sitecontext)) {
-            error('You do not have the required permissions to view all site blogs');
+            print_error('You do not have the required permissions to view all site blogs');
         }
     break;
 
     case 'course':
         if ($CFG->bloglevel < BLOG_COURSE_LEVEL) {
-            error('Course blogs is not enabled');
+            print_error('Course blogs is not enabled');
         }
         if (!$course = get_record('course', 'id', $filterselect)) {
-            error('Incorrect course id specified');
+            print_error('Incorrect course id specified');
         }
         $courseid = $course->id;
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
         require_login($course);
         if (!has_capability('moodle/blog:view', $coursecontext)) {
-            error('You do not have the required permissions to view blogs in this course');
+            print_error('You do not have the required permissions to view blogs in this course');
         }
     break;
 
     case 'group':
         if ($CFG->bloglevel < BLOG_GROUP_LEVEL) {
-            error('Group blogs is not enabled');
+            print_error('Group blogs is not enabled');
         }
         
         // fix for MDL-9268
         if (! $group = groups_get_group($filterselect)) { //TODO:check.
-            error('Incorrect group id specified');
+            print_error('Incorrect group id specified');
         }
         if (!$course = get_record('course', 'id', $group->courseid)) {
-            error('Incorrect course id specified');
+            print_error('Incorrect course id specified');
         }
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
         $courseid = $course->id;
         require_login($course);
         if (!has_capability('moodle/blog:view', $coursecontext)) {
-            error('You do not have the required permissions to view blogs in this course/group');
+            print_error('You do not have the required permissions to view blogs in this course/group');
         }
         if (groups_get_course_groupmode($course) == SEPARATEGROUPS
           and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
@@ -109,24 +109,24 @@ switch ($filtertype) {
 
     case 'user':
         if ($CFG->bloglevel < BLOG_USER_LEVEL) {
-            error('Blogs is not enabled');
+            print_error('Blogs is not enabled');
         }
         if (!$user = get_record('user', 'id', $filterselect)) {
-            error('Incorrect user id');
+            print_error('Incorrect user id');
         }
         if ($USER->id == $filterselect) {
             if (!has_capability('moodle/blog:create', $sitecontext)
               and !has_capability('moodle/blog:view', $sitecontext)) {
-                error('You do not have your own blog, sorry.');
+                print_error('You do not have your own blog, sorry.');
             }
         } else {
             $personalcontext = get_context_instance(CONTEXT_USER, $filterselect);
             if (!has_capability('moodle/blog:view', $sitecontext) 
               and !has_capability('moodle/user:readuserblogs', $personalcontext)) {
-                error('You do not have the required permissions to read user blogs');
+                print_error('You do not have the required permissions to read user blogs');
             }
             if (!blog_user_can_view_user_post($filterselect)) {
-                error('You can not view blog of this user, sorry.');
+                print_error('You can not view blog of this user, sorry.');
             }
         }
         $userid = $filterselect;
@@ -138,7 +138,7 @@ switch ($filtertype) {
     break;
 
     default:
-        error('Incorrect blog filter type specified');
+        print_error('Incorrect blog filter type specified');
     break;
 }
 
index 3f5fdce78d2655c34de67a79dac0f991af0c6391..81daa68b4147f59b0b1a3759d8632db8c97d98ff 100755 (executable)
@@ -15,7 +15,7 @@
     }
 
     if (empty($CFG->bloglevel)) {
-        error('Blogging is disabled!');
+        print_error('Blogging is disabled!');
     }
 
     require_capability('moodle/blog:view', $context);
@@ -26,7 +26,7 @@
         $pagesize = required_param('pagesize', PARAM_INT);
 
         if ($pagesize < 1) {
-            error('invalid page size');
+            print_error('invalid page size');
         }
         set_user_preference('blogpagesize', $pagesize);
 
index ac650ac8106c13fbbe753e27f0c7c861e7a58d01..3fe21b87e888cdee57c5a7d3ae11ffc60aec0067 100644 (file)
             $title = get_string('deleteevent', 'calendar');
             $event = get_record('event', 'id', $eventid);
             if($event === false) {
-                error('Invalid event');
+                print_error('Invalid event');
             }
             if(!calendar_edit_event_allowed($event)) {
-                error('You are not authorized to do this');
+                print_error('You are not authorized to do this');
             }
         break;
 
             $repeats = optional_param('repeats', 0, PARAM_INT);
 
             if($event === false) {
-                error('Invalid event');
+                print_error('Invalid event');
             }
             if(!calendar_edit_event_allowed($event)) {
-                error('You are not authorized to do this');
+                print_error('You are not authorized to do this');
             }
 
             if($form = data_submitted()) {
                     $form->timeduration = 0;
                 }
                 if(!calendar_add_event_allowed($form)) {
-                    error('You are not authorized to do this');
+                    print_error('You are not authorized to do this');
                 }
                 validate_form($form, $err);
                 if (count($err) == 0) {
                 case 'select':
                 break;
                 default:
-                    error('Unsupported event type');
+                    print_error('Unsupported event type');
             }
 
             $form->format = $defaultformat;
                     $courseid = SITEID;
                 }
                 if (!$course = get_record('course', 'id', $courseid)) {
-                    error('Incorrect course ID');
+                    print_error('Incorrect course ID');
                 }
                 
                 $groupid = groups_get_course_group($course);
@@ -593,7 +593,7 @@ function validate_form(&$form, &$err) {
         // Timestamps must be >= course startdate
         $course = get_record('course', 'id', $form->courseid);
         if($course === false) {
-            error('Event belongs to invalid course');
+            print_error('Event belongs to invalid course');
         }
         else if($form->timestart < $course->startdate) {
             $err['timestart'] = get_string('errorbeforecoursestart', 'calendar');
index 73b4a90c9db8192845276df8176fd91bfa656323..7038eb10ac7bd11cdd78c2e303baed6d63c89f41 100644 (file)
@@ -431,7 +431,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
                     // TODO: rewrite this hack somehow
                     if (!calendar_edit_event_allowed($event)){ // cannot manage entries, eg. student  
                         if(!$assignment = get_record('assignment','id',$event->instance)){
-                            // error("assignment ID was incorrect");
+                            // print_error("assignment ID was incorrect");
                             continue;
                         }
                         // assign assignment to assignment object to use hidden_is_hidden method
index 7cac89ee24adc261a957a7c88bec2b620f526986..8ea03e539b029b846df4a31b878ac37616b04699 100644 (file)
     }
 
     if (!$site = get_site()) {
-        error("Site isn't defined!");
+        print_error("Site isn't defined!");
     }
 
     if (empty($id)) {
-        error("Category not known!");
+        print_error("Category not known!");
     }
 
     if (!$context = get_context_instance(CONTEXT_COURSECAT, $id)) {
-        error("Category not known!");
+        print_error("Category not known!");
     }
 
     if (!$category = get_record("course_categories", "id", $id)) {
-        error("Category not known!");
+        print_error("Category not known!");
     }
 
     if (has_capability('moodle/course:create', $context)) {
@@ -49,7 +49,7 @@
 
     } else {
         if (!$category->visible) {
-            error(get_string('notavailable', 'error'));
+            print_error('notavailable', 'error');
         }
         $navbaritem = print_course_search("", true, "navbar");
         $adminediting = false;
             require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto));
 
             if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
-                error("Error finding the category");
+                print_error("Error finding the category");
             }
 
 
index 02ed485bcae5026a9989bce3697502fda9246482..697edf06885ec098530eae8aa3f0bfb34b57fa77 100644 (file)
@@ -9,11 +9,11 @@
     require_login();
 
     if (!can_delete_course($id)) {
-        error('You do not have the permission to delete this course.');
+        print_error('You do not have the permission to delete this course.');
     }
 
     if (!$site = get_site()) {
-        error("Site not found!");
+        print_error("Site not found!");
     }
 
     $strdeletecourse = get_string("deletecourse");
@@ -21,7 +21,7 @@
     $strcategories = get_string("categories");
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID was incorrect (can't find it)");
+        print_error("Course ID was incorrect (can't find it)");
     }
 
     $category = get_record("course_categories", "id", $course->category);
     }
 
     if ($delete != md5($course->timemodified)) {
-        error("The check variable was wrong - try again");
+        print_error("The check variable was wrong - try again");
     }
 
     if (!confirm_sesskey()) {
-        error(get_string('confirmsesskeybad', 'error'));
+        print_error('confirmsesskeybad', 'error');
     }
 
     // OK checks done, delete the course now.
index 4e1135707c5e1315ace3aee79c3dc07d5418bb4c..46ded6b77ce7fc131c8f43e83e08666f29f6b0a4 100644 (file)
 
         if($id == SITEID){
             // don't allow editing of  'site course' using this from
-            error('You cannot edit the site course using this form');
+            print_error('You cannot edit the site course using this form');
         }
 
         if (!$course = get_record('course', 'id', $id)) {
-            error('Course ID was incorrect');
+            print_error('Course ID was incorrect');
         }
         require_login($course->id);
         $category = get_record('course_categories', 'id', $course->category);
         $course = null;
         require_login();
         if (!$category = get_record('course_categories', 'id', $categoryid)) {
-            error('Category ID was incorrect');
+            print_error('Category ID was incorrect');
         }
         require_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id));
     } else {
         require_login();
-        error('Either course id or category must be specified');
+        print_error('Either course id or category must be specified');
     }
 
 /// prepare course
index 0b60a3d69fb744411ee5942e3e31be00eeb7fa3d..cb4f284b0bf63f9960b099fef66e62be6672f0f0 100644 (file)
@@ -22,7 +22,7 @@ $categoryupdate = optional_param('categoryupdate', 0, PARAM_BOOL); // Enables th
 $resort         = optional_param('resort', 0, PARAM_BOOL);
 
 if (!$site = get_site()) {
-    error("Site isn't defined!");
+    print_error("Site isn't defined!");
 }
 
 if ($categoryadd) { // Show Add category form: if $id is given, it is used as the parent category 
@@ -33,7 +33,7 @@ if ($categoryadd) { // Show Add category form: if $id is given, it is used as th
     $strtitle = get_string("editcategorysettings");
     $context = get_context_instance(CONTEXT_COURSECAT, $id); 
     if (!$category = get_record("course_categories", "id", $id)) {
-        error("Category not known!");
+        print_error("Category not known!");
     }
 }
 
@@ -83,7 +83,7 @@ if ($mform->is_cancelled()){
         }
 
         if (!update_record('course_categories', $newcategory)) {
-            error( "Could not update the category '$newcategory->name' ");
+            print_error( "Could not update the category '$newcategory->name' ");
         } else {
             if ($newcategory->parent == 0) {
                 $redirect_link = 'index.php?categoryedit=on';
@@ -117,7 +117,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
 
     } else {
         if (!$category->visible) {
-            error(get_string('notavailable', 'error'));
+            print_error('notavailable', 'error');
         }
         $navbaritem = print_course_search("", true, "navbar");
         $adminediting = false;
@@ -210,7 +210,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
             require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto));
 
             if (!$destcategory = get_record("course_categories", "id", $data->moveto)) {
-                error("Error finding the destination category");
+                print_error("Error finding the destination category");
             } 
             // TODO function to move the category
         }
index 6e9b848a6682524bc083e66d633cff30df016b23..7bb21abfb56a6c2e48f2d844f3c214edea054f02 100644 (file)
@@ -7,11 +7,11 @@
     $id = required_param('id',PARAM_INT);    // Week ID
 
     if (! $section = get_record("course_sections", "id", $id)) {
-        error("Course section is incorrect");
+        print_error("Course section is incorrect");
     }
 
     if (! $course = get_record("course", "id", $section->course)) {
-        error("Could not find the course!");
+        print_error("Could not find the course!");
     }
 
     require_login($course->id);
@@ -25,7 +25,7 @@
         $timenow = time();
 
         if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
-            error("Could not update the summary!");
+            print_error("Could not update the summary!");
         }
 
         add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
index 0ebb95e60aa26f67dc6190bcd0225543547a6392..8826778dafd441759d49742ea7daa7002ae73708 100644 (file)
     }
 
     if (! $course = get_record('course', 'id', $id) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     if (! $context = get_context_instance(CONTEXT_COURSE, $course->id) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
 /// do not use when in course login as
index a4ef5b4c7d6f1c3e1e0cec0209b936329e239931..98d346e116d975ba2ef1f32751888f218adf8d8b 100644 (file)
@@ -39,7 +39,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id);
 if (($marker >=0) and has_capability('moodle/course:setcurrentsection', $context) and confirm_sesskey()) {
     $course->marker = $marker;
     if (! set_field("course", "marker", $marker, "id", $course->id)) {
-        error("Could not mark that topic for this course");
+        print_error("Could not mark that topic for this course");
     }
 }
 
index d2df141caf247ca41d48d9d3f333fe09c034fd3a..3dc459d44b7fd8c70f84dbd8a93f4943ec61f40b 100644 (file)
@@ -44,7 +44,7 @@
     if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
        $course->marker = $marker;
        if (! set_field("course", "marker", $marker, "id", $course->id)) {
-           error("Could not mark that topic for this course");
+           print_error("Could not mark that topic for this course");
        }
     }
 
index 3c30c3832388f0e9e0497a40f8f6d37cefb4a116..f2dfaab811efc002fff19a963fd0569827e52d3a 100644 (file)
@@ -6,7 +6,7 @@
     $id = required_param('id', PARAM_INT);   // course id to import TO
 
     if (!$course = get_record('course', 'id', $id)) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     require_login($course->id);
index 8b593cacd2d8713c5f5d3d761f5c4456c95d4d1a..f15f467f4d75141fa2c1a92115cd52e08c9d650b 100644 (file)
     $strimportactivities = get_string('importactivities');
 
     if (! ($course = get_record("course", "id", $id)) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     if (!$site = get_site()){
-        error("Couldn't get site course");
+        print_error("Couldn't get site course");
     }
 
     require_login($course->id);
@@ -28,7 +28,7 @@
     $syscontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
 
     if (!has_capability('moodle/course:manageactivities', $tocontext)) {
-        error("You need do not have the required permissions to import activities to this course");
+        print_error("You need do not have the required permissions to import activities to this course");
     }
 
     // if we're not a course creator , we can only import from our own courses.
@@ -38,7 +38,7 @@
 
     if ($from = get_record('course', 'id', $fromcourse)) {
         if (!has_capability('moodle/course:manageactivities', $fromcontext)) {
-            error("You need to have the required permissions in the course you are importing data from, as well");
+            print_error("You need to have the required permissions in the course you are importing data from, as well");
         }
         if (!empty($filename) && file_exists($CFG->dataroot.'/'.$filename) && !empty($SESSION->import_preferences)) {
             $restore = backup_to_restore_array($SESSION->import_preferences);
index 231184f527926ec4d839a47109312d01344b0bff..e1e085fd950ed6ae6a17381154b8ccecec2929fb 100755 (executable)
@@ -9,7 +9,7 @@
     $id = required_param('id', PARAM_INT);    // Course id
 
     if (! $course = get_record('course', 'id', $id) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     require_login($course->id);
 
 
     if (!has_capability('moodle/course:managegroups', $context)) {
-        error("You do not have the required permissions to manage groups.");
+        print_error("You do not have the required permissions to manage groups.");
     }
 
     //if (!confirm_sesskey()) {
-    //    error(get_string('confirmsesskeybad', 'error'));
+    //    print_error('confirmsesskeybad', 'error');
     //}
 
       $strimportgroups = get_string("importgroups");
@@ -87,7 +87,7 @@
             if ( !(isset($required[$h]) or
                 isset($optionalDefaults[$h]) or
                 isset($optional[$h])) ) {
-                error(get_string('invalidfieldname', 'error', $h), 'index.php?id='.$id.'&amp;sesskey='.$USER->sesskey);
+                print_error('invalidfieldname', 'error', 'index.php?id='.$id.'&amp;sesskey='.$USER->sesskey, $h);
             }
             if ( isset($required[$h]) ) {
                 $required[$h] = 2;
@@ -96,7 +96,7 @@
         // check for required fields
         foreach ($required as $key => $value) {
             if ($value < 2) {
-                error(get_string('fieldrequired', 'error', $key), 'uploaduser.php?id='.$id.'&amp;sesskey='.$USER->sesskey);
+                print_error('fieldrequired', 'error', 'uploaduser.php?id='.$id.'&amp;sesskey='.$USER->sesskey, $key);
             }
         }
         $linenum = 2; // since header is line 1
                 foreach ($record as $name => $value) {
                     // check for required values
                     if (isset($required[$name]) and !$value) {
-                        error(get_string('missingfield', 'error', $name). " ".
-                              get_string('erroronline', 'error', $linenum) .". ".
-                              get_string('processingstops', 'error'),
-                              'uploaduser.php?sesskey='.$USER->sesskey);
+                        //error(get_string('missingfield', 'error', $name). " ".
+                        //      get_string('erroronline', 'error', $linenum) .". ".
+                        //      get_string('processingstops', 'error'),
+                        //      'uploaduser.php?sesskey='.$USER->sesskey);
+                        print_error('missingfield', 'error', 'uploaduser.php?sesskey='.$USER->sesskey, $name);
                     }
                     else if ($name == "groupname") {
                         $newgroup->name = addslashes($value);
index 845cd51a1bb24e859cf6c811d49582dbef10b712..f9d940599f42c7ccf21e8cf9ab67b54a0fb9ae91 100644 (file)
@@ -20,7 +20,7 @@
     }
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID was incorrect (can't find it)");
+        print_error("Course ID was incorrect (can't find it)");
     }
 
     require_login($course->id);
@@ -65,7 +65,7 @@
                 $addcourse = clean_param($addcourse, PARAM_INT);
                 set_time_limit(180);
                 if (!add_to_metacourse($course->id,$addcourse)) {
-                    error("Could not add the selected course to this meta course!");
+                    print_error("Could not add the selected course to this meta course!");
                 }
             }
         } else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
@@ -73,7 +73,7 @@
                 set_time_limit(180);
                 $removecourse = clean_param($removecourse, PARAM_INT);
                 if (! remove_from_metacourse($course->id,$removecourse)) {
-                    error("Could not remove the selected course from this meta course!");
+                    print_error("Could not remove the selected course from this meta course!");
                 }
             }
         } else if ($showall and confirm_sesskey()) {
index eb1f55494749ffdb992aed09ab398d377cb42563..fd8a4300d9ad57589f84ed9009418ba54972a247 100644 (file)
@@ -19,7 +19,7 @@
     $context = $sysctx;
 
     if (!$site = get_site()) {
-        error('Site isn\'t defined!');
+        print_error('Site isn\'t defined!');
     }
 
     if ($CFG->forcelogin) {
                 if ($childcats = get_records('course_categories', 'parent', $deletecat->id)) {
                     foreach ($childcats as $childcat) {
                         if (! set_field('course_categories', 'parent', $deletecat->parent, 'id', $childcat->id)) {
-                            error('Could not update a child category!', 'index.php');
+                            print_error('Could not update a child category!', 'index.php');
                         }
                     }
                 }
                     if ($childcourses = get_records('course', 'category', $deletecat->id)) {
                         foreach ($childcourses as $childcourse) {
                             if (! set_field('course', 'category', $deletecat->parent, 'id', $childcourse->id)) {
-                                error('Could not update a child course!', 'index.php');
+                                print_error('Could not update a child course!', 'index.php');
                             }
                         }
                     }
         unset($tempcat);
         $tempcat->name = get_string('miscellaneous');
         if (!$tempcat->id = insert_record('course_categories', $tempcat)) {
-            error('Serious error: Could not create a default category!');
+            print_error('Serious error: Could not create a default category!');
         }
         $tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id);
         mark_context_dirty('/'.SYSCONTEXTID);
index e5ecf3304f033ef73d3f7c000241f01e9608bb52..e3d1e7a92b2806dc145c4394ab9123be05aaf799 100644 (file)
@@ -9,16 +9,16 @@
     $name = optional_param('name', false, PARAM_RAW); // Course short name
 
     if (!$id and !$name) {
-        error("Must specify course id or short name");
+        print_error("Must specify course id or short name");
     }
 
     if ($name) {
         if (! $course = get_record("course", "shortname", $name) ) {
-            error("That's an invalid short course name");
+            print_error("That's an invalid short course name");
         }
     } else {
         if (! $course = get_record("course", "id", $id) ) {
-            error("That's an invalid course id");
+            print_error("That's an invalid course id");
         }
     }
 
@@ -30,7 +30,7 @@
 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     if ((!course_parent_visible($course) || (! $course->visible)) && !has_capability('moodle/course:viewhiddencourses', $context)) {
-        error(get_string('coursehidden'), $CFG->wwwroot .'/'); 
+        print_error('coursehidden', '', $CFG->wwwroot .'/'); 
     }  
     
     print_header(get_string("summaryof", "", $course->fullname));
index 231fc8dca60e6c1028b4702cf7f7cde99b797dcd..11f1259344db580a65d0c0a8a80cf645a0841aa7 100644 (file)
@@ -1169,7 +1169,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname
         }
         asort($modnames, SORT_LOCALE_STRING);
     } else {
-        error("No modules are installed!");
+        print_error("No modules are installed!");
     }
 
     if ($rawmods = get_course_mods($courseid)) {
@@ -1930,7 +1930,7 @@ function print_my_moodle() {
     global $USER, $CFG;
 
     if (empty($USER->id)) {
-        error("It shouldn't be possible to see My Moodle without being logged in.");
+        print_error("It shouldn't be possible to see My Moodle without being logged in.");
     }
 
     $courses  = get_my_courses($USER->id, 'visible DESC,sortorder ASC', array('summary'));
@@ -2511,7 +2511,7 @@ function course_in_meta ($course) {
  */
 function print_standard_coursemodule_settings($form, $features=null) {
     if (! $course = get_record('course', 'id', $form->course)) {
-        error("This course doesn't exist");
+        print_error("This course doesn't exist");
     }
     print_groupmode_setting($form, $course);
     if (!empty($features->groupings)) {
@@ -2527,12 +2527,12 @@ function print_groupmode_setting($form, $course=NULL) {
 
     if (empty($course)) {
         if (! $course = get_record('course', 'id', $form->course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
     }
     if ($form->coursemodule) {
         if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
         $groupmode = groups_get_activity_groupmode($cm);
     } else {
@@ -2560,12 +2560,12 @@ function print_grouping_settings($form, $course=NULL) {
 
     if (empty($course)) {
         if (! $course = get_record('course', 'id', $form->course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
     }
     if ($form->coursemodule) {
         if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
     } else {
         $cm = null;
@@ -2599,7 +2599,7 @@ function print_grouping_settings($form, $course=NULL) {
 function print_visible_setting($form, $course=NULL) {
     if (empty($course)) {
         if (! $course = get_record('course', 'id', $form->course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
     }
     if ($form->coursemodule) {
index 3bddfe5aaf6c9fa8e120d8acc613f474956f1750..91f8efc60fd3a208e5a764c4133d52848023c631 100644 (file)
@@ -46,7 +46,7 @@
     }
 
     if (! $course = get_record('course', 'id', $id)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
 /// User must be logged in
@@ -65,7 +65,7 @@
         require_login($course);
         require_capability('moodle/user:loginas', $coursecontext);
         if (!has_capability('moodle/course:view', $coursecontext, $userid, false)) {
-            error('This user is not in this course!');
+            print_error('This user is not in this course!');
         }
         if (has_capability('moodle/site:doanything', $coursecontext, $userid, false)) {
             print_error('nologinas');
index c230b3ea9d3e4ab1d5fb190535d2cf9585212cab..4e8b2ee312537fc07f6bc914cc18e6dc7522ae25 100644 (file)
@@ -58,7 +58,7 @@
                                 {$CFG->prefix}modules md
                            WHERE cm.id = '$update' AND
                                  md.id = cm.module")){
-            error('Invalid course module id!');
+            print_error('Invalid course module id!');
         }
         $returntomod = optional_param('return', 0, PARAM_BOOL);
         if (file_exists("../mod/$modname/mod_form.php")) {
 
         if (empty($mod->coursemodule)) { //add
             if (! $course = get_record("course", "id", $mod->course)) {
-                error("This course doesn't exist");
+                print_error("This course doesn't exist");
             }
             $mod->instance = '';
             $mod->coursemodule = '';
         } else { //delete and update
             if (! $cm = get_record("course_modules", "id", $mod->coursemodule)) {
-                error("This course module doesn't exist");
+                print_error("This course module doesn't exist");
             }
 
             if (! $course = get_record("course", "id", $cm->course)) {
-                error("This course doesn't exist");
+                print_error("This course doesn't exist");
             }
             $mod->instance = $cm->instance;
             $mod->coursemodule = $cm->id;
@@ -99,7 +99,7 @@
         if (file_exists($modlib)) {
             include_once($modlib);
         } else {
-            error("This module is missing important code! ($modlib)");
+            print_error("This module is missing important code! ($modlib)");
         }
         $addinstancefunction    = $mod->modulename."_add_instance";
         $updateinstancefunction = $mod->modulename."_update_instance";
                         include_once($moderr);
                         die;
                     }
-                    error("Could not update the $mod->modulename", "view.php?id=$course->id");
+                    print_error("Could not update the $mod->modulename", '', "view.php?id=$course->id");
                 }
                 if (is_string($return)) {
-                    error($return, "view.php?id=$course->id");
+                    print_error($return, '', "view.php?id=$course->id");
                 }
 
                 if (isset($mod->visible)) {
             case "add":
 
                 if (!course_allowed_module($course,$mod->modulename)) {
-                    error("This module ($mod->modulename) has been disabled for this particular course");
+                    print_error("This module ($mod->modulename) has been disabled for this particular course");
                 }
 
                 if (!isset($mod->name) || trim($mod->name) == '') {
                         include_once($moderr);
                         die;
                     }
-                    error("Could not add a new instance of $mod->modulename", "view.php?id=$course->id");
+                    print_error("Could not add a new instance of $mod->modulename", '', "view.php?id=$course->id");
                 }
                 if (is_string($return)) {
-                    error($return, "view.php?id=$course->id");
+                    print_error($return, '', "view.php?id=$course->id");
                 }
 
                 if (!isset($mod->groupmode)) { // to deal with pre-1.5 modules
                 // to each other, so we have to update one of them twice.
 
                 if (! $mod->coursemodule = add_course_module($mod) ) {
-                    error("Could not add a new course module");
+                    print_error("Could not add a new course module");
                 }
                 if (! $sectionid = add_mod_to_section($mod) ) {
-                    error("Could not add the new course module to that section");
+                    print_error("Could not add the new course module to that section");
                 }
 
                 if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
-                    error("Could not update the course module with the correct section");
+                    print_error("Could not update the course module with the correct section");
                 }
 
                 if (!isset($mod->visible)) {   // We get the section's visible field status
                            "$mod->modulename $mod->instance", $mod->coursemodule);
                 break;
             default:
-                error("No mode defined");
+                print_error("No mode defined");
 
         }
 
     if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
 
         if (! $cm = get_record("course_modules", "id", $USER->activitycopy)) {
-            error("The copied course module doesn't exist!");
+            print_error("The copied course module doesn't exist!");
         }
 
         if (!empty($movetosection)) {
             if (! $section = get_record("course_sections", "id", $movetosection)) {
-                error("This section doesn't exist");
+                print_error("This section doesn't exist");
             }
             $beforecm = NULL;
 
         } else {                      // normal moveto
             if (! $beforecm = get_record("course_modules", "id", $moveto)) {
-                error("The destination course module doesn't exist");
+                print_error("The destination course module doesn't exist");
             }
             if (! $section = get_record("course_sections", "id", $beforecm->section)) {
-                error("This section doesn't exist");
+                print_error("This section doesn't exist");
             }
         }
 
         require_capability('moodle/course:manageactivities', $context);
 
         if (!ismoving($section->course)) {
-            error("You need to copy something first!");
+            print_error("You need to copy something first!");
         }
 
         moveto_module($cm, $section, $beforecm);
         $id = required_param('id',PARAM_INT);
 
         if (! $cm = get_record("course_modules", "id", $id)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         require_login($cm->course); // needed to setup proper $COURSE
         }
 
         if (!set_field("course_modules", "indent", $cm->indent, "id", $cm->id)) {
-            error("Could not update the indent level on that course module");
+            print_error("Could not update the indent level on that course module");
         }
 
         if (SITEID == $cm->course) {
     } else if (!empty($hide) and confirm_sesskey()) {
 
         if (! $cm = get_record("course_modules", "id", $hide)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         require_login($cm->course); // needed to setup proper $COURSE
     } else if (!empty($show) and confirm_sesskey()) {
 
         if (! $cm = get_record("course_modules", "id", $show)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         require_login($cm->course); // needed to setup proper $COURSE
         require_capability('moodle/course:activityvisibility', $context);
 
         if (! $section = get_record("course_sections", "id", $cm->section)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if (! $module = get_record("modules", "id", $cm->module)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if ($module->visible and ($section->visible or (SITEID == $cm->course))) {
         $id = required_param( 'id', PARAM_INT );
 
         if (! $cm = get_record("course_modules", "id", $id)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         require_login($cm->course); // needed to setup proper $COURSE
     } else if (!empty($copy) and confirm_sesskey()) { // value = course module
 
         if (! $cm = get_record("course_modules", "id", $copy)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         require_login($cm->course); // needed to setup proper $COURSE
         require_capability('moodle/course:manageactivities', $context);
 
         if (! $section = get_record("course_sections", "id", $cm->section)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if (! $module = get_record("modules", "id", $cm->module)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if (! $instance = get_record($module->name, "id", $cm->instance)) {
-            error("Could not find the instance of this module");
+            print_error("Could not find the instance of this module");
         }
 
         $USER->activitycopy = $copy;
     } else if (!empty($delete) and confirm_sesskey()) {   // value = course module
 
         if (! $cm = get_record("course_modules", "id", $delete)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
 
         require_login($cm->course); // needed to setup proper $COURSE
         require_capability('moodle/course:manageactivities', $context);
 
         if (! $module = get_record("modules", "id", $cm->module)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if (! $instance = get_record($module->name, "id", $cm->instance)) {
             if (! delete_course_module($cm->id)) {
                 notify("Could not delete the $module->name (coursemodule)");
             }
-            error("The required instance of this module didn't exist.  Module deleted.",
+            print_error("The required instance of this module didn't exist.  Module deleted.",
                   "$CFG->wwwroot/course/view.php?id=$course->id");
         }
 
     } else if (!empty($update) and confirm_sesskey()) {   // value = course module
 
         if (! $cm = get_record("course_modules", "id", $update)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
 
         require_login($course->id); // needed to setup proper $COURSE
         require_capability('moodle/course:manageactivities', $context);
 
         if (! $module = get_record("modules", "id", $cm->module)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if (! $form = get_record($module->name, "id", $cm->instance)) {
-            error("The required instance of this module doesn't exist");
+            print_error("The required instance of this module doesn't exist");
         }
 
         if (! $cw = get_record("course_sections", "id", $cm->section)) {
-            error("This course section doesn't exist");
+            print_error("This course section doesn't exist");
         }
 
         if (isset($return)) {
 
 
         if (! $cm = get_record("course_modules", "id", $duplicate)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
 
         require_login($course->id); // needed to setup proper $COURSE
         require_capability('moodle/course:manageactivities', $context);
 
         if (! $module = get_record("modules", "id", $cm->module)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if (! $form = get_record($module->name, "id", $cm->instance)) {
-            error("The required instance of this module doesn't exist");
+            print_error("The required instance of this module doesn't exist");
         }
 
         if (! $cw = get_record("course_sections", "id", $cm->section)) {
-            error("This course section doesn't exist");
+            print_error("This course section doesn't exist");
         }
 
         if (isset($return)) {
         $section = required_param('section',PARAM_INT);
 
         if (! $course = get_record("course", "id", $id)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
 
         if (! $module = get_record("modules", "name", $add)) {
-            error("This module type doesn't exist");
+            print_error("This module type doesn't exist");
         }
 
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
         require_capability('moodle/course:manageactivities', $context);
 
         if (!course_allowed_module($course,$module->id)) {
-            error("This module has been disabled for this particular course");
+            print_error("This module has been disabled for this particular course");
         }
 
         require_login($course->id); // needed to setup proper $COURSE
         }
 
     } else {
-        error("No action was specified");
+        print_error("No action was specified");
     }
 
     require_login($course->id); // needed to setup proper $COURSE
index c55880f3cfd3503ec8ec2b475b74a269880e12d6..8d28a2bb46dda2ced395dd982f1031ac1727cbb0 100644 (file)
@@ -18,7 +18,7 @@
         $course = required_param('course', PARAM_INT);
 
         if (! $course = get_record("course", "id", $course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
 
         require_login($course);
         require_capability('moodle/course:manageactivities', $context);
 
         if (! $module = get_record("modules", "name", $add)) {
-            error("This module type doesn't exist");
+            print_error("This module type doesn't exist");
         }
 
         $cw = get_course_section($section, $course->id);
 
         if (!course_allowed_module($course, $module->id)) {
-            error("This module has been disabled for this particular course");
+            print_error("This module has been disabled for this particular course");
         }
 
         $cm = null;
         $navlinksinstancename = '';
     } else if (!empty($update)) {
         if (! $cm = get_record("course_modules", "id", $update)) {
-            error("This course module doesn't exist");
+            print_error("This course module doesn't exist");
         }
 
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("This course doesn't exist");
+            print_error("This course doesn't exist");
         }
 
         require_login($course); // needed to setup proper $COURSE
         require_capability('moodle/course:manageactivities', $context);
 
         if (! $module = get_record("modules", "id", $cm->module)) {
-            error("This module doesn't exist");
+            print_error("This module doesn't exist");
         }
 
         if (! $form = get_record($module->name, "id", $cm->instance)) {
-            error("The required instance of this module doesn't exist");
+            print_error("The required instance of this module doesn't exist");
         }
 
         if (! $cw = get_record("course_sections", "id", $cm->section)) {
-            error("This course section doesn't exist");
+            print_error("This course section doesn't exist");
         }
 
         $form->coursemodule     = $cm->id;
             $CFG->pagepath .= '/mod';
         }
     } else {
-        error('Invalid operation.');
+        print_error('Invalid operation.');
     }
 
     $modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
         require_once($modmoodleform);
 
     } else {
-        error('No formslib form description file found for this activity.');
+        print_error('No formslib form description file found for this activity.');
     }
 
     $modlib = "$CFG->dirroot/mod/$module->name/lib.php";
     if (file_exists($modlib)) {
         include_once($modlib);
     } else {
-        error("This module is missing important code! ($modlib)");
+        print_error("This module is missing important code! ($modlib)");
     }
 
     $mformclassname = 'mod_'.$module->name.'_mod_form';
         if (empty($fromform->coursemodule)) { //add
             $cm = null;
             if (! $course = get_record("course", "id", $fromform->course)) {
-                error("This course doesn't exist");
+                print_error("This course doesn't exist");
             }
             $fromform->instance = '';
             $fromform->coursemodule = '';
         } else { //update
             if (! $cm = get_record("course_modules", "id", $fromform->coursemodule)) {
-                error("This course module doesn't exist");
+                print_error("This course module doesn't exist");
             }
 
             if (! $course = get_record("course", "id", $cm->course)) {
-                error("This course doesn't exist");
+                print_error("This course doesn't exist");
             }
             $fromform->instance = $cm->instance;
             $fromform->coursemodule = $cm->id;
 
             $returnfromfunc = $updateinstancefunction($fromform);
             if (!$returnfromfunc) {
-                error("Could not update the $fromform->modulename", "view.php?id=$course->id");
+                print_error("Could not update the $fromform->modulename", '', "view.php?id=$course->id");
             }
             if (is_string($returnfromfunc)) {
-                error($returnfromfunc, "view.php?id=$course->id");
+                print_error($returnfromfunc, '', "view.php?id=$course->id");
             }
 
             set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
             }
 
             if (!course_allowed_module($course,$fromform->modulename)) {
-                error("This module ($fromform->modulename) has been disabled for this particular course");
+                print_error("This module ($fromform->modulename) has been disabled for this particular course");
             }
 
             $returnfromfunc = $addinstancefunction($fromform);
             if (!$returnfromfunc) {
-                error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id");
+                print_error("Could not add a new instance of $fromform->modulename", '', "view.php?id=$course->id");
             }
             if (is_string($returnfromfunc)) {
-                error($returnfromfunc, "view.php?id=$course->id");
+                print_error($returnfromfunc, '', "view.php?id=$course->id");
             }
 
             $fromform->instance = $returnfromfunc;
             // to each other, so we have to update one of them twice.
 
             if (! $fromform->coursemodule = add_course_module($fromform) ) {
-                error("Could not add a new course module");
+                print_error("Could not add a new course module");
             }
             if (! $sectionid = add_mod_to_section($fromform) ) {
-                error("Could not add the new course module to that section");
+                print_error("Could not add the new course module to that section");
             }
 
             if (! set_field("course_modules", "section", $sectionid, "id", $fromform->coursemodule)) {
-                error("Could not update the course module with the correct section");
+                print_error("Could not update the course module with the correct section");
             }
 
             // make sure visibility is set correctly (in particular in calendar)
                        "view.php?id=$fromform->coursemodule",
                        "$fromform->instance", $fromform->coursemodule);
         } else {
-            error("Data submitted is invalid.");
+            print_error("Data submitted is invalid.");
         }
 
         // sync idnumber with grade_item
index c94e6ddb776767c68707f03ca16925c390f89361..086e9dceaba8a0cca22644f56918516599475b47 100644 (file)
@@ -9,7 +9,7 @@
     $id = required_param('id', PARAM_INT);
 
     if (!$course = get_record('course', 'id', $id) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     require_login($course);
@@ -46,7 +46,7 @@
 
     if (!empty($param->user)) {
         if (!$u = get_record('user', 'id', $param->user) ) {
-            error("That's an invalid user!");
+            print_error("That's an invalid user!");
         }
         $userinfo = fullname($u);
     }
index 515e0bb5d4d8d0e786859419441f601ce4fc020f..f024fce3267d45676164849100c964cb3f615014 100644 (file)
@@ -6,7 +6,7 @@
     $id = required_param('id', PARAM_INT);   // course id to import TO
 
     if (!$course = get_record('course', 'id', $id)) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     require_login($course->id);
index b2dd3117e4478caa14434dcbd696408d279fe49d..ef7309b18dec5c652d5c17c6ce50d6c04b50fe93 100644 (file)
@@ -11,7 +11,7 @@
     $date = optional_param('date', 0, PARAM_INT);  // A time of a day (in GMT)
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id);
 
     if (! (has_capability('moodle/site:viewreports', $context)
                 or ($course->showreports and $USER->id == $user)) ) {
-        error("Sorry, you aren't allowed to see this.");
+        print_error("Sorry, you aren't allowed to see this.");
     }
 
     if ($user) {
         if (! $user = get_record("user", "id", $user)) {
-            error("Can not find that user");
+            print_error("Can not find that user");
         }
     }
 
index 2c6030f53c236ab669d1bb8eff7abc150f80dd57..7cfd457b76b8601b519017e670b257a51b6fd306 100644 (file)
@@ -35,7 +35,7 @@
 
     if ($hostid == $CFG->mnet_localhost_id) {
         if (!$course = get_record('course', 'id', $id) ) {
-            error('That\'s an invalid course id'.$id);
+            print_error('That\'s an invalid course id'.$id);
         }
     } else {
         $course_stub       = array_pop(get_records_select('mnet_log', " hostid='$hostid' AND course='$id' ", '', '*', '', '1'));
@@ -66,7 +66,7 @@
 
         if ($user) {
             if (!$u = get_record('user', 'id', $user) ) {
-                error('That\'s an invalid user!');
+                print_error('That\'s an invalid user!');
             }
             $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
         }
index 9fd1961535e0e559158c99ea1b8a0f57b9d00d17..732abadf99d730fc123ac9643c469db29228e220 100644 (file)
@@ -8,14 +8,14 @@
     $page = optional_param('page', 0, PARAM_INT);     // which page to show
 
     if (! $course = get_record("course", "id", $id) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     require_login($course);
 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     if (!has_capability('moodle/site:viewreports', $context)) {
-        error('You need do not have the required permission to view this report');
+        print_error('You need do not have the required permission to view this report');
     }
 
     add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id); 
index 989543970fd2b4c36d8877334225095ec98a21ae..628cf0e61cdc5f646b5479793a4e491c55fea68b 100644 (file)
@@ -8,7 +8,7 @@
     $id = required_param('id',PARAM_INT);       // course id
 
     if (!$course = get_record('course', 'id', $id)) {
-        error('Course id is incorrect.');
+        print_error('Course id is incorrect.');
     }
 
     require_login($course);
@@ -32,7 +32,7 @@
     print_heading(format_string($course->fullname));
 
     if (!$logstart = get_field_sql("SELECT MIN(time) FROM {$CFG->prefix}log")) {
-        error('Logs not available');
+        print_error('Logs not available');
     }
 
     echo '<div class="loginfo">'.get_string('computedfromlogs', 'admin', userdate($logstart)).'</div>';
index 3444708b2dd15babb76fdb6efa8a98fa0d26bacc..34e51a9838da1381d29bece3de9188e8a7ec175c 100644 (file)
     $roleid   = optional_param('roleid',0,PARAM_INT);
 
     if (!$course = get_record("course","id",$courseid)) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     if (!empty($userid)) {
         if (!$user = get_record('user','id',$userid)) {
-            error("That's an invalid user id");
+            print_error("That's an invalid user id");
         }
     }
 
@@ -25,7 +25,7 @@
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
 
     if (!has_capability('moodle/site:viewreports', $context)) {
-        error('You need do not have the required permission to view reports for this course');
+        print_error('You need do not have the required permission to view reports for this course');
     }
 
     stats_check_uptodate($course->id);
index 0ab3fdf9cecfd06c3228d15f9ab492294e4f2245..7183df393b86d0c9c2d42f8ccd1cb42994ddb188 100644 (file)
@@ -5,7 +5,7 @@
     require_once($CFG->dirroot.'/course/report/stats/lib.php');
 
     if (empty($CFG->enablestats)) {
-        error("Stats is not enabled.");
+        print_error("Stats is not enabled.");
     }
 
     $courseid = required_param('course', PARAM_INT);
     }
 
     if (!$course = get_record("course","id",$courseid)) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     if (!empty($userid)) {
         if (!$user = get_record('user','id',$userid)) {
-            error("That's an invalid user id");
+            print_error("That's an invalid user id");
         }
     }
 
index fa5d2184854e65e695f18dafe126e5a8cfcd4a95..6093ac84191a404c20232e309149c7acccabd035 100644 (file)
@@ -14,7 +14,7 @@
     $reportoptions = stats_get_report_options($course->id, $mode);
     $timeoptions = report_stats_timeoptions($mode);
     if (empty($timeoptions)) {
-        error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
+        print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
     }
 
     $table->width = 'auto';
@@ -31,7 +31,7 @@
             .' ORDER BY u.lastname, u.firstname ASC';
 
         if (!$us = get_records_sql($sql)) {
-            error('Cannot enter detailed view: No users found for this course.');
+            print_error('Cannot enter detailed view: No users found for this course.');
         }
 
         foreach ($us as $u) {
@@ -68,7 +68,7 @@
 
     if (!empty($report) && !empty($time)) {
         if ($report == STATS_REPORT_LOGINS && $course->id != SITEID) {
-            error('This type of report is only available for the site course');
+            print_error('This type of report is only available for the site course');
         }
 
         $param = stats_get_parameters($time,$report,$course->id,$mode);
index 9af3d0ced372b30ee35c3092a5eff5914ffcf03f..7469cfdc4d887f227cd8f9a36ca14acd8f20a757 100644 (file)
@@ -8,7 +8,7 @@
     require_login();
 
     if (isguest()) {
-        error("No guests here!");
+        print_error("No guests here!");
     }
 
     if (empty($CFG->enablecourserequests)) {
index cf165cd51ccc05dfde25097fe69d2690435df9fc..61c07c205f0ef68a27d185b4d097628ed2f847d3 100755 (executable)
@@ -14,7 +14,7 @@ require_once('reset_form.php');
 $id = required_param('id', PARAM_INT);
 
 if (!$course = get_record('course', 'id', $id)) {
-    error("Course is misconfigured");
+    print_error("Course is misconfigured");
 }
 
 require_login($course);
index 3759a1f45e47eac92030a60208507c7a5da98fdf..1ea5a7884df6095cb6bc82c4b5449f68c03ab2e2 100644 (file)
@@ -7,7 +7,7 @@
     $id   = required_param('id', PARAM_INT);               // course id
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
     require_login($course);
index a497cee6985c07e4800b924d6208f820a60e9b93..215a7109e490e0bf19f09773e5be604c27d815c2 100644 (file)
     if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) {   // Some courses are being moved
 
         if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
-            error("Error finding the category");
+            print_error("Error finding the category");
         }
 
         $courses = array();
     if (!empty($blocklist) and confirm_sesskey()) {
         $blockid = $blocklist;
         if (!$blocks = get_records('block_instance', 'blockid', $blockid)) {
-            error( "Could not read data for blockid=$blockid" );
+            print_error( "Could not read data for blockid=$blockid" );
         }
 
         // run through blocks and get (unique) courses
                 continue;
             }
             if (!$course = get_record('course', 'id', $courseid)) {
-                error( "Could not read data for courseid=$courseid" );
+                print_error( "Could not read data for courseid=$courseid" );
             }
             $courses[$courseid] = $course;
         }
     elseif (!empty($modulelist) and confirm_sesskey()) {
         $modulename = $modulelist;
         if (!$modules = get_records($modulename)) {
-            error( "Could not read data for module=$modulename" );
+            print_error( "Could not read data for module=$modulename" );
         }
 
         // run through modules and get (unique) courses
                 continue;
             }
             if (!$course = get_record('course', 'id', $courseid)) {
-                error( "Could not read data for courseid=$courseid" );
+                print_error( "Could not read data for courseid=$courseid" );
             }
             $courses[$courseid] = $course;
         }
index 03617c3e30d6c4b57acae8d0da73e4c698168a7a..74e877defac2844d71258130f5f7a83880cda4e4 100644 (file)
     }
 
     if (! $course = get_record('course', 'id', $id) ) {
-        error('Invalid course id');
+        print_error('Invalid course id');
     }
 
     if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) {
-        error('Invalid context');
+        print_error('Invalid context');
     }
 
     require_login($course->id);
@@ -43,7 +43,7 @@
         // verify user may unassign all roles at course context
         foreach($roles as $role) {
             if (!user_can_assign($context, $role->roleid)) {
-                error('Can not unassign this user from role id:'.$role->roleid);
+                print_error('Can not unassign this user from role id:'.$role->roleid);
             }
         }
 
@@ -59,7 +59,7 @@
     if ($confirm and confirm_sesskey()) {
         if ($userid) {
             if (! role_unassign(0, $userid, 0, $context->id)) {
-                error("An error occurred while trying to unenrol that person.");
+                print_error("An error occurred while trying to unenrol that person.");
             }
 
             add_to_log($course->id, 'course', 'unenrol', "view.php?id=$course->id", $userid);
@@ -67,7 +67,7 @@
 
         } else {
             if (! role_unassign(0, $USER->id, 0, $context->id)) {
-                error("An error occurred while trying to unenrol you.");
+                print_error("An error occurred while trying to unenrol you.");
             }
 
             // force a refresh of mycourses
@@ -88,7 +88,7 @@
 
     if ($userid) {
         if (!$user = get_record('user', 'id', $userid)) {
-            error('That user does not exist!');
+            print_error('That user does not exist!');
         }
         $strunenrolsure  = get_string('unenrolsure', '', fullname($user, true));
         notice_yesno($strunenrolsure, "unenrol.php?id=$id&amp;user=$user->id&amp;confirm=yes&amp;sesskey=".sesskey(),
index 0707f9f337a46de9d4a8598c6701a3ef6531c47e..8768086eacdaa8ec498f9d8f56bbe3c56f4fa5fc 100644 (file)
     $perpage = optional_param('perpage', 100, PARAM_INT);
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course id is incorrect.");
+        print_error("Course id is incorrect.");
     }
 
     if (! $user = get_record("user", "id", $user)) {
-        error("User ID is incorrect");
+        print_error("User ID is incorrect");
     }
 
     //require_login($course);
@@ -29,7 +29,7 @@
 
     // if in either context, we can read report, then we can proceed
     if (!(has_capability('moodle/site:viewreports', $coursecontext) or ($course->showreports and $USER->id == $user->id) or has_capability('moodle/user:viewuseractivitiesreport', $personalcontext))) {
-        error("You are not allowed to look at this page");
+        print_error("You are not allowed to look at this page");
     }
 
     add_to_log($course->id, "course", "user report", "user.php?id=$course->id&amp;user=$user->id&amp;mode=$mode", "$user->id");
         case 'stats':
 
             if (empty($CFG->enablestats)) {
-                error("Stats is not enabled.");
+                print_error("Stats is not enabled.");
             }
 
             require_once($CFG->dirroot.'/lib/statslib.php');
             $timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
 
             if (empty($timeoptions)) {
-                error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
+                print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
             }
 
             // use the earliest.
             $stats = get_records_sql($sql);
 
             if (empty($stats)) {
-                error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
+                print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
             }
 
             // MDL-10818, do not display broken graph when user has no permission to view graph
index 4539d9c633c08f4ac9cf55b76d7a5d1b3ae98d3f..04f83fab402e4ffc048fce00d8f7308cc18292b5 100644 (file)
 
 
     if (empty($id) && empty($name) && empty($idnumber)) {
-        error("Must specify course id, short name or idnumber");
+        print_error("Must specify course id, short name or idnumber");
     }
 
     if (!empty($name)) {
         if (! ($course = get_record('course', 'shortname', $name)) ) {
-            error('Invalid short course name');
+            print_error('Invalid short course name');
         }
     } else if (!empty($idnumber)) {
         if (! ($course = get_record('course', 'idnumber', $idnumber)) ) {
-            error('Invalid course idnumber');
+            print_error('Invalid course idnumber');
         }
     } else {
         if (! ($course = get_record('course', 'id', $id)) ) {
-            error('Invalid course id');
+            print_error('Invalid course id');
         }
     }
 
             $section->id = insert_record('course_sections', $section);
         }
         if (! $sections = get_all_sections($course->id) ) {      // Try again
-            error('Error finding or creating section structures for this course');
+            print_error('Error finding or creating section structures for this course');
         }
     }
 
index 529e387dea8348bde8bbadbc6e96c36abdb161dd..60d4c4ce4d55a406bb8ad40e580c22f7a3cc7fa2 100755 (executable)
@@ -45,7 +45,7 @@ class enrolment_plugin_authorize
 
         if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 443) { // MDL-9836
             if (empty($CFG->loginhttps)) {
-                error(get_string('httpsrequired', 'enrol_authorize'));
+                print_error('httpsrequired', 'enrol_authorize');
             } else {
                 $wwwsroot = str_replace('http:','https:', $CFG->wwwroot);
                 redirect("$wwwsroot/course/enrol.php?id=$course->id");
@@ -92,7 +92,7 @@ class enrolment_plugin_authorize
                         break;
                 }
                 if (!empty($authorizeerror)) {
-                    error($authorizeerror);
+                    print_error($authorizeerror);
                 }
             }
             $frmenrol->display();
index 744fa4ab3f8c4ee161bfab220e0acfe9d94023b1..eea8655f5895d857d0a223cb7c366d462f2d1c1a 100755 (executable)
@@ -11,7 +11,7 @@ class enrol_authorize_form extends moodleform
         $paymentmethodsenabled = get_list_of_payment_methods();
         $paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA);
         if (!in_array($paymentmethod, $paymentmethodsenabled)) {
-            error("Invalid payment method: $paymentmethod");
+            print_error("Invalid payment method: $paymentmethod");
         }
 
         $mform =& $this->_form;
index ab4e53e6e2cebb4856364b1572c06a83c558cf2d..12d416756d1d7c37d0575031d74a6e3bb6d0e85c 100644 (file)
@@ -5,7 +5,7 @@
     require_once('const.php');
     require_once('locallib.php');
     require_once('localfuncs.php');
-    require_once('authorizenetlib.php');
+    require_once('authorizenet.class.php');
 
 /// Parameters
     $orderid  = optional_param('order', 0, PARAM_INT);
 
 /// Get course
     if (! $course = get_record('course', 'id', $courseid)) {
-        error('Could not find that course');
+        print_error('Could not find that course');
     }
 
 /// Only SITE users can access to this page
     require_login(); // Don't use $courseid! User may want to see old orders.
     if (has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) {
-        error("Guests cannot use this page.");
+        print_error("Guests cannot use this page.");
     }
 
     /// Load strings. All strings should be defined here. locallib.php uses these strings.
index c8291e814fd3ef8b9b2ca2e28770d7255b406aa4..09f3e42ae5311d02e3f8b1490f2700131e67f7c4 100644 (file)
@@ -92,10 +92,11 @@ function authorize_print_orders($courseid, $userid)
     if ($perpage > 100) { $perpage = 100; }
     $perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
     $perpagemenu = popup_form($baseurl.'&amp;status='.$status.'&amp;course='.$courseid.'&amp;perpage=',$perpagemenus,'perpagemenu',$perpage,'','','',true);
-    $table->define_columns(array('id', 'userid', 'timecreated', 'status', ''));
+    $table->define_columns(array('id', 'userid', 'timecreated', 'status', 'action'));
     $table->define_headers(array($authstrs->orderid, $authstrs->shopper, $strs->time, $strs->status, $perpagemenu));
     $table->define_baseurl($baseurl."&amp;status=$status&amp;course=$courseid&amp;perpage=$perpage");
 
+    $table->no_sorting('action');
     $table->sortable(true, 'id', SORT_DESC);
     $table->pageable(true);
     $table->setup();
@@ -210,15 +211,15 @@ function authorize_print_order($orderid)
     $confirm = optional_param('confirm', 0, PARAM_BOOL);
 
     if (!$order = get_record('enrol_authorize', 'id', $orderid)) {
-        error("Order $orderid not found.", "$CFG->wwwroot/enrol/authorize/index.php");
+        print_error("Order $orderid not found.", '', "$CFG->wwwroot/enrol/authorize/index.php");
     }
 
     if (!$course = get_record('course', 'id', $order->courseid)) {
-        error("Could not find that course id $order->courseid", "$CFG->wwwroot/enrol/authorize/index.php");
+        print_error("Could not find that course id $order->courseid", '', "$CFG->wwwroot/enrol/authorize/index.php");
     }
 
     if (!$user = get_record('user', 'id', $order->userid)) {
-        error("Could not find that user id $order->userid", "$CFG->wwwroot/enrol/authorize/index.php");
+        print_error("Could not find that user id $order->userid", '', "$CFG->wwwroot/enrol/authorize/index.php");
     }
 
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -226,7 +227,7 @@ function authorize_print_order($orderid)
         require_capability('enrol/authorize:managepayments', $coursecontext);
     }
 
-    $settled = authorize_settled($order);
+    $settled = AuthorizeNet::settled($order);
     $statusandactions = authorize_get_status_action($order);
     $color = authorize_get_status_color($statusandactions->status);
 
@@ -280,7 +281,7 @@ function authorize_print_order($orderid)
         if ($confirm && confirm_sesskey()) {
             $message = '';
             $extra = NULL;
-            if (AN_APPROVED == authorize_action($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) {
+            if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) {
                 if (empty($CFG->an_test)) {
                     if (enrol_into_course($course, $user, 'authorize')) {
                         if (!empty($CFG->enrol_mailstudents)) {
@@ -316,18 +317,18 @@ function authorize_print_order($orderid)
         }
         $upto = round($order->amount - $refunded, 2);
         if ($upto <= 0) {
-            error("Refunded to original amount: $order->amount", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
+            print_error("Refunded to original amount: $order->amount", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
         }
         $amount = round(optional_param('amount', $upto), 2);
         if ($amount > $upto) {
-            error("Can be refunded to $upto", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
+            print_error("Can be refunded to $upto", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
         }
         if ($confirm && confirm_sesskey()) {
             $extra = new stdClass;
             $extra->orderid = $orderid;
             $extra->amount = $amount;
             $message = '';
-            $success = authorize_action($order, $message, $extra, AN_ACTION_CREDIT);
+            $success = AuthorizeNet::process($order, $message, $extra, AN_ACTION_CREDIT);
             if (AN_APPROVED == $success || AN_REVIEW == $success) {
                 if (empty($CFG->an_test)) {
                     if (empty($extra->id)) {
@@ -375,7 +376,7 @@ function authorize_print_order($orderid)
             if ($confirm && confirm_sesskey()) {
                 $extra = NULL;
                 $message = '';
-                if (AN_APPROVED == authorize_action($order, $message, $extra, AN_ACTION_VOID)) {
+                if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_VOID)) {
                     if (empty($CFG->an_test)) {
                         redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
                     }
@@ -402,7 +403,7 @@ function authorize_print_order($orderid)
 
             $suborder = get_record_sql($sql);
             if (!$suborder) { // not found
-                error("Transaction can not be voided because of already been voided.", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
+                print_error("Transaction can not be voided because of already been voided.", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
             }
             $refundedstatus = authorize_get_status_action($suborder);
             unset($suborder->courseid);
@@ -410,7 +411,7 @@ function authorize_print_order($orderid)
                 if ($confirm && confirm_sesskey()) {
                     $message = '';
                     $extra = NULL;
-                    if (AN_APPROVED == authorize_action($suborder, $message, $extra, AN_ACTION_VOID)) {
+                    if (AN_APPROVED == AuthorizeNet::process($suborder, $message, $extra, AN_ACTION_VOID)) {
                         if (empty($CFG->an_test)) {
                             if (!empty($unenrol)) {
                                 role_unassign(0, $order->userid, 0, $coursecontext->id);
@@ -524,7 +525,7 @@ function authorize_get_status_action($order)
 
     switch ($order->status) {
         case AN_STATUS_AUTH:
-            if (authorize_expired($order)) {
+            if (AuthorizeNet::expired($order)) {
                 if ($canmanage) {
                     $ret->actions = array(ORDER_DELETE);
                 }
@@ -539,7 +540,7 @@ function authorize_get_status_action($order)
             return $ret;
 
         case AN_STATUS_AUTHCAPTURE:
-            if (authorize_settled($order)) {
+            if (AuthorizeNet::settled($order)) {
                 if ($canmanage) {
                     if (($order->paymentmethod == AN_METHOD_CC) || ($order->paymentmethod == AN_METHOD_ECHECK && !empty($order->refundinfo))) {
                         $ret->actions = array(ORDER_REFUND);
@@ -556,7 +557,7 @@ function authorize_get_status_action($order)
             return $ret;
 
         case AN_STATUS_CREDIT:
-            if (authorize_settled($order)) {
+            if (AuthorizeNet::settled($order)) {
                 $ret->status = 'settled';
             }
             else {
index 0d68154de9889d7003ff90cb0ea0f720ec88695e..940033abcd19e6b1dd6443771d616d69d9d4cdb4 100644 (file)
@@ -76,13 +76,13 @@ function authorize_process_csv($filename)
 /// Open the file and get first line
     $handle = fopen($filename, "r");
     if (!$handle) {
-        error('CANNOT OPEN CSV FILE');
+        print_error('CANNOT OPEN CSV FILE');
     }
     $firstline = fgetcsv($handle, 8192, ",");
     $numfields = count($firstline);
     if ($numfields != 49 && $numfields != 70) {
         @fclose($handle);
-        error('INVALID CSV FILE; Each line must include 49 or 70 fields');
+        print_error('INVALID CSV FILE; Each line must include 49 or 70 fields');
     }
 
 /// Re-sort fields
@@ -97,7 +97,7 @@ function authorize_process_csv($filename)
     }
     if (empty($csvfields)) {
         @fclose($handle);
-        error("<b>INVALID CSV FILE:</b> First line must include 'Header Fields' and
+        print_error("<b>INVALID CSV FILE:</b> First line must include 'Header Fields' and
                the file must be type of <br />'Expanded Fields/Comma Separated'<br />or<br />
               'Expanded Fields with CAVV Result Code/Comma Separated'");
     }
index 78e51b8eec5c766d7cc2c3145bad35480c2fdcae..2346198f8135b9d7686d7530ccfa57e27573aebf 100644 (file)
@@ -141,7 +141,7 @@ function check_entry($form, $course) {
     if (empty($course->password)) {
         // do not allow entry when no course password set
         // automatic login when manual primary, no login when secondary at all!!
-        error('illegal enrolment attempted');
+        print_error('illegal enrolment attempted');
     }
 
     $groupid = $this->check_group_entry($course->id, $form->password);
index 650f3dc97ede7a8805bd533514a085326f429f48..dcb6f639a8b0ad8130da6cd54b4bbd22e26acf50 100644 (file)
@@ -363,7 +363,7 @@ class enrolment_plugin_mnet {
         // require_capability('moodle/role:assign', $context, NULL, false);
 
         if (!role_unassign(0, $userrecord->id, 0, $context->id)) {
-            error("An error occurred while trying to unenrol that person.");
+            print_error("An error occurred while trying to unenrol that person.");
         }
 
         return true;
@@ -500,7 +500,7 @@ class enrolment_plugin_mnet {
                 list($code, $errormessage) = array_map('trim',explode(':', $errormessage, 2));
                 $message .= "ERROR $code:<br/>$errormessage<br/>";
             }
-            error("RPC enrol/mnet/available_courses:<br/>$message");
+            print_error("RPC enrol/mnet/available_courses:<br/>$message");
         }
         return false;
     }
index e88367e272410304411102f2a8f1038df660ff2c..0781d4ce7ff249003c96adad998988864a2d1dfa 100644 (file)
@@ -18,7 +18,7 @@
 
 /// Keep out casual intruders
     if (empty($_POST) or !empty($_GET)) {
-        error("Sorry, you can not use the script that way.");
+        print_error("Sorry, you can not use the script that way.");
     }
 
 /// Read all the data from PayPal and get it ready for later;
index fefcb33adfa124e0c4a6e495ed293b921d188a73..602d0fef1bc2348bd493d201261b6e5962146ca2 100644 (file)
@@ -11,7 +11,7 @@
 
     /// Work out who to send the message to
         if (!$admin = get_admin() ) {
-            error('Could not find an admin user!');
+            print_error('Could not find an admin user!');
         }
 
         $supportuser = new object;
index 80ad8f810937d39091168f5c3fffe75b652e134b..c59c65cb8ee912f4d443263f665f6c8dba3a57e5 100644 (file)
--- a/file.php
+++ b/file.php
@@ -28,9 +28,9 @@
     
     // relative path must start with '/', because of backup/restore!!!
     if (!$relativepath) {
-        error('No valid arguments supplied or incorrect server configuration');
+        print_error('No valid arguments supplied or incorrect server configuration');
     } else if ($relativepath{0} != '/') {
-        error('No valid arguments supplied, path does not start with slash!');
+        print_error('No valid arguments supplied, path does not start with slash!');
     }
 
     $pathname = $CFG->dataroot.$relativepath;
     // extract relative path components
     $args = explode('/', trim($relativepath, '/'));
     if (count($args) == 0) { // always at least courseid, may search for index.html in course root
-        error('No valid arguments supplied');
+        print_error('No valid arguments supplied');
     }
   
     // security: limit access to existing course subdirectories
     if (($args[0]!='blog') and (!$course = get_record_sql("SELECT * FROM {$CFG->prefix}course WHERE id='".(int)$args[0]."'"))) {
-        error('Invalid course ID');
+        print_error('Invalid course ID');
     }
 
     // security: prevent access to "000" or "1 something" directories
     // hack for blogs, needs proper security check too
     if (($args[0] != 'blog') and ($args[0] != $course->id)) {
-        error('Invalid course ID');
+        print_error('Invalid course ID');
     }
 
     // security: login to course if necessary
     if ($args[0] == 'blog') {
         if (empty($CFG->bloglevel)) {
-            error('Blogging is disabled!');
+            print_error('Blogging is disabled!');
         } else if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
             require_login();
         } else if ($CFG->forcelogin) {
@@ -76,7 +76,7 @@
     // security: only editing teachers can access backups
     if ((count($args) >= 2) and (strtolower($args[1]) == 'backupdata')) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
-            error('Access not allowed');
+            print_error('Access not allowed');
         } else {
             $lifetime = 0; //disable browser caching for backups 
         }
         $lifetime = 0;  // do not cache assignments, students may reupload them
         if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_COURSE, $course->id))
           and $args[4] != $USER->id) {
-           error('Access not allowed');
+           print_error('Access not allowed');
         }
     }
 
                    "AND r.type      = 'file' " .
                    "AND r.reference = '{$reference}'";
         if (count_records_sql($sql)) {
-           error('Access not allowed');
+           print_error('Access not allowed');
         }
     }
 
     function not_found($courseid) {
         global $CFG;
         header('HTTP/1.0 404 not found');
-        error(get_string('filenotfound', 'error'), $CFG->wwwroot.'/course/view.php?id='.$courseid); //this is not displayed on IIS??
+        print_error('filenotfound', 'error', $CFG->wwwroot.'/course/view.php?id='.$courseid); //this is not displayed on IIS??
     }
 ?>
index 96d710c123887a3dff98ae10bc1c37bb98269034..3ff0190c7b4772a3e21cad915a69a03d19a0ffcf 100644 (file)
 
     if ($choose) {
         if (count(explode('.', $choose)) > 2) {
-            error('Incorrect format for choose parameter');
+            print_error('Incorrect format for choose parameter');
         }
     }
 
 
     if (! $course = get_record("course", "id", $id) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     require_login($course);
 
 
     if (! $basedir = make_upload_directory("$course->id")) {
-        error("The site administrator needs to fix the file permissions");
+        print_error("The site administrator needs to fix the file permissions");
     }
 
     $baseweb = $CFG->wwwroot;
 
     if ($wdir == "/backupdata") {
         if (! make_upload_directory("$course->id/backupdata")) {   // Backup folder
-            error("Could not create backupdata folder.  The site administrator needs to fix the file permissions");
+            print_error("Could not create backupdata folder.  The site administrator needs to fix the file permissions");
         }
     }
 
     if (!is_dir($basedir.$wdir)) {
         html_header($course, $wdir);
-        error("Requested directory does not exist.", "$CFG->wwwroot/files/index.php?id=$id");
+        print_error("Requested directory does not exist.", '', "$CFG->wwwroot/files/index.php?id=$id");
     }
 
     switch ($action) {
                 }
 
                 if (!zip_files($files,"$basedir$wdir/$name")) {
-                    error(get_string("zipfileserror","error"));
+                    print_error("zipfileserror","error");
                 }
 
                 clearfilelist();
                 $file = basename($file);
 
                 if (!unzip_file("$basedir$wdir/$file")) {
-                    error(get_string("unzipfileserror","error"));
+                    print_error("unzipfileserror","error");
                 }
 
                 echo "<div style=\"text-align:center\"><form action=\"index.php\" method=\"get\">";
index 5d51d769743bebc9387db2b6580fc47b8c2c10a6..05804d84f6b68ff3aaf892f3472064f916f759dd 100644 (file)
@@ -35,7 +35,7 @@
         $image    = $args[0];
         $pathname = $CFG->dataroot.'/filter/algebra/'.$image;
     } else {
-        error('No valid arguments supplied');
+        print_error('No valid arguments supplied');
     }
 
     if (!file_exists($pathname)) {
index 7eeb949cedd59044cb8e561d37c850464ccb12b7..4c358781bef7d4251bace82cfd7a2748dad54cd4 100644 (file)
@@ -21,7 +21,7 @@ function tex_filter_get_executable($debug=false) {
         if (is_executable($custom_commandpath)) {
             return $custom_commandpath;
         } else {
-            error($error_message2.$error_message1);
+            print_error($error_message2.$error_message1);
         }
     }
 
@@ -31,7 +31,7 @@ function tex_filter_get_executable($debug=false) {
         case "FreeBSD": return "$CFG->dirroot/filter/tex/mimetex.freebsd";
     }
 
-    error($error_message1);
+    print_error($error_message1);
 }
 
 
index 457703e54f858ca12beaaad9a1075ed2debfaca9..377db43ad472ccf6894e43d051f375dddfb50002 100644 (file)
@@ -36,7 +36,7 @@
         $image    = $args[0];
         $pathname = $CFG->dataroot.'/filter/tex/'.$image;
     } else {
-        error('No valid arguments supplied');
+        print_error('No valid arguments supplied');
     }
 
     if (!file_exists($pathname)) {
index 0377da37371b5d45bdc87b928ad444a4ab07efc1..e93a8e125b9994d876d301809d1145bc20d343e5 100644 (file)
@@ -32,7 +32,7 @@ require_once 'edit_form.php';
 $contextid = optional_param('id', SYSCONTEXTID, PARAM_INT);
 
 if (!$context = get_context_instance_by_id($contextid)) {
-    error('Incorrect context id');
+    print_error('Incorrect context id');
 }
 
 if ($context->contextlevel == CONTEXT_SYSTEM or $context->contextlevel == CONTEXT_COURSECAT) {
@@ -49,7 +49,7 @@ if ($context->contextlevel == CONTEXT_SYSTEM or $context->contextlevel == CONTEX
     $returnurl = $CFG->wwwroot.'/grade/edit/letter/index.php?id='.$context->instanceid;
 
 } else {
-    error('Incorrect context level');
+    print_error('Incorrect context level');
 }
 
 require_capability('moodle/grade:manageletters', $context);
index 410471b5b95e55842a48fb5bd7f7d47005229b5f..310159d154ab42af65ca0df19864a18c0cb1eca0 100644 (file)
@@ -37,7 +37,7 @@ require_login($course);
 $context = get_context_instance(CONTEXT_COURSE, $course->id);
 
 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:manageletters', $context)) {
-    error('Missing permission to view letter grades');
+    print_error('Missing permission to view letter grades');
 }
 
 $gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'letter', 'courseid'=>$courseid));
index ac0eaf80137765c203b09581c3eefef4d85819b2..f1c3aec2800a1c21bb0401aa69533077a270b908 100644 (file)
@@ -37,12 +37,12 @@ $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 if ($id) {
     /// editing existing outcome
     if (!$outcome_rec = get_record('grade_outcomes', 'id', $id)) {
-        error('Incorrect outcome id');
+        print_error('Incorrect outcome id');
     }
     if ($outcome_rec->courseid) {
         $outcome_rec->standard = 0;
         if (!$course = get_record('course', 'id', $outcome_rec->courseid)) {
-            error('Incorrect course id');
+            print_error('Incorrect course id');
         }
         require_login($course);
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -51,7 +51,7 @@ if ($id) {
     } else {
         if ($courseid) {
             if (!$course = get_record('course', 'id', $courseid)) {
-                error('Incorrect course id');
+                print_error('Incorrect course id');
             }
         }
         $outcome_rec->standard = 1;
index 99cc31555303228a4a15116f3626dd6a696e6e63..60bda49ec8d76c9f1235895dba2dac7f341cdbbb 100644 (file)
@@ -92,7 +92,7 @@ switch ($action) {
         if (empty($outcome->courseid)) {
             require_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM));
         } else if ($outcome->courseid != $courseid) {
-            error('Incorrect courseid!');
+            print_error('Incorrect courseid!');
         }
 
         if (!$outcome->can_delete()) {
index 5842451f318b2ed11e86b7a0f966e97bafa82df0..26b700e468fa3b60dfdbca7c95305dcfc6ef8ca4 100644 (file)
@@ -37,12 +37,12 @@ $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 if ($id) {
     /// editing existing scale
     if (!$scale_rec = get_record('scale', 'id', $id)) {
-        error('Incorrect scale id');
+        print_error('Incorrect scale id');
     }
     if ($scale_rec->courseid) {
         $scale_rec->standard = 0;
         if (!$course = get_record('course', 'id', $scale_rec->courseid)) {
-            error('Incorrect course id');
+            print_error('Incorrect course id');
         }
         require_login($course);
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -51,7 +51,7 @@ if ($id) {
     } else {
         if ($courseid) {
             if (!$course = get_record('course', 'id', $courseid)) {
-                error('Incorrect course id');
+                print_error('Incorrect course id');
             }
         }
         $scale_rec->standard = 1;
index 2968220a155cec71d37175694550a5aad7810cbd..0a950e26df6a0730bcde0a6d2c08fe6e62e100b2 100644 (file)
@@ -76,7 +76,7 @@ switch ($action) {
         if (empty($scale->courseid)) {
             require_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM));
         } else if ($scale->courseid != $courseid) {
-            error('Incorrect courseid!');
+            print_error('Incorrect courseid!');
         }
 
         if (!$scale->can_delete()) {
index 79f86aa53e5edac9eea87e02a31ce66d13703a63..c6722edd476c3126ab00a6bb7f5471792e39ea2b 100644 (file)
@@ -46,7 +46,7 @@ $gtree = new grade_tree($courseid, false, false);
 
 // what are we working with?
 if (!$element = $gtree->locate_element($eid)) {
-    error('Incorrect element id!', $returnurl);
+    print_error('Incorrect element id!', '', $returnurl);
 }
 $object = $element['object'];
 $type   = $element['type'];
@@ -56,7 +56,7 @@ switch ($action) {
     case 'hide':
         if ($eid and confirm_sesskey()) {
             if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) {
-                error('No permission to hide!', $returnurl);
+                print_error('No permission to hide!', '', $returnurl);
             }
             if ($type == 'grade' and empty($object->id)) {
                 $object->insert();
@@ -68,7 +68,7 @@ switch ($action) {
     case 'show':
         if ($eid and confirm_sesskey()) {
             if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) {
-                error('No permission to show!', $returnurl);
+                print_error('No permission to show!', '', $returnurl);
             }
             if ($type == 'grade' and empty($object->id)) {
                 $object->insert();
@@ -80,7 +80,7 @@ switch ($action) {
     case 'lock':
         if ($eid and confirm_sesskey()) {
             if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:lock', $context)) {
-                error('No permission to lock!', $returnurl);
+                print_error('No permission to lock!', '', $returnurl);
             }
             if ($type == 'grade' and empty($object->id)) {
                 $object->insert();
@@ -92,7 +92,7 @@ switch ($action) {
     case 'unlock':
         if ($eid and confirm_sesskey()) {
             if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:unlock', $context)) {
-                error('No permission to unlock!', $returnurl);
+                print_error('No permission to unlock!', '', $returnurl);
             }
             if ($type == 'grade' and empty($object->id)) {
                 $object->insert();
index fd79c2382a72743c5feb1a8ed71c04ef3aa98397..06e9e27850dea0cc692a6ad8234483e4bc038c21 100644 (file)
@@ -46,7 +46,7 @@ $gpr = new grade_plugin_return();
 $returnurl = $gpr->get_return_url($CFG->wwwroot.'/grade/report.php?id='.$course->id);
 
 if (!$grade_item = grade_item::fetch(array('id'=>$id, 'courseid'=>$course->id))) {
-    error('Incorect item id');
+    print_error('Incorect item id');
 }
 
 // activity items and items without grade can not have calculation
index 853bcfe2912ab6ecc3a6ae757db7ac0b5ded1e00..073f4019caa17c8dacdaca2070b29783943dade2 100644 (file)
@@ -48,7 +48,7 @@ $mform = new edit_category_form(null, array('gpr'=>$gpr));
 
 if ($id) {
     if (!$grade_category = grade_category::fetch(array('id'=>$id, 'courseid'=>$course->id))) {
-        error('Incorrect category id!');
+        print_error('Incorrect category id!');
     }
     $grade_category->apply_forced_settings();
     $category = $grade_category->get_record_data();
@@ -98,7 +98,7 @@ if ($mform->is_cancelled()) {
     // Handle user preferences
     if (isset($data->pref_aggregationview)) {
         if (!grade_report::set_pref('aggregationview', $data->pref_aggregationview, $grade_category->id)) {
-            error("Could not set preference aggregationview to $value for this grade category");
+            print_error("Could not set preference aggregationview to $value for this grade category");
         }
     }
 
index e0981c3b4df0a350eed311cdb645c14787a6a1e5..5b0463c79d67b3a8ee2463ed8e3535489de4fe70 100644 (file)
@@ -50,27 +50,27 @@ $returnurl = $gpr->get_return_url($CFG->wwwroot.'/grade/report.php?id='.$course-
 // security checks!
 if (!empty($id)) {
     if (!$grade = get_record('grade_grades', 'id', $id)) {
-        error('Incorrect grade id');
+        print_error('Incorrect grade id');
     }
 
     if (!empty($itemid) and $itemid != $grade->itemid) {
-        error('Incorrect itemid');
+        print_error('Incorrect itemid');
     }
     $itemid = $grade->itemid;
 
     if (!empty($userid) and $userid != $grade->userid) {
-        error('Incorrect userid');
+        print_error('Incorrect userid');
     }
     $userid = $grade->userid;
 
     unset($grade);
 
 } else if (empty($userid) or empty($itemid)) {
-    error('Missing userid and itemid');
+    print_error('Missing userid and itemid');
 }
 
 if (!$grade_item = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$courseid))) {
-    error('Can not find grade_item');
+    print_error('Can not find grade_item');
 }
 
 // now verify grading user has access to all groups or is member of the same group when separate groups used in course
@@ -83,10 +83,10 @@ if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('
             }
         }
         if (!$ok) {
-            error('Can not grade this user');
+            print_error('Can not grade this user');
         }
     } else {
-        error('Can not grade this user');
+        print_error('Can not grade this user');
     }
 }
 
index 17aa4aafa19a8d39646211ec53c53a0f885ce44a..4c34e7f46d27a3a1f977273eee9a81c427834de5 100644 (file)
@@ -59,7 +59,7 @@ if (empty($eid)) {
 
 } else {
     if (!$element = $gtree->locate_element($eid)) {
-        error('Incorrect element id!', $returnurl);
+        print_error('Incorrect element id!', '', $returnurl);
     }
     $object = $element['object'];
 }
@@ -112,7 +112,7 @@ switch ($action) {
         if ($eid and confirm_sesskey()) {
             $moveafter = required_param('moveafter', PARAM_ALPHANUM);
             if(!$after_el = $gtree->locate_element($moveafter)) {
-                error('Incorect element id in moveafter', $returnurl);
+                print_error('Incorect element id in moveafter', '', $returnurl);
             }
             $after = $after_el['object'];
             $parent = $after->get_parent_category();
index fdbc4f2f9737cd7c26fc6ecb48bc59037f2cb7e2..4fc2abcb84f40560e75a38b46d354f322bdd4f55 100644 (file)
@@ -34,22 +34,22 @@ $confirm  = optional_param('confirm', 0, PARAM_BOOL);
 
 if ($id) {
     if (!$key = get_record('user_private_key', 'id', $id)) {
-        error('Group ID was incorrect');
+        print_error('Group ID was incorrect');
     }
     if (empty($courseid)) {
         $courseid = $key->instance;
 
     } else if ($courseid != $key->instance) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
 } else {
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
     $key = new object();
 }
@@ -62,7 +62,7 @@ require_capability('moodle/grade:export', $context);
 
 // extra security check
 if (!empty($key->userid) and $USER->id != $key->userid) {
-    error('You are not owner of this key');
+    print_error('You are not owner of this key');
 }
 
 $returnurl = $CFG->wwwroot.'/grade/export/keymanager.php?id='.$course->id;
index e5c1d1689aa13bc1394daa22d840b36963339273..8f40b6269598af9d9754b2e46fce60e3763b9755 100644 (file)
@@ -34,7 +34,7 @@ if (!$course = get_record('course', 'id', $id)) {
 require_user_key_login('grade/export', $id); // we want different keys for each course
 
 if (empty($CFG->gradepublishing)) {
-    error('Grade publishing disabled');
+    print_error('Grade publishing disabled');
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
index 1969f95c1e0dd7fdaa868ad019d76c3d2d9a2607..9897cc152b671bdfc71f6816d259347abcd72fc9 100644 (file)
@@ -34,7 +34,7 @@ if (!$course = get_record('course', 'id', $id)) {
 require_user_key_login('grade/export', $id); // we want different keys for each course
 
 if (empty($CFG->gradepublishing)) {
-    error('Grade publishing disabled');
+    print_error('Grade publishing disabled');
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
index 5ae4dd70a52be8507549414b2280b0334e57db96..7139e2f6cc080351d9339a5a38f33aef7cc16775 100644 (file)
@@ -34,7 +34,7 @@ if (!$course = get_record('course', 'id', $id)) {
 require_user_key_login('grade/export', $id); // we want different keys for each course
 
 if (empty($CFG->gradepublishing)) {
-    error('Grade publishing disabled');
+    print_error('Grade publishing disabled');
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
index d0cff60b58edfb84b8c9595aebb51914f931e791..68a7aadd62a54f070c3f17b03bf97c012d18d194 100644 (file)
@@ -34,7 +34,7 @@ if (!$course = get_record('course', 'id', $id)) {
 require_user_key_login('grade/export', $id); // we want different keys for each course
 
 if (empty($CFG->gradepublishing)) {
-    error('Grade publishing disabled');
+    print_error('Grade publishing disabled');
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
index 0f505780661fe7a113cc1f62f1aeac86e95075bb..2379929e1c1af5e8f4e90be2e3c0180d778584d9 100755 (executable)
@@ -50,7 +50,7 @@ class grade_export_xml extends grade_export {
         make_upload_directory('temp/gradeexport', false);
         $tempfilename = $CFG->dataroot .'/temp/gradeexport/'. md5(sesskey().microtime().$downloadfilename);
         if (!$handle = fopen($tempfilename, 'w+b')) {
-            error("Could not create a temporary file into which to dump the XML data.");
+            print_error("Could not create a temporary file into which to dump the XML data.");
             return false;
         }
 
index 36d42847ee4778bbefb6a7a3eb991f4120de242b..e4f1edaa47cafb567020ac174fdecba9f22841e2 100755 (executable)
@@ -160,7 +160,7 @@ if ($formdata = $mform->get_data()) {
     $filename = $CFG->dataroot.'/temp/gradeimport/cvs/'.$USER->id.'/'.$importcode;
 
     if (!file_exists($filename)) {
-        error('error processing upload file');
+        print_error('error processing upload file');
     }
 
     if ($fp = fopen($filename, "r")) {
@@ -195,7 +195,7 @@ if ($formdata = $mform->get_data()) {
             } else {
                 // collision
                 unlink($filename); // needs to be uploaded again, sorry
-                error('mapping collision detected, 2 fields maps to the same grade item '.$j);
+                print_error('mapping collision detected, 2 fields maps to the same grade item '.$j);
             }
         }
     }
index df9a4d8063c5bb6af29a54a1afaaa226d6676204..c4426db2d7d51c22860bf8060935c4fc1b973523 100644 (file)
@@ -34,22 +34,22 @@ $confirm  = optional_param('confirm', 0, PARAM_BOOL);
 
 if ($id) {
     if (!$key = get_record('user_private_key', 'id', $id)) {
-        error('Group ID was incorrect');
+        print_error('Group ID was incorrect');
     }
     if (empty($courseid)) {
         $courseid = $key->instance;
 
     } else if ($courseid != $key->instance) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
 } else {
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
     $key = new object();
 }
@@ -62,7 +62,7 @@ require_capability('moodle/grade:import', $context);
 
 // extra security check
 if (!empty($key->userid) and $USER->id != $key->userid) {
-    error('You are not owner of this key');
+    print_error('You are not owner of this key');
 }
 
 $returnurl = $CFG->wwwroot.'/grade/import/keymanager.php?id='.$course->id;
index 1fed44e9aa9f62ab98b5a611fe276e9556f2cd6c..a0c1715badac1e0f6bfeeb3005358e921d605308 100644 (file)
@@ -34,7 +34,7 @@ if (!$course = get_record('course', 'id', $id)) {
 require_user_key_login('grade/import', $id); // we want different keys for each course
 
 if (empty($CFG->gradepublishing)) {
-    error('Grade publishing disabled');
+    print_error('Grade publishing disabled');
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
index 960c40e24c9489cf016d3e854a77a18f36ac5dfe..f479aa8ca1a501cdf5e4644d228240eecd290169 100644 (file)
@@ -53,7 +53,7 @@ if (function_exists('apache_child_terminate')) {
 
 $text = download_file_content($url);
 if ($text === false) {
-    error('Can not read file');
+    print_error('Can not read file');
 }
 
 $error = '';
@@ -67,7 +67,7 @@ if ($importcode !== false) {
             echo 'ok';
             die;
         } else {
-            error('Grade import error'); //TODO: localize
+            print_error('Grade import error'); //TODO: localize
         }
 
     } else {
@@ -85,7 +85,7 @@ if ($importcode !== false) {
     }
 
 } else {
-    error($error);
+    print_error($error);
 }
 
 ?>
index 230c94dc0cc69448c0d0f8fe80e540175ad7a9d2..2ad2d9d18ea6fab5c46e8d0764a61d2b3b0fd7ed 100644 (file)
@@ -180,7 +180,7 @@ class grade_report_grader extends grade_report {
             }
 
             if (!$grade_item = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$this->courseid))) { // we must verify course id here!
-                error('Incorrect grade item id');
+                print_error('Incorrect grade item id');
             }
 
             // Pre-process grade
index f0fb7e2573dfc9c5a56de79dadf88c90c73139e6..2aa15701b94c3accca3acda76bdba4fe5dd643f4 100644 (file)
@@ -43,7 +43,7 @@ if ($reports = get_list_of_plugins('grade/report', 'CVS')) {     // Get all inst
 }
 
 if (empty($reports)) {
-    error('No reports accessible', $CFG->wwwroot.'/course/view.php?id='.$course->id); // TODO: localize
+    print_error('No reports accessible', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); // TODO: localize
 }
 
 if (!isset($USER->grade_last_report)) {
index 547c167c4355beb70b4e44a30eff237b5be82009..624a9035096d5a61cb851ddb9dc537fa9f430df1 100644 (file)
@@ -37,7 +37,7 @@ if (!$course = get_record('course', 'id', $courseid)) {
 require_login($course);
 
 if (!$user = get_complete_user_data('id', $userid)) {
-    error("Incorrect userid");
+    print_error("Incorrect userid");
 }
 
 $context     = get_context_instance(CONTEXT_COURSE, $course->id);
index 2c019ffc57d949c41339d9ee6ec21fadba897e22..64b09096b67500f353a51323ae2024ae0c94f48a 100644 (file)
@@ -44,7 +44,7 @@ if (empty($userid)) {
 
 } else {
     if (!get_complete_user_data('id', $userid)) {
-    error("Incorrect userid");
+    print_error("Incorrect userid");
 }
 
 }
index 0c7211ad83bc464cf4b30567832d798fa70af68c..fb8bf24a5a0b52bf4af45951b026834979cb8cba 100644 (file)
@@ -9,7 +9,7 @@ require_once('lib.php');
 $groupingid = required_param('id', PARAM_INT);
 
 if (!$grouping = get_record('groupings', 'id', $groupingid)) {
-    error('Incorrect group id');
+    print_error('Incorrect group id');
 }
 
 if (! $course = get_record('course', 'id', $grouping->courseid)) {
index add9d3561f031886758c19726c2fd283d8acee7b..642cbc2e2744fedfbe7012a43dd44e68f23b3e04 100644 (file)
@@ -19,7 +19,7 @@ if (!defined('AUTOGROUP_MIN_RATIO')) {
 $courseid = required_param('courseid', PARAM_INT);
 
 if (!$course = get_record('course', 'id', $courseid)) {
-    error('invalidcourse');
+    print_error('invalidcourse');
 }
 
 // Make sure that the user has permissions to manage groups.
@@ -82,7 +82,7 @@ if ($editform->is_cancelled()) {
         case 'idnumber':
             $orderby = 'idnumber'; break;
         default:
-            error('Unknown ordering');
+            print_error('Unknown ordering');
     }
     $users = groups_get_potential_members($data->courseid, $data->roleid, $orderby);
     $usercnt = count($users);
index db3c508b2b64008d1d8bad3245c5876f609a6cc0..31f13cdebb1b827e97a6a5796de3d8e1b4d96170 100644 (file)
@@ -21,23 +21,23 @@ $confirm  = optional_param('confirm', 0, PARAM_BOOL);
 
 if ($id) {
     if (!$group = get_record('groups', 'id', $id)) {
-        error('Group ID was incorrect');
+        print_error('Group ID was incorrect');
     }
     $group->description = clean_text($group->description);
     if (empty($courseid)) {
         $courseid = $group->courseid;
 
     } else if ($courseid != $group->courseid) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
 } else {
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
     $group = new object();
     $group->courseid = $course->id;
@@ -83,11 +83,11 @@ if ($editform->is_cancelled()) {
 
     if ($data->id) {
         if (!groups_update_group($data, $editform->_upload_manager)) {
-            error('Error updating group');
+            print_error('Error updating group');
         }
     } else {
         if (!$id = groups_create_group($data, $editform->_upload_manager)) {
-            error('Error creating group');
+            print_error('Error creating group');
         }
         $returnurl = $CFG->wwwroot.'/group/index.php?id='.$course->id.'&amp;group='.$id;
     }
index d1bde1beb2e414ea4ebd49097fdee59cbfbe9f38..a6bdb9c4f0f5f5eb8d796d6d8ad0adb65fe71f6b 100644 (file)
@@ -20,23 +20,23 @@ $confirm  = optional_param('confirm', 0, PARAM_BOOL);
 
 if ($id) {
     if (!$grouping = get_record('groupings', 'id', $id)) {
-        error('Group ID was incorrect');
+        print_error('Group ID was incorrect');
     }
     $grouping->description = clean_text($grouping->description);
     if (empty($courseid)) {
         $courseid = $grouping->courseid;
 
     } else if ($courseid != $grouping->courseid) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
 } else {
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
     $grouping = new object();
     $grouping->courseid = $course->id;
@@ -84,12 +84,12 @@ if ($editform->is_cancelled()) {
 
     if ($data->id) {
         if (!groups_update_grouping($data)) {
-            error('Error updating grouping');
+            print_error('Error updating grouping');
         }
 
     } else {
         if (!groups_create_grouping($data)) {
-            error('Error creating grouping');
+            print_error('Error creating grouping');
         }
     }
 
index d70ebf2e1286a42bc55e7e3bd4b03c319eec4f9e..c0ab841f31bf7054312cfac631e543cbb352a5a8 100644 (file)
@@ -96,7 +96,7 @@ switch ($action) {
 
     default: //ERROR.
         if (debugging()) {
-            error('Error, unknown button/action. Probably a user-interface bug!', $returnurl);
+            print_error('Error, unknown button/action. Probably a user-interface bug!', '', $returnurl);
         break;
     }
 }
@@ -269,7 +269,7 @@ function groups_param_action($prefix = 'act_') {
     }
     if ($action && !preg_match('/^\w+$/', $action)) {
         $action = false;
-        error('Action had wrong type.');
+        print_error('Action had wrong type.');
     }
     ///if (debugging()) echo 'Debug: '.$action;
     return $action;
index ecd75fb1cd36e1aaa1c908e4d2e3212cf0e9c1a5..c3f476da371dfb14cdac366b16b905a96961ce9d 100644 (file)
@@ -22,7 +22,7 @@ if ($showall) {
 }
 
 if (!$group = get_record('groups', 'id', $groupid)) {
-    error('Incorrect group id');
+    print_error('Incorrect group id');
 }
 
 if (!$course = get_record('course', 'id', $group->courseid)) {
index 737f1a405c46b8e3c29b20356cd1a75980cbf236..a1f3705eaafe63da4b1f36ce88d52867c6e4b32c 100644 (file)
@@ -18,7 +18,7 @@ $returnurl = $CFG->wwwroot.'/group/index.php?id='.$courseid;
 $rooturl   = $CFG->wwwroot.'/group/overview.php?id='.$courseid;
 
 if (!$course = get_record('course', 'id',$courseid)) {
-    error('invalidcourse');
+    print_error('invalidcourse');
 }
 
 // Make sure that the user has permissions to manage groups.
index fb45f49f3de6971cb471b6c8df2310d6c73729f7..1ec4ab06ccc2ad583ffae334ce85ab6f1cfa9652 100644 (file)
--- a/help.php
+++ b/help.php
@@ -144,7 +144,7 @@ function include_help_for_each_module($file, $langs, $helpdir) {
     global $CFG;
 
     if (!$modules = get_records('modules', 'visible', 1)) {
-        error('No modules found!!');        // Should never happen
+        print_error('No modules found!!');        // Should never happen
     }
     
     $grade = new stdClass();
index cc022d3b088d06cce6ac0c3a50c8215459ab717e..81ff29c4191af0264b1d67700a7dd67a97ac8edc 100644 (file)
--- a/index.php
+++ b/index.php
                     require_once($CFG->dirroot .'/mod/forum/lib.php');
 
                     if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
-                        error('Could not find or create a main news forum for the site');
+                        print_error('Could not find or create a main news forum for the site');
                     }
 
                     if (!empty($USER->id)) {
index 7e75bd80df342e4cd0c3ff112e9294002b0b15af..f174dbdbe4b802ec1b2b096aaa333867faa57727 100644 (file)
@@ -85,7 +85,7 @@ if (!empty($CFG->geoipfile) and file_exists($CFG->geoipfile)) {
 } else {
     $ipdata = download_file_content('http://netgeo.caida.org/perl/netgeo.cgi?target='.$ip);
     if ($ipdata === false) {
-        error('Can not connect to NetGeo server at http://netgeo.caida.org, please check proxy settings or better install MaxMind GeoLite City data file.');
+        print_error('Can not connect to NetGeo server at http://netgeo.caida.org, please check proxy settings or better install MaxMind GeoLite City data file.');
     }
     $matches = null;
     if (!preg_match('/LAT:\s*(-?\d+\.\d+)/s', $ipdata, $matches)) {
index 60537a97a7bf26c46bc9452f4de8469573c2de25..a2d490ff5f0e2e2e2823a8cb95e8106c07b611e3 100755 (executable)
@@ -852,10 +852,10 @@ function require_capability($capability, $context, $userid=NULL, $doanything=tru
 
         } else if ($context->contextlevel == CONTEXT_MODULE) {
             if (!$cm = get_record('course_modules', 'id', $context->instanceid)) {
-                error('Incorrect module');
+                print_error('Incorrect module');
             }
             if (!$course = get_record('course', 'id', $cm->course)) {
-                error('Incorrect course.');
+                print_error('Incorrect course.');
             }
             require_course_login($course, true, $cm);
             $errorlink = $CFG->wwwroot.'/course/view.php?id='.$cm->course;
@@ -1885,10 +1885,10 @@ function moodle_install_roles() {
 /// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
 
     if (!assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $systemcontext->id)) {
-        error('Could not assign moodle/site:doanything to the admin role');
+        print_error('Could not assign moodle/site:doanything to the admin role');
     }
     if (!update_capabilities()) {
-        error('Had trouble upgrading the core capabilities for the Roles System');
+        print_error('Had trouble upgrading the core capabilities for the Roles System');
     }
 
 /// Look inside user_admin, user_creator, user_teachers, user_students and
@@ -2101,7 +2101,7 @@ function assign_legacy_capabilities($capability, $legacyperms) {
         $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 
         if (!array_key_exists($type, $legacyroles)) {
-            error('Incorrect legacy role definition for type: '.$type);
+            print_error('Incorrect legacy role definition for type: '.$type);
         }
 
         if ($roles = get_roles_with_capability($legacyroles[$type], CAP_ALLOW)) {
@@ -2558,7 +2558,7 @@ function get_context_instance($contextlevel, $instance=0) {
 /// check allowed context levels
     if (!in_array($contextlevel, $allowed_contexts)) {
         // fatal error, code must be fixed - probably typo or switched parameters
-        error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"');
+        print_error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"');
     }
 
     if (!is_array($instance)) {
@@ -2686,11 +2686,11 @@ function create_role($name, $shortname, $description, $legacy='') {
     // check for duplicate role name
 
     if ($role = get_record('role','name', $name)) {
-        error('there is already a role with this name!');
+        print_error('there is already a role with this name!');
     }
 
     if ($role = get_record('role','shortname', $shortname)) {
-        error('there is already a role with this shortname!');
+        print_error('there is already a role with this shortname!');
     }
 
     $role = new object();
@@ -3249,7 +3249,7 @@ function get_cached_capabilities($component='moodle') {
  */
 function get_default_capabilities($legacyrole) {
     if (!$allcaps = get_records('capabilities')) {
-        error('Error: no capabilitites defined!');
+        print_error('Error: no capabilitites defined!');
     }
     $alldefs = array();
     $defaults = array();
@@ -3425,7 +3425,7 @@ function capabilities_cleanup($component, $newcapdef=NULL) {
 
                 // Remove from capabilities cache.
                 if (!delete_records('capabilities', 'name', $cachedcap->name)) {
-                    error('Could not delete deprecated capability '.$cachedcap->name);
+                    print_error('Could not delete deprecated capability '.$cachedcap->name);
                 } else {
                     $removedcount++;
                 }
@@ -3433,7 +3433,7 @@ function capabilities_cleanup($component, $newcapdef=NULL) {
                 if($roles = get_roles_with_capability($cachedcap->name)) {
                     foreach($roles as $role) {
                         if (!unassign_capability($cachedcap->name, $role->id)) {
-                            error('Could not unassign deprecated capability '.
+                            print_error('Could not unassign deprecated capability '.
                                     $cachedcap->name.' from role '.$role->name);
                         }
                     }
@@ -3837,7 +3837,7 @@ function get_child_contexts($context) {
         break;
 
         default:
-            error('This is an unknown context (' . $context->contextlevel . ') in get_child_contexts!');
+            print_error('This is an unknown context (' . $context->contextlevel . ') in get_child_contexts!');
         return false;
     }
 }
index 857873b1076481e0450c912d28371dd0e75f22b0..f28f9da5c40544d90e815c494e4252439849efb8 100644 (file)
@@ -15,7 +15,7 @@ function upgrade_main_savepoint($result, $version) {
     if ($result) {
         if ($CFG->version >= $version) {
             // something really wrong is going on in main upgrade script
-            error("Upgrade savepoint: Can not upgrade main version from $CFG->version to $version.");
+            print_error("Upgrade savepoint: Can not upgrade main version from $CFG->version to $version.");
         }
         set_config('version', $version);
     } else {
@@ -149,7 +149,7 @@ function upgrade_plugins($type, $dir, $return) {
 
                 /// Install capabilities
                     if (!update_capabilities($type.'/'.$plug)) {
-                        error('Could not set up the capabilities for '.$plugin->name.'!');
+                        print_error('Could not set up the capabilities for '.$plugin->name.'!');
                     }
                 /// Install events
                     events_update_definition($type.'/'.$plug);
@@ -205,7 +205,7 @@ function upgrade_plugins($type, $dir, $return) {
                     // OK so far, now update the plugins record
                     set_config($pluginversion, $plugin->version);
                     if (!update_capabilities($type.'/'.$plug)) {
-                        error('Could not update '.$plugin->name.' capabilities!');
+                        print_error('Could not update '.$plugin->name.' capabilities!');
                     }
                     events_update_definition($type.'/'.$plug);
                     notify(get_string('modulesuccess', '', $plugin->name), 'notifysuccess');
@@ -218,7 +218,7 @@ function upgrade_plugins($type, $dir, $return) {
             }
         } else {
             upgrade_log_start();
-            error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !');
+            print_error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !');
         }
     }
 
@@ -253,7 +253,7 @@ function upgrade_activity_modules($return) {
     global $CFG, $db, $interactive;
 
     if (!$mods = get_list_of_plugins('mod') ) {
-        error('No modules installed!');
+        print_error('No modules installed!');
     }
 
     $updated_modules = false;
@@ -372,7 +372,7 @@ function upgrade_activity_modules($return) {
                     // OK so far, now update the modules record
                     $module->id = $currmodule->id;
                     if (! update_record('modules', $module)) {
-                        error('Could not update '. $module->name .' record in modules table!');
+                        print_error('Could not update '. $module->name .' record in modules table!');
                     }
                     remove_dir($CFG->dataroot . '/cache', true); // flush cache
                     notify(get_string('modulesuccess', '', $module->name), 'notifysuccess');
@@ -385,7 +385,7 @@ function upgrade_activity_modules($return) {
 
             /// Update the capabilities table?
                 if (!update_capabilities('mod/'.$module->name)) {
-                    error('Could not update '.$module->name.' capabilities!');
+                    print_error('Could not update '.$module->name.' capabilities!');
                 }
                 events_update_definition('mod/'.$module->name);
 
@@ -393,7 +393,7 @@ function upgrade_activity_modules($return) {
 
             } else {
                 upgrade_log_start();
-                error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !');
+                print_error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !');
             }
 
         } else {    // module not installed yet, so install it
@@ -431,7 +431,7 @@ function upgrade_activity_modules($return) {
 
                 /// Capabilities
                     if (!update_capabilities('mod/'.$module->name)) {
-                        error('Could not set up the capabilities for '.$module->name.'!');
+                        print_error('Could not set up the capabilities for '.$module->name.'!');
                     }
 
                 /// Events
@@ -450,10 +450,10 @@ function upgrade_activity_modules($return) {
                     echo '<hr />';
                     }
                 } else {
-                    error($module->name .' module could not be added to the module list!');
+                    print_error($module->name .' module could not be added to the module list!');
                 }
             } else {
-                error($module->name .' tables could NOT be set up successfully!');
+                print_error($module->name .' tables could NOT be set up successfully!');
             }
         }
 
@@ -611,16 +611,16 @@ function create_admin_user($user_input=NULL) {
             $user = $user_input;
         }
         if (!$user->id = insert_record('user', $user)) {
-            error('SERIOUS ERROR: Could not create admin user record !!!');
+            print_error('SERIOUS ERROR: Could not create admin user record !!!');
         }
 
         if (!$user = get_record('user', 'id', $user->id)) {   // Double check.
-            error('User ID was incorrect (can\'t find it)');
+            print_error('User ID was incorrect (can\'t find it)');
         }
 
         // Assign the default admin roles to the new user.
         if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
-            error('No admin role could be found');
+            print_error('No admin role could be found');
         }
         $sitecontext = get_context_instance(CONTEXT_SYSTEM);
         foreach ($adminroles as $adminrole) {
@@ -638,7 +638,7 @@ function create_admin_user($user_input=NULL) {
         redirect("$CFG->wwwroot/user/editadvanced.php?id=$user->id");  // Edit thyself
         }
     } else {
-        error('Can not create admin!');
+        print_error('Can not create admin!');
     }
 }
 
@@ -695,10 +695,10 @@ function upgrade_log_start() {
 
 /**
  * Terminate logging of output, flush all data, allow script aborting
- * and reopen session for writing. Function error() does terminate the logging too.
+ * and reopen session for writing. Function print_error() does terminate the logging too.
  *
  * Please make sure that each upgrade_log_start() is properly terminated by
- * this function or error().
+ * this function or print_error().
  *
  * This function may be called repeatedly.
  */
@@ -3951,13 +3951,13 @@ function admin_externalpage_setup($section) {
     $extpage =& $adminroot->locate($section);
 
     if (empty($extpage) or !is_a($extpage, 'admin_externalpage')) {
-        error(get_string('sectionerror','admin'), "$CFG->wwwroot/$CFG->admin/");
+        print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
         die;
     }
 
     // this eliminates our need to authenticate on the actual pages
     if (!($extpage->check_access())) {
-        error(get_string('accessdenied', 'admin'));
+        print_error('accessdenied', 'admin');
         die;
     }
 
@@ -4025,7 +4025,7 @@ function admin_externalpage_print_header($focus='') {
                 case 'middle':
                     echo '<td id="middle-column">';
                     print_container_start(true);
-                    $THEME->open_header_containers++; // this is hacky workaround for the error()/notice() autoclosing problems on admin pages
+                    $THEME->open_header_containers++; // this is hacky workaround for the print_error()/notice() autoclosing problems on admin pages
                 break;
 
                 case 'right':
@@ -4082,7 +4082,7 @@ function admin_externalpage_print_footer() {
 
                 case 'middle':
                     print_container_end();
-                    $THEME->open_header_containers--; // this is hacky workaround for the error()/notice() autoclosing problems on admin pages
+                    $THEME->open_header_containers--; // this is hacky workaround for the print_error()/notice() autoclosing problems on admin pages
                     echo '</td>';
                 break;
 
index ec953df4f13df52d55818f9d4d64334c45220d30..787e5a735b23079ff2722fcfece0e8952da141ca 100644 (file)
@@ -43,7 +43,7 @@ function ajax_get_lib($libname) {
 
     $testpath = str_replace($CFG->wwwroot, $CFG->dirroot, $libpath);
     if (!file_exists($testpath)) {        
-        error('require_js: '.$libpath.' - file not found.');
+        print_error('require_js: '.$libpath.' - file not found.');
     }
 
     return $libpath;
index 835e6afd68e709b2472bd332f3e084199a49fd2c..a60a661378d3089b4d9ff40c70530b76e8cb057a 100644 (file)
@@ -73,7 +73,7 @@ class auth_plugin_base {
      * @return bool Authentication success or failure.
      */
     function user_login($username, $password) {
-        error('Abstract user_login() method must be overriden.');
+        print_error('Abstract user_login() method must be overriden.');
     }
 
     /**
@@ -180,7 +180,7 @@ class auth_plugin_base {
      */
     function user_signup($user, $notify=true) {
         //override when can signup
-        error('user_signup method must be overriden if signup enabled');
+        print_error('user_signup method must be overriden if signup enabled');
     }
 
     /**
@@ -201,7 +201,7 @@ class auth_plugin_base {
      */
     function user_confirm($username, $confirmsecret) {
         //override when can confirm
-        error('user_confirm method must be overriden if confirm enabled');
+        print_error('user_confirm method must be overriden if confirm enabled');
     }
 
     /**
index 5a2d9c9dca1bea0e3ec0311910bddd072686ea76..92bc24e80e83f1debc00d9127e4bfe593e529824 100644 (file)
@@ -512,7 +512,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
                     unset($data->$item);
                 }
                 if(!$blockobject->instance_config_save($data,$pinned)) {
-                    error('Error saving block configuration');
+                    print_error('Error saving block configuration');
                 }
                 // And nothing more, continue with displaying the page
             }
@@ -541,7 +541,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'toggle':
             if(empty($instance))  {
-                error('Invalid block instance for '.$blockaction);
+                print_error('Invalid block instance for '.$blockaction);
             }
             $instance->visible = ($instance->visible) ? 0 : 1;
             if (!empty($pinned)) {
@@ -552,13 +552,13 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'delete':
             if(empty($instance))  {
-                error('Invalid block instance for '. $blockaction);
+                print_error('Invalid block instance for '. $blockaction);
             }
             blocks_delete_instance($instance, $pinned);
         break;
         case 'moveup':
             if(empty($instance))  {
-                error('Invalid block instance for '. $blockaction);
+                print_error('Invalid block instance for '. $blockaction);
             }
 
             if($instance->weight == 0) {
@@ -595,7 +595,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'movedown':
             if(empty($instance))  {
-                error('Invalid block instance for '. $blockaction);
+                print_error('Invalid block instance for '. $blockaction);
             }
 
             if($instance->weight == max(array_keys($pageblocks[$instance->position]))) {
@@ -632,7 +632,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'moveleft':
             if(empty($instance))  {
-                error('Invalid block instance for '. $blockaction);
+                print_error('Invalid block instance for '. $blockaction);
             }
 
             // Where is the instance going to be moved?
@@ -643,7 +643,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'moveright':
             if(empty($instance))  {
-                error('Invalid block instance for '. $blockaction);
+                print_error('Invalid block instance for '. $blockaction);
             }
 
             // Where is the instance going to be moved?
@@ -976,7 +976,7 @@ function blocks_repopulate_page($page) {
     $allblocks = blocks_get_record();
 
     if(empty($allblocks)) {
-        error('Could not retrieve blocks from the database');
+        print_error('Could not retrieve blocks from the database');
     }
 
     // Assemble the information to correlate block names to ids
@@ -1036,22 +1036,22 @@ function upgrade_blocks_db($continueto) {
 /// This function upgrades the blocks tables, if necessary
 /// It's called from admin/index.php
 
-    global $CFG, $db, $interactive;\r
+    global $CFG, $db, $interactive;
 
     require_once ($CFG->dirroot .'/blocks/version.php');  // Get code versions
 
     if (empty($CFG->blocks_version)) {                  // Blocks have never been installed.
         $strdatabaseupgrades = get_string('databaseupgrades');
-        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
         print_header($strdatabaseupgrades, $strdatabaseupgrades,
                 build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '',
                 upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
-        }\r
+        }
         upgrade_log_start();
         print_heading('blocks');
-        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
         $db->debug=true;
-        }\r
+        }
     /// Both old .sql files and new install.xml are supported
     /// but we priorize install.xml (XMLDB) if present
         $status = false;
@@ -1060,30 +1060,30 @@ function upgrade_blocks_db($continueto) {
         } else if (file_exists($CFG->dirroot . '/blocks/db/' . $CFG->dbtype . '.sql')) {
             $status = modify_database($CFG->dirroot . '/blocks/db/' . $CFG->dbtype . '.sql'); //Old method
         }
-        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
         $db->debug = false;
-        }\r
+        }
         if ($status) {
             if (set_config('blocks_version', $blocks_version)) {
                 notify(get_string('databasesuccess'), 'notifysuccess');
                 notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess');
-                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                 print_continue($continueto);
                 print_footer('none');
                 exit;
-                } else if (CLI_UPGRADE && ($interactive > CLI_SEMI) ) {\r
-                    console_write(STDOUT,'askcontinue');\r
-                    if (read_boolean()){\r
-                        return ;\r
-                    }else {\r
-                        console_write(STDERR,'','',false);\r
-                    }\r
-                }\r
+                } else if (CLI_UPGRADE && ($interactive > CLI_SEMI) ) {
+                    console_write(STDOUT,'askcontinue');
+                    if (read_boolean()){
+                        return ;
+                    }else {
+                        console_write(STDERR,'','',false);
+                    }
+                }
             } else {
-                error('Upgrade of blocks system failed! (Could not update version in config table)');
+                print_error('Upgrade of blocks system failed! (Could not update version in config table)');
             }
         } else {
-            error('Blocks tables could NOT be set up successfully!');
+            print_error('Blocks tables could NOT be set up successfully!');
         }
     }
 
@@ -1101,12 +1101,12 @@ function upgrade_blocks_db($continueto) {
 
     if ($blocks_version > $CFG->blocks_version) {       // Upgrade tables
         $strdatabaseupgrades = get_string('databaseupgrades');
-        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
         print_header($strdatabaseupgrades, $strdatabaseupgrades,
                 build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript());
-        }\r
+        }
         upgrade_log_start();
-\r
+
         print_heading('blocks');
 
     /// Run de old and new upgrade functions for the module
@@ -1116,9 +1116,9 @@ function upgrade_blocks_db($continueto) {
     /// First, the old function if exists
         $oldupgrade_status = true;
         if ($oldupgrade && function_exists($oldupgrade_function)) {
-            if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+            if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
             $db->debug = true;
-            }\r
+            }
             $oldupgrade_status = $oldupgrade_function($CFG->blocks_version);
         } else if ($oldupgrade) {
             notify ('Upgrade function ' . $oldupgrade_function . ' was not available in ' .
@@ -1128,32 +1128,32 @@ function upgrade_blocks_db($continueto) {
     /// Then, the new function if exists and the old one was ok
         $newupgrade_status = true;
         if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) {
-            if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+            if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
             $db->debug = true;
-            }\r
+            }
             $newupgrade_status = $newupgrade_function($CFG->blocks_version);
         } else if ($newupgrade) {
             notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' .
                      '/blocks/db/upgrade.php');
         }
-        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
         $db->debug=false;
-        }\r
+        }
     /// Now analyze upgrade results
         if ($oldupgrade_status && $newupgrade_status) {    // No upgrading failed
             if (set_config('blocks_version', $blocks_version)) {
                 notify(get_string('databasesuccess'), 'notifysuccess');
                 notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess');
-                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                 print_continue($continueto);
                 print_footer('none');
                 exit;
-                }\r
+                }
             } else {
-                error('Upgrade of blocks system failed! (Could not update version in config table)');
+                print_error('Upgrade of blocks system failed! (Could not update version in config table)');
             }
         } else {
-            error('Upgrade failed!  See blocks/version.php');
+            print_error('Upgrade failed!  See blocks/version.php');
         }
 
     } else if ($blocks_version < $CFG->blocks_version) {
@@ -1167,7 +1167,7 @@ function upgrade_blocks_db($continueto) {
 //into blocks table or do all the upgrade process if newer
 function upgrade_blocks_plugins($continueto) {
 
-    global $CFG, $db, $interactive;\r
+    global $CFG, $db, $interactive;
 
     $blocktitles = array();
     $invalidblocks = array();
@@ -1186,12 +1186,12 @@ function upgrade_blocks_plugins($continueto) {
     $site = get_site();
 
     if (!$blocks = get_list_of_plugins('blocks', 'db') ) {
-        error('No blocks installed!');
+        print_error('No blocks installed!');
     }
 
     include_once($CFG->dirroot .'/blocks/moodleblock.class.php');
     if(!class_exists('block_base')) {
-        error('Class block_base is not defined or file not found for /blocks/moodleblock.class.php');
+        print_error('Class block_base is not defined or file not found for /blocks/moodleblock.class.php');
     }
 
     foreach ($blocks as $blockname) {
@@ -1276,7 +1276,7 @@ function upgrade_blocks_plugins($continueto) {
             } else if ($currblock->version < $block->version) {
                 if (empty($updated_blocks)) {
                     $strblocksetup    = get_string('blocksetup');
-                    if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+                    if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                     print_header($strblocksetup, $strblocksetup,
                             build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '',
                             upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
@@ -1284,7 +1284,7 @@ function upgrade_blocks_plugins($continueto) {
                 }
                 $updated_blocks = true;
                 upgrade_log_start();
-\r
+
                 print_heading('New version of '.$blocktitle.' ('.$block->name.') exists');
                 @set_time_limit(0);  // To allow slow databases to complete the long SQL
 
@@ -1295,9 +1295,9 @@ function upgrade_blocks_plugins($continueto) {
             /// First, the old function if exists
                 $oldupgrade_status = true;
                 if ($oldupgrade && function_exists($oldupgrade_function)) {
-                    if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+                    if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                     $db->debug = true;
-                    }\r
+                    }
                     $oldupgrade_status = $oldupgrade_function($currblock->version, $block);
                 } else if ($oldupgrade) {
                     notify ('Upgrade function ' . $oldupgrade_function . ' was not available in ' .
@@ -1307,17 +1307,17 @@ function upgrade_blocks_plugins($continueto) {
             /// Then, the new function if exists and the old one was ok
                 $newupgrade_status = true;
                 if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) {
-                    if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+                    if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                     $db->debug = true;
-                    }\r
+                    }
                     $newupgrade_status = $newupgrade_function($currblock->version, $block);
                 } else if ($newupgrade) {
                     notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' .
                              $fullblock . '/db/upgrade.php');
                 }
-                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                 $db->debug=false;
-                }\r
+                }
             /// Now analyze upgrade results
                 if ($oldupgrade_status && $newupgrade_status) {    // No upgrading failed
 
@@ -1327,11 +1327,11 @@ function upgrade_blocks_plugins($continueto) {
                     // OK so far, now update the block record
                     $block->id = $currblock->id;
                     if (! update_record('block', $block)) {
-                        error('Could not update block '. $block->name .' record in block table!');
+                        print_error('Could not update block '. $block->name .' record in block table!');
                     }
                     $component = 'block/'.$block->name;
                     if (!update_capabilities($component)) {
-                        error('Could not update '.$block->name.' capabilities!');
+                        print_error('Could not update '.$block->name.' capabilities!');
                     }
 
                     events_update_definition($component);
@@ -1339,12 +1339,12 @@ function upgrade_blocks_plugins($continueto) {
                 } else {
                     notify('Upgrading block '. $block->name .' from '. $currblock->version .' to '. $block->version .' FAILED!');
                 }
-                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                 echo '<hr />';
-                }\r
+                }
             } else {
                 upgrade_log_start();
-                error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!');
+                print_error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!');
             }
 
         } else {    // block not installed yet, so install it
@@ -1363,26 +1363,26 @@ function upgrade_blocks_plugins($continueto) {
             if($conflictblock !== false && $conflictblock !== NULL) {
                 // Duplicate block titles are not allowed, they confuse people
                 // AND PHP's associative arrays ;)
-                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
-                error('<strong>Naming conflict</strong>: block <strong>'.$block->name.'</strong> has the same title with an existing block, <strong>'.$conflictblock.'</strong>!');
-                } else if (CLI_UPGRADE) {\r
-                    error('Naming conflict: block "'.$block->name.'" has the same title with an existing block, "'.$conflictblock.'"!');\r
-                }\r
+                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
+                    print_error('<strong>Naming conflict</strong>: block <strong>'.$block->name.'</strong> has the same title with an existing block, <strong>'.$conflictblock.'</strong>!');
+                } else if (CLI_UPGRADE) {
+                    print_error('Naming conflict: block "'.$block->name.'" has the same title with an existing block, "'.$conflictblock.'"!');
+                }
             }
             if (empty($updated_blocks)) {
                 $strblocksetup    = get_string('blocksetup');
-                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) {\r
+                if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) {
                 print_header($strblocksetup, $strblocksetup,
                         build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '',
                         upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
             }
-            }\r
+            }
             $updated_blocks = true;
             upgrade_log_start();
             print_heading($block->name);
-            if (!defined('CLI_UPGRADE')||!CLI_UPGRADE) {\r
+            if (!defined('CLI_UPGRADE')||!CLI_UPGRADE) {
             $db->debug = true;
-            }\r
+            }
             @set_time_limit(0);  // To allow slow databases to complete the long SQL
 
         /// Both old .sql files and new install.xml are supported
@@ -1395,9 +1395,9 @@ function upgrade_blocks_plugins($continueto) {
             } else {
                 $status = true;
             }
-            if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {\r
+            if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
             $db->debug = false;
-            }\r
+            }
             if ($status) {
                 if ($block->id = insert_record('block', $block)) {
                     $blockobj->after_install();
@@ -1408,14 +1408,14 @@ function upgrade_blocks_plugins($continueto) {
 
                     events_update_definition($component);
                     notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess');
-                    if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE) {\r
+                    if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE) {
                     echo '<hr />';
-                    }\r
+                    }
                 } else {
-                    error($block->name .' block could not be added to the block list!');
+                    print_error($block->name .' block could not be added to the block list!');
                 }
             } else {
-                error('Block '. $block->name .' tables could NOT be set up successfully!');
+                print_error('Block '. $block->name .' tables could NOT be set up successfully!');
             }
         }
 
@@ -1452,18 +1452,18 @@ function upgrade_blocks_plugins($continueto) {
     upgrade_log_finish();
 
     if (!empty($updated_blocks)) {
-        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) {\r
+        if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) {
         print_continue($continueto);
         print_footer('none');
         die;
-        } else if ( CLI_UPGRADE && ($interactive > CLI_SEMI) ) {\r
-            console_write(STDOUT,'askcontinue');\r
-            if (read_boolean()){\r
-                return ;\r
-            }else {\r
-                console_write(STDERR,'','',false);\r
-            }\r
-        }\r
+        } else if ( CLI_UPGRADE && ($interactive > CLI_SEMI) ) {
+            console_write(STDOUT,'askcontinue');
+            if (read_boolean()){
+                return ;
+            }else {
+                console_write(STDERR,'','',false);
+            }
+        }
     }
 }
 
index 662ceef41f113735b8e69930a5af6dab48863874..bb6f701cf1c452435118ab6919ac36ec1cd21211 100644 (file)
@@ -253,7 +253,7 @@ class csv_import_reader {
         global $USER;
 
         if (!$filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id, false)) {
-            error('Can not create temporary upload directory - verify moodledata permissions!');
+            print_error('Can not create temporary upload directory - verify moodledata permissions!');
         }
 
         // use current (non-conflicting) time stamp
index 2f49ef88df069312a0da0e04646a334f535536ee..0d25719fc727fc2dd8304d6c2ad44bc7c86f07be 100644 (file)
 function require_variable($var) {
     global $CFG;
     if (!empty($CFG->disableglobalshack)) {
-        error( 'The require_variable() function is deprecated.' );
+        print_error( 'The require_variable() function is deprecated.' );
     }
     if (! isset($var)) {
-        error('A required parameter was missing');
+        print_error('A required parameter was missing');
     }
 }
 
@@ -67,7 +67,7 @@ function require_variable($var) {
 function optional_variable(&$var, $default=0) {
     global $CFG;
     if (!empty($CFG->disableglobalshack)) {
-        error( "The optional_variable() function is deprecated ($var, $default)." );
+        print_error( "The optional_variable() function is deprecated ($var, $default)." );
     }
     if (! isset($var)) {
         $var = $default;
@@ -88,7 +88,7 @@ function nvl(&$var, $default='') {
     global $CFG;
 
     if (!empty($CFG->disableglobalshack)) {
-      error( "The nvl() function is deprecated ($var, $default)." );
+      print_error( "The nvl() function is deprecated ($var, $default)." );
     }
     return isset($var) ? $var : $default;
 }
index c6ab9a7b4d1f71d0488e6e92c81fce53fb48f6d2..9c24aa1a0cf428bbb44f887fdba0999cf94c385f 100644 (file)
@@ -673,7 +673,7 @@ function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
             strpos($sql, ' '.$CFG->prefix.'user_coursecreators ') ||
             strpos($sql, ' '.$CFG->prefix.'user_admins ')) {
             if (debugging()) { var_dump(debug_backtrace()); }
-            error('This SQL relies on obsolete tables!  Your code must be fixed by a developer.');
+            print_error('This SQL relies on obsolete tables!  Your code must be fixed by a developer.');
         }
     }
 
@@ -1459,7 +1459,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
     if (!empty($CFG->rolesactive)) {
         if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) {
             if (debugging()) { var_dump(debug_backtrace()); }
-            error('This SQL relies on obsolete tables ('.$table.')!  Your code must be fixed by a developer.');
+            print_error('This SQL relies on obsolete tables ('.$table.')!  Your code must be fixed by a developer.');
         }
     }
 
@@ -1652,7 +1652,7 @@ function update_record($table, $dataobject) {
     if (!empty($CFG->rolesactive)) {
         if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) {
             if (debugging()) { var_dump(debug_backtrace()); }
-            error('This SQL relies on obsolete tables ('.$table.')!  Your code must be fixed by a developer.');
+            print_error('This SQL relies on obsolete tables ('.$table.')!  Your code must be fixed by a developer.');
         }
     }
 
index 6f2206f4394dc4bfca0b3f041c08a4a84f68024d..7a47f62f3ed8f03f6ac18c200b28325438cc057a 100644 (file)
@@ -27,7 +27,7 @@
 
 
     if (! $course = get_record("course", "id", $id) ) {
-        error("That's an invalid course id");
+        print_error("That's an invalid course id");
     }
 
     require_login($course);
     }
 
     if (! $basedir = make_upload_directory("$course->id")) {
-        error("The site administrator needs to fix the file permissions");
+        print_error("The site administrator needs to fix the file permissions");
     }
 
     $baseweb = $CFG->wwwroot;
                 }
 
                 if (!zip_files($files,"$basedir/$wdir/$name")) {
-                    error(get_string("zipfileserror","error"));
+                    print_error("zipfileserror","error");
                 }
 
                 clearfilelist();
                 $file = basename($file);
 
                 if (!unzip_file("$basedir/$wdir/$file")) {
-                    error(get_string("unzipfileserror","error"));
+                    print_error("unzipfileserror","error");
                 }
 
                 echo "<center><form action=\"coursefiles.php\" method=\"get\">\n";
index 439792b6a48b9da8a2725c6796e67eba75b389db..c65366c09cdc74fa5d4f960dd94c1fc4a90dd81c 100644 (file)
@@ -66,11 +66,11 @@ class editorObject {
             // If args is an array search keys courseid and name.
             // Name represents editor name to load.
             if ( !array_key_exists('courseid', $args) ) {
-                error("Required variable courseid is missing!");
+                print_error("Required variable courseid is missing!");
             }
 
             if ( !array_key_exists('name', $args) ) {
-                error("Required variable name is missing!");
+                print_error("Required variable name is missing!");
             }
 
             $courseid   = clean_param($args['courseid'], PARAM_INT);
@@ -125,4 +125,4 @@ class editorObject {
     }
 
 }
-?>
\ No newline at end of file
+?>
index 6de33baf23542b85cd034be54eff42949b3cbd5b..c4e5d5268f30d3d034a09da0e972eb62347cc7a4 100644 (file)
@@ -699,7 +699,7 @@ function get_records_csv($file, $table) {
     }
 
     if(!($handle = @fopen($file, 'r'))) {
-        error('get_records_csv failed to open '.$file);
+        print_error('get_records_csv failed to open '.$file);
     }
 
     $fieldnames = fgetcsv($handle, 4096);
@@ -746,7 +746,7 @@ function put_records_csv($file, $records, $table = NULL) {
     echo "x";
 
     if(!($fp = @fopen($CFG->dataroot.'/temp/'.$file, 'w'))) {
-        error('put_records_csv failed to open '.$file);
+        print_error('put_records_csv failed to open '.$file);
     }
 
     $proto = reset($records);
index 794e14f5259b7478591570ee004ad9d07ac85175..6b031fc69ed64f1c01ac8b27cb9540d5e6a55165 100644 (file)
@@ -25,7 +25,7 @@ for ($i=1; ; $i++){
                 $topics[$i] = helplink('text', get_string('helptext'));
                 break;
             default :
-                error('Unknown help topic '.$item);
+                print_error('Unknown help topic '.$item);
         }
     } else {
         $keyword = optional_param("keyword$i", '', PARAM_ALPHAEXT);
index e2f3e7dea04c29c47341d3cd858068d91108fb34..b4f81700f689a8292f7d2c4d7e9d13334b59e7d2 100644 (file)
@@ -182,7 +182,7 @@ class moodleform {
         // the _qf__.$this->_formname serves as a marker that form was actually submitted
         if (array_key_exists('_qf__'.$this->_formname, $submission) and $submission['_qf__'.$this->_formname] == 1) {
             if (!confirm_sesskey()) {
-                error('Incorrect sesskey submitted, form not accepted!');
+                print_error('Incorrect sesskey submitted, form not accepted!');
             }
             $files = $_FILES;
         } else {
@@ -225,7 +225,7 @@ class moodleform {
                     $files[$elname] = $this->_upload_manager->files[$elname]['tmp_name'];
                 }
             } else {
-                error('Incorrect upload attempt!');
+                print_error('Incorrect upload attempt!');
             }
         }
 
@@ -489,7 +489,7 @@ class moodleform {
      * If you need special handling of uploaded files, create instance of $this->_upload_manager here.
      */
     function definition() {
-        error('Abstract form_definition() method in class '.get_class($this).' must be overriden, please fix the code.');
+        print_error('Abstract form_definition() method in class '.get_class($this).' must be overriden, please fix the code.');
     }
 
     /**
index d678c1a9da7335c3f35eb55defb40498fe242e46..b5fc1880408f662f239eaa7452da44e9c6c68710 100644 (file)
@@ -298,7 +298,7 @@ class grade_category extends grade_object {
     function insert($source=null) {
 
         if (empty($this->courseid)) {
-            error('Can not insert grade category without course id!');
+            print_error('Can not insert grade category without course id!');
         }
 
         if (empty($this->parent)) {
@@ -1046,11 +1046,11 @@ class grade_category extends grade_object {
         }
 
         if ($parentid == $this->id) {
-            error('Can not assign self as parent!');
+            print_error('Can not assign self as parent!');
         }
 
         if (empty($this->parent) and $this->is_course_category()) {
-            error('Course category can not have parent!');
+            print_error('Course category can not have parent!');
         }
 
         // find parent and check course id
index f23fd2432059a7cb177111f7a04d93ebf987e2ee..694d2923a6cabfc0445398f3e90f7522c1faeb1b 100644 (file)
@@ -560,7 +560,7 @@ class grade_grade extends grade_object {
         global $CFG;
 
         if (count($grade_grades) !== count($grade_items)) {
-            error('Incorrect size of arrays in params of grade_grade::get_hiding_affected()!');
+            print_error('Incorrect size of arrays in params of grade_grade::get_hiding_affected()!');
         }
 
         $dependson = array();
index 3db1376de888d53db381b4e76b443a11f00b0fd6..69b0957c0019cc347d4a69ac1f0b3f7e7e0fdce1 100644 (file)
@@ -370,7 +370,7 @@ class grade_item extends grade_object {
         global $CFG;
 
         if (empty($this->courseid)) {
-            error('Can not insert grade item without course id!');
+            print_error('Can not insert grade item without course id!');
         }
 
         // load scale if needed
@@ -1188,7 +1188,7 @@ class grade_item extends grade_object {
      */
     function set_parent($parentid) {
         if ($this->is_course_item() or $this->is_category_item()) {
-            error('Can not set parent for category or course item!');
+            print_error('Can not set parent for category or course item!');
         }
 
         if ($this->categoryid == $parentid) {
index b730ee81afe5428f01ff3eaa5d728fb7f21b2e6c..c96a97235408348c99a48c04e7edfd3a4dadc47a 100644 (file)
@@ -110,7 +110,7 @@ class grade_object {
      * @return object grade_object instance or false if none found.
      */
     function fetch($params) {
-        error('Abstract method fetch() not overridden in '.get_class($this));
+        print_error('Abstract method fetch() not overridden in '.get_class($this));
     }
 
     /**
@@ -121,7 +121,7 @@ class grade_object {
      * @return array array of grade_object insatnces or false if none found.
      */
     function fetch_all($params) {
-        error('Abstract method fetch_all() not overridden in '.get_class($this));
+        print_error('Abstract method fetch_all() not overridden in '.get_class($this));
     }
 
     /**
@@ -133,7 +133,7 @@ class grade_object {
         if ($instances = grade_object::fetch_all_helper($table, $classname, $params)) {
             if (count($instances) > 1) {
                 // we should not tolerate any errors here - problems might appear later
-                error('Found more than one record in fetch() !');
+                print_error('Found more than one record in fetch() !');
             }
             return reset($instances);
         } else {
index 5bc322f6e217012e85dd6b840b9f8731a15de723..3987cd6b3a77d5b6fea524e36fceeabd7ad2b0a7 100644 (file)
@@ -840,7 +840,7 @@ function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null)
     if ($userid) {
         // one raw grade updated for one user
         if (empty($updated_item)) {
-            error("updated_item_id can not be null!");
+            print_error("updated_item_id can not be null!");
         }
         if ($course_item->needsupdate) {
             $updated_item->force_regrading();
@@ -951,7 +951,7 @@ function grade_grab_legacy_grades($courseid) {
     global $CFG;
 
     if (!$mods = get_list_of_plugins('mod') ) {
-        error('No modules installed!');
+        print_error('No modules installed!');
     }
 
     foreach ($mods as $mod) {
@@ -997,7 +997,7 @@ function grade_grab_course_grades($courseid, $modname=null) {
     }
 
     if (!$mods = get_list_of_plugins('mod') ) {
-        error('No modules installed!');
+        print_error('No modules installed!');
     }
 
     foreach ($mods as $mod) {
index 99773ff187cdf216154d6ccdb0f4f355478baf07..136ed2035cae63b3c1c953e8ae2dae3881a326d6 100644 (file)
@@ -319,7 +319,7 @@ function groups_get_activity_groupmode($cm, $course=null) {
         $course = $COURSE;
     } else {
         if (!$course = get_record('course', 'id', $cm->course)) {
-            error('Incorrect course id in cm');
+            print_error('Incorrect course id in cm');
         }
     }
 
index f300072a9b12f065d02ca8bb6c468983840946a8..d67abb39928d62ba510a2c3ea49d0b5fd52167c5 100644 (file)
@@ -163,13 +163,13 @@ function upgrade_local_db($continueto) {
                     }
                 }
             } else {
-                error('Upgrade of local database customisations failed! (Could not update version in config table)');
+                print_error('Upgrade of local database customisations failed! (Could not update version in config table)');
             }
         } else {
             if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
             $db->debug=false;
             }
-            error('Upgrade failed!  See local/version.php');
+            print_error('Upgrade failed!  See local/version.php');
         }
 
     } else if ($local_version < $CFG->local_version) {
index f4857630a502749690b383a3ca031a307213887d..fdb4c7c3363d5d1ac61287c457ddeba96586cfa5 100644 (file)
@@ -298,7 +298,7 @@ function required_param($parname, $type=PARAM_CLEAN) {
     } else if (isset($_GET[$parname])) {
         $param = $_GET[$parname];
     } else {
-        error('A required parameter ('.$parname.') was missing');
+        print_error('A required parameter ('.$parname.') was missing');
     }
 
     return clean_param($param, $type);
@@ -588,7 +588,7 @@ function clean_param($param, $type) {
             }
 
         default:                 // throw error, switched parameters in optional_param or another serious problem
-            error("Unknown parameter type: $type");
+            print_error("Unknown parameter type: $type");
     }
 }
 
@@ -1800,7 +1800,7 @@ function course_setup($courseorid=0) {
             $COURSE = clone($course);
         } else {
             if (!$COURSE = get_record('course', 'id', $courseorid)) {
-                error('Invalid course ID');
+                print_error('Invalid course ID');
             }
         }
     }
@@ -2139,7 +2139,7 @@ function require_user_key_login($script, $instance=null) {
     global $nomoodlecookie, $USER, $SESSION, $CFG;
 
     if (empty($nomoodlecookie)) {
-        error('Incorrect use of require_key_login() - session cookies must be disabled!');
+        print_error('Incorrect use of require_key_login() - session cookies must be disabled!');
     }
 
 /// extra safety
@@ -2148,22 +2148,22 @@ function require_user_key_login($script, $instance=null) {
     $keyvalue = required_param('key', PARAM_ALPHANUM);
 
     if (!$key = get_record('user_private_key', 'script', $script, 'value', $keyvalue, 'instance', $instance)) {
-        error('Incorrect key');
+        print_error('Incorrect key');
     }
 
     if (!empty($key->validuntil) and $key->validuntil < time()) {
-        error('Expired key');
+        print_error('Expired key');
     }
 
     if ($key->iprestriction) {
         $remoteaddr = getremoteaddr();
         if ($remoteaddr == '' or !address_in_subnet($remoteaddr, $key->iprestriction)) {
-            error('Client IP address mismatch');
+            print_error('Client IP address mismatch');
         }
     }
 
     if (!$user = get_record('user', 'id', $key->userid)) {
-        error('Incorrect user record');
+        print_error('Incorrect user record');
     }
 
 /// emulate normal session
@@ -2206,7 +2206,7 @@ function create_user_key($script, $userid, $instance=null, $iprestriction=null,
     }
 
     if (!insert_record('user_private_key', $key)) {
-        error('Can not insert new key');
+        print_error('Can not insert new key');
     }
 
     return $key->value;
@@ -2707,7 +2707,7 @@ function get_auth_plugin($auth) {
 
     // check the plugin exists first
     if (! exists_auth_plugin($auth)) {
-        error("Authentication plugin '$auth' not found.");
+        print_error("Authentication plugin '$auth' not found.");
     }
 
     // return auth plugin instance
@@ -3466,7 +3466,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
     $result = true;
 
     if (! $course = get_record('course', 'id', $courseid)) {
-        error('Course ID was incorrect (can\'t find it)');
+        print_error('Course ID was incorrect (can\'t find it)');
     }
 
     $strdeleted = get_string('deleted');
@@ -3517,7 +3517,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
             }
         }
     } else {
-        error('No modules are installed!');
+        print_error('No modules are installed!');
     }
 
 /// Give local code a chance to delete its references to this course.
@@ -4263,7 +4263,7 @@ function reset_password_and_mail($user) {
     $newpassword = generate_password();
 
     if (!$userauth->user_update_password(addslashes_recursive($user), addslashes($newpassword))) {
-        error("Could not set user password!");
+        print_error("Could not set user password!");
     }
 
     $a = new object();
index c6053d3ef8b7e04fea6ffcbf4d9b7925d9d3135b..2b10047aa5a4987d6d0975d1398dc6c5ac167234 100644 (file)
@@ -32,7 +32,7 @@ function page_import_types($path) {
     if(is_file($file)) {
         require($file);
         if(!isset($DEFINEDPAGES)) {
-            error('Imported '.$file.' but found no page classes');
+            print_error('Imported '.$file.' but found no page classes');
         }
         return $types[$path] = $DEFINEDPAGES;
     }
@@ -314,7 +314,7 @@ class page_course extends page_base {
     // Do NOT load up "expensive" resouces (e.g. SQL data) here!
     function init_quick($data) {
         if(empty($data->pageid) && !defined('ADMIN_STICKYBLOCKS')) {
-            error('Cannot quickly initialize page: empty course id');
+            print_error('Cannot quickly initialize page: empty course id');
         }
         parent::init_quick($data);
     }
@@ -338,7 +338,7 @@ class page_course extends page_base {
         }
 
         if(empty($this->courserecord) && !defined('ADMIN_STICKYBLOCKS')) {
-            error('Cannot fully initialize page: invalid course id '. $this->id);
+            print_error('Cannot fully initialize page: invalid course id '. $this->id);
         }
 
         $this->context = get_context_instance(CONTEXT_COURSE, $this->id);
@@ -588,18 +588,18 @@ class page_generic_activity extends page_base {
             return;
         }
         if(empty($this->activityname)) {
-            error('Page object derived from page_generic_activity but did not define $this->activityname');
+            print_error('Page object derived from page_generic_activity but did not define $this->activityname');
         }
         if (!$this->modulerecord = get_coursemodule_from_instance($this->activityname, $this->id)) {
-            error('Cannot fully initialize page: invalid '.$this->activityname.' instance id '. $this->id);
+            print_error('Cannot fully initialize page: invalid '.$this->activityname.' instance id '. $this->id);
         }
         $this->courserecord = get_record('course', 'id', $this->modulerecord->course);
         if(empty($this->courserecord)) {
-            error('Cannot fully initialize page: invalid course id '. $this->modulerecord->course);
+            print_error('Cannot fully initialize page: invalid course id '. $this->modulerecord->course);
         }
         $this->activityrecord = get_record($this->activityname, 'id', $this->id);
         if(empty($this->activityrecord)) {
-            error('Cannot fully initialize page: invalid '.$this->activityname.' id '. $this->id);
+            print_error('Cannot fully initialize page: invalid '.$this->activityname.' id '. $this->id);
         }
         $this->full_init_done = true;
     }
index 543b7595ac1069235924ad74a5852e232f961807..64da4dac8d909b76ada9d8fbd442e5f70fead1ed 100644 (file)
@@ -578,6 +578,41 @@ function questionbank_navigation_tabs(&$row, $contexts, $querystring) {
     }
 }
 
+/**
+ * Load a set of questions, given a list of ids. The $join and $extrafields arguments can be used
+ * together to pull in extra data. See, for example, the usage in mod/quiz/attempt.php, and 
+ * read the code below to see how the SQL is assembled. 
+ *
+ * @param string $questionlist list of comma-separated question ids.
+ * @param string $extrafields
+ * @param string $join
+ *
+ * @return mixed array of question objects on success, a string error message on failure.
+ */
+function question_load_questions($questionlist, $extrafields = '', $join = '') {
+    global $CFG;
+    if ($join) {
+        $join = ' JOIN ' . $CFG->prefix . $join;
+    }
+    if ($extrafields) {
+        $extrafields = ', ' . $extrafields;
+    }
+    $sql = 'SELECT q.*' . $extrafields . ' FROM ' . $CFG->prefix . 'question q' . $join .
+            ' WHERE q.id IN (' . $questionlist . ')';
+
+    // Load the questions
+    if (!$questions = get_records_sql($sql)) {
+        return 'Could not load questions.';
+    }
+
+    // Load the question type specific information
+    if (!get_question_options($questions)) {
+        return 'Could not load the question options';
+    }
+
+    return $questions;
+}
+
 /**
  * Private function to factor common code out of get_question_options().
  *
@@ -829,7 +864,7 @@ function save_question_session(&$question, &$state) {
         $session->sumpenalty = $state->sumpenalty;
         $session->manualcomment = $state->manualcomment;
         if (!insert_record('question_sessions', $session)) {
-            error('Could not insert entry in question_sessions');
+            print_error('Could not insert entry in question_sessions');
         }
     } else {
         $session->newest = $state->id;
@@ -906,7 +941,7 @@ function question_extract_responses($questions, $formdata, $defaultevent=QUESTIO
         if (false !== ($quid = question_get_id_from_name_prefix($key))) {
             // check if this is a valid id
             if (!isset($questions[$quid])) {
-                error('Form contained question that is not in questionids');
+                print_error('Form contained question that is not in questionids');
             }
 
             // Remove the name prefix from the name
@@ -1315,7 +1350,7 @@ function get_question_image($question) {
     $img = '';
 
     if (!$category = get_record('question_categories', 'id', $question->category)){
-        error('invalid category id '.$question->category);
+        print_error('invalid category id '.$question->category);
     }
     $coursefilesdir = get_filesdir_from_context(get_context_instance_by_id($category->contextid));
 
@@ -1359,7 +1394,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad
     $comment = trim($comment);
     $state->manualcomment = $comment;
     if (!set_field('question_sessions', 'manualcomment', $comment, 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) {
-        error("Cannot save comment");
+        print_error("Cannot save comment");
     }
 
     // Update the attempt if the score has changed.
@@ -1367,7 +1402,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad
         $attempt->sumgrades = $attempt->sumgrades - $state->last_graded->grade + $grade;
         $attempt->timemodified = time();
         if (!update_record('quiz_attempts', $attempt)) {
-            error('Failed to save the current quiz attempt!');
+            print_error('Failed to save the current quiz attempt!');
         }
     }
 
@@ -1443,7 +1478,7 @@ function question_new_attempt_uniqueid($modulename='quiz') {
     $attempt = new stdClass;
     $attempt->modulename = $modulename;
     if (!$id = insert_record('question_attempts', $attempt)) {
-        error('Could not create new entry in question_attempts table');
+        print_error('Could not create new entry in question_attempts table');
     }
     return $id;
 }
@@ -1687,7 +1722,7 @@ function question_make_default_categories($contexts) {
     // If it already exists, just return it.
     foreach ($contexts as $key => $context) {
         if (!$categoryrs = get_recordset_select("question_categories", "contextid = '{$context->id}'", 'sortorder, name', '*', '', 1)) {
-            error('error getting category record');
+            print_error('error getting category record');
         } else {
             if (!$category = rs_fetch_record($categoryrs)){
                 // Otherwise, we need to make one
@@ -1700,7 +1735,7 @@ function question_make_default_categories($contexts) {
                 $category->sortorder = 999; // By default, all categories get this number, and are sorted alphabetically.
                 $category->stamp = make_unique_id_code();
                 if (!$category->id = insert_record('question_categories', $category)) {
-                    error('Error creating a default category for context '.print_context_name($context));
+                    print_error('Error creating a default category for context '.print_context_name($context));
                 }
             }
         }
@@ -2113,7 +2148,7 @@ function get_filesdir_from_context($context){
             $courseid = SITEID;
             break;
         default :
-            error('Unsupported contextlevel in category record!');
+            print_error('Unsupported contextlevel in category record!');
     }
     return $courseid;
 }
index 4934a25a66d93bcede63e2edb37ea3dab53413b0..65bb588def65bf50411cc8caba902fcc938940a8 100755 (executable)
@@ -36,7 +36,7 @@ function sample_function_handler($eventdata) {
         return true;
     }
 
-    error('Incorrect eventadata submitted: '.$eventdata);
+    print_error('Incorrect eventadata submitted: '.$eventdata);
 }
 
 // test handler class with static method
@@ -70,7 +70,7 @@ class sample_handler_class {
             return true;
         }
 
-        error('Incorrect eventadata submitted: '.$eventdata);
+        print_error('Incorrect eventadata submitted: '.$eventdata);
     }
 }
 
index 1831184698b393306c88b45997c1b77017593291..e6d26dc1400d7486026108110917178667c1735e 100644 (file)
@@ -3,7 +3,7 @@
     require_login();
 
 if (empty($CFG->aspellpath)) {
-    error('Spellchecker not configured');
+    print_error('Spellchecker not configured');
 }
 
 header('Content-type: text/html; charset=utf-8');
index fa271a3259dcf786649b6e7d12a806ca59a7cdc6..2bb44ee8e6851a43a2e109d3a8efe93548a7c0a9 100644 (file)
@@ -326,7 +326,7 @@ class moodle_url {
             }
             $parts = parse_url($url);
             if ($parts === FALSE){
-                error('invalidurl');
+                print_error('invalidurl');
             }
             if (isset($parts['query'])){
                 parse_str(str_replace('&amp;', '&', $parts['query']), $this->params);
@@ -703,7 +703,7 @@ function element_to_popup_window ($type=null, $url=null, $name=null, $linkname=n
                                   $options=null, $return=false, $id=null, $class=null) {
 
     if (is_null($url)) {
-        error('There must be an url to the popup. Can\'t create popup window.');
+        print_error('There must be an url to the popup. Can\'t create popup window.');
     }
 
     global $CFG;
@@ -757,7 +757,7 @@ function element_to_popup_window ($type=null, $url=null, $name=null, $linkname=n
                        "onclick=\"this.target='$name'; return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname</a>";
             break;
         default :
-            error('Undefined element - can\'t create popup window.');
+            print_error('Undefined element - can\'t create popup window.');
             break;
     }
 
@@ -2402,7 +2402,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
 
 /// This makes sure that the header is never repeated twice on a page
     if (defined('HEADER_PRINTED')) {
-        debugging('print_header() was called more than once - this should not happen.  Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().');
+        debugging('print_header() was called more than once - this should not happen.  Please check the code for this page closely. Note: print_error() and redirect() are now safe to call after print_header().');
         return;
     }
     define('HEADER_PRINTED', 'true');
@@ -3721,7 +3721,7 @@ function build_navigation($extranavlinks, $cm = null) {
                     'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '.
                     'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
             if (!$cm->modname = get_field('modules', 'name', 'id', $cm->module)) {
-                error('Cannot get the module type in build navigation.');
+                print_error('Cannot get the module type in build navigation.');
             }
         }
         if (!isset($cm->name)) {
@@ -3729,7 +3729,7 @@ function build_navigation($extranavlinks, $cm = null) {
                     'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '.
                     'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
             if (!$cm->name = get_field($cm->modname, 'name', 'id', $cm->instance)) {
-                error('Cannot get the module name in build navigation.');
+                print_error('Cannot get the module name in build navigation.');
             }
         }
         $navlinks[] = array(
@@ -5797,7 +5797,7 @@ function editorhelpbutton(){
                     $titles[] = get_string('helptext');
                     break;
                 default :
-                    error('Unknown help topic '.$item);
+                    print_error('Unknown help topic '.$item);
             }
         }
         $i++;
index d6482463bae5c1fa6df77f8485fda86d0aa05d94..81ca8dc9be1dc529a04dd5acca7662950ef28b63 100644 (file)
@@ -13,7 +13,7 @@
     $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 
     if (!$course = get_record('course', 'id', $id)) {
-        error('No such course!');
+        print_error('No such course!');
     }
 
     // require proper login; guest user can not change password
@@ -31,7 +31,7 @@
 
     // do not allow "Logged in as" users to change any passwords
     if (!empty($USER->realuser)) {
-        error('Can not use this script when "Logged in as"!');
+        print_error('Can not use this script when "Logged in as"!');
     }
 
     if (is_mnet_remote_user($USER)) {
         if ($idprovider = get_record('mnet_host', 'id', $USER->mnethostid)) {
             $message .= get_string('userchangepasswordlink', 'mnet', $idprovider);
         }
-        error($message);
+        print_error($message);
     }
 
     // load the appropriate auth plugin
     $userauth = get_auth_plugin($USER->auth);
 
     if (!$userauth->can_change_password()) {
-        error(get_string('nopasswordchange', 'auth'));
+        print_error('nopasswordchange', 'auth');
     }
 
     if ($changeurl = $userauth->change_password_url()) {
@@ -65,7 +65,7 @@
     } else if ($data = $mform->get_data()) {
 
         if (!$userauth->user_update_password(addslashes_recursive($USER), $data->newpassword1)) {
-            error(get_string('errorpasswordupdate', 'auth'));
+            print_error('errorpasswordupdate', 'auth');
         }
 
         // register success changing password
index f07a9865e4bb601208b4561cb1298278bee68ccb..04251de1c638b85814bbc593a0872ec6298faf9b 100644 (file)
@@ -8,12 +8,12 @@
     $s = optional_param('s', '', PARAM_CLEAN);        // Old parameter:  username
 
     if (empty($CFG->registerauth)) {
-        error("Sorry, you may not use this page.");
+        print_error("Sorry, you may not use this page.");
     }
     $authplugin = get_auth_plugin($CFG->registerauth);
 
     if (!$authplugin->can_confirm()) {
-        error("Sorry, you may not use this page.");
+        print_error("Sorry, you may not use this page.");
     }
 
     if (!empty($data) || (!empty($p) && !empty($s))) {
@@ -45,7 +45,7 @@
             // The user has confirmed successfully, let's log them in
 
             if (!$USER = get_complete_user_data('username', $username)) {
-                error("Something serious is wrong with the database");
+                print_error("Something serious is wrong with the database");
             }
 
             set_moodle_cookie($USER->username);
             print_footer();
             exit;
         } else {
-            error("Invalid confirmation data");
+            print_error("Invalid confirmation data");
         }
     } else {
-        error(get_string("errorwhenconfirming"));
+        print_error("errorwhenconfirming");
     }
 
     redirect("$CFG->wwwroot/");
index 286729db1d497d365b9eb14557dd69ffb8f04112..904cef44fe80ad097d745c2eed9eb10c1055de96 100644 (file)
@@ -41,14 +41,14 @@ if ($p_secret !== false) {
     $user = get_complete_user_data('username', $p_username);
     if (!empty($user) and $user->secret === '') {
         print_header($strforgotten, $strforgotten, $navigation);
-        error(get_string('secretalreadyused'));
+        print_error('secretalreadyused');
 
     } else if (!empty($user) and $user->secret == stripslashes($p_secret)) {
         // make sure that url relates to a valid user
 
         // check this isn't guest user
         if (isguestuser($user)) {
-            error('You cannot reset the guest password');
+            print_error('You cannot reset the guest password');
         }
 
         // make sure user is allowed to change password
@@ -57,13 +57,13 @@ if ($p_secret !== false) {
         // override email stop and mail new password
         $user->emailstop = 0;
         if (!reset_password_and_mail($user)) {
-            error('Error resetting password and mailing you');
+            print_error('Error resetting password and mailing you');
         }
 
         // Clear secret so that it can not be used again
         $user->secret = '';
         if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
-            error('Error resetting user secret string');
+            print_error('Error resetting user secret string');
         }
 
         reset_login_count();
@@ -78,7 +78,7 @@ if ($p_secret !== false) {
 
     } else {
         print_header($strforgotten, $strforgotten, $navigation);
-        error(get_string('forgotteninvalidurl'));
+        print_error('forgotteninvalidurl');
     }
 
     die; //never reached
@@ -115,16 +115,16 @@ if ($mform->is_cancelled()) {
             // set 'secret' string
             $user->secret = random_string(15);
             if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
-                error('error setting user secret string');
+                print_error('error setting user secret string');
             }
 
             if (!send_password_change_confirmation_email($user)) {
-                error('error sending password change confirmation email');
+                print_error('error sending password change confirmation email');
             }
 
         } else {
             if (!send_password_change_info($user)) {
-                error('error sending password change confirmation email');
+                print_error('error sending password change confirmation email');
             }
         }
     }
index e8b24cb57368ed8d06efd7b3e2f964805195c2a9..3a3da1d449e1ba2fd03f3d3c3e17e0b09c6d86cc 100644 (file)
@@ -56,7 +56,7 @@ httpsrequired();
 
 /// Define variables used in page
     if (!$site = get_site()) {
-        error("No site found!");
+        print_error("No site found!");
     }
 
     if (empty($CFG->langmenu)) {
index 1cac1cb109227c7464e7b504da69a98fa6e849ab..a3e6e2fcbe54e47d8ccbfff73a4ed3b00b96a137 100644 (file)
     
 
     if (empty($CFG->registerauth)) {
-        error("Sorry, you may not use this page.");
+        print_error("Sorry, you may not use this page.");
     }
     $authplugin = get_auth_plugin($CFG->registerauth);
 
     if (!$authplugin->can_signup()) {
-        error("Sorry, you may not use this page.");
+        print_error("Sorry, you may not use this page.");
     }
 
     //HTTPS is potentially required in this page
index e1cbaca52435241ba95d053311d0db7e47aa7939..1ac476e9cc6d52ec4f388ba8c8cf04acf1d8c656 100644 (file)
@@ -10,7 +10,7 @@
     }
 
     if (empty($CFG->messaging)) {
-        error("Messaging is disabled on this site");
+        print_error("Messaging is disabled on this site");
     }
 
 /// Script parameters
@@ -19,7 +19,7 @@
 
 /// Check the user we are talking to is valid
     if (! $user = get_record('user', 'id', $userid)) {
-        error("User ID was incorrect");
+        print_error("User ID was incorrect");
     }
 
 /// Check if frame&jsless mode selected
index f0d254d1e5e52dc0b93bfd9b8c228817b1b011b1..6b9f2b4df96947918b57ebcbee42fead2c68917a 100644 (file)
     }
 
     if (empty($CFG->messaging)) {
-        error("Messaging is disabled on this site");
+        print_error("Messaging is disabled on this site");
     }
 
 /// Script parameters
     $userid1 = required_param('user1', PARAM_INT);
     if (! $user1 = get_record("user", "id", $userid1)) {  // Check it's correct
-        error("User ID 1 was incorrect");
+        print_error("User ID 1 was incorrect");
     }
 
     if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM, SITEID))) {             // Able to see any discussion
         $userid2 = optional_param('user2', $USER->id, PARAM_INT);
         if (! $user2 = get_record("user", "id", $userid2)) {  // Check
-            error("User ID 2 was incorrect");
+            print_error("User ID 2 was incorrect");
         }
     } else {
         $userid2 = $USER->id;    // Can only see messages involving yourself
index 21ed8814674b447ca87982eac3bc9881ee2442df..53c4511ac38c2675b63ffcce8bdb54a246ebf5e6 100644 (file)
@@ -11,7 +11,7 @@
     }
 
     if (empty($CFG->messaging)) {
-        error("Messaging is disabled on this site");
+        print_error("Messaging is disabled on this site");
     }
 
 /// Optional variables that may be passed in
index 3f480dae708ae1bd28f74dc3fa5513d822072c08..891055413b71bed1aaea4cc2f89827507c8528f4 100644 (file)
@@ -11,7 +11,7 @@
     }
 
     if (empty($CFG->messaging)) {
-        error("Messaging is disabled on this site");
+        print_error("Messaging is disabled on this site");
     }
 
 /// Script parameters
index c8d085a5331b464f3f9179489c868729c2598dcb..a2c4206e87f2bc5fd0dd2d1d28fa9a1ddba93d47 100644 (file)
@@ -10,7 +10,7 @@ if (isguest()) {
 }
 
 if (empty($CFG->messaging)) {
-    error("Messaging is disabled on this site");
+    print_error("Messaging is disabled on this site");
 }
 
 if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
@@ -42,7 +42,7 @@ if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTE
 
 /// Check the user we are talking to is valid
     if (! $user = get_record('user', 'id', $userid)) {
-        error("User ID was incorrect");
+        print_error("User ID was incorrect");
     }
 
 /// Check that the user is not blocking us!!
index 9546f618102db3a40abc6e4292e4a75a6ce74286..b715002488bf6fe8214113f4d6629501c731f8fd 100644 (file)
@@ -10,7 +10,7 @@
     }
 
     if (empty($CFG->messaging)) {
-        error("Messaging is disabled on this site");
+        print_error("Messaging is disabled on this site");
     }
 
 /// Script parameters
@@ -23,7 +23,7 @@
 
 /// Check the user we are talking to is valid
     if (! $user = get_record('user', 'id', $userid)) {
-        error("User ID was incorrect");
+        print_error("User ID was incorrect");
     }
 
 /// Possibly change some contacts if requested
index 402727b8d19b54b66e1afdc29602b425c4c637a5..fe3e2039ee7686d1aa42645afaa605f497ee4ad9 100644 (file)
@@ -8,25 +8,25 @@
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('assignment', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
 
         if (! $assignment = get_record('assignment', 'id', $cm->instance)) {
-            error("assignment ID was incorrect");
+            print_error("assignment ID was incorrect");
         }
 
         if (! $course = get_record('course', 'id', $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
     } else {
         if (!$assignment = get_record('assignment', 'id', $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record('course', 'id', $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance('assignment', $assignment->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
 
index a4bd1b84996c0e8b95e7bac08627bc99be47137f..4bc1b99d674ae33bcdd5328596b287edc6df3ac1 100644 (file)
@@ -5,15 +5,15 @@
     $id   = required_param('id', PARAM_INT);          // Course module ID
 
     if (! $cm = get_coursemodule_from_id('assignment', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $assignment = get_record("assignment", "id", $cm->instance)) {
-        error("assignment ID was incorrect");
+        print_error("assignment ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $assignment->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
index 334266e95be041d086e1c51d48b9ab95d30617e5..39ac4bc4ecc95a0984d0f9045c57af410e0b3d41 100644 (file)
@@ -7,7 +7,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index 2ea77f7bf22ee74b60bab35e3a097ccac73c6c77..193286513a57e794a1d9ce4510f190e8cd0e00e4 100644 (file)
@@ -52,7 +52,7 @@ class assignment_base {
         if ($cm) {
             $this->cm = $cm;
         } else if (! $this->cm = get_coursemodule_from_id('assignment', $cmid)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
 
         $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
@@ -62,13 +62,13 @@ class assignment_base {
         } else if ($this->cm->course == $COURSE->id) {
             $this->course = $COURSE;
         } else if (! $this->course = get_record('course', 'id', $this->cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
 
         if ($assignment) {
             $this->assignment = $assignment;
         } else if (! $this->assignment = get_record('assignment', 'id', $this->cm->instance)) {
-            error('assignment ID was incorrect');
+            print_error('assignment ID was incorrect');
         }
 
         $this->assignment->cmidnumber = $this->cm->id;     // compatibility with modedit assignment obj
@@ -235,7 +235,7 @@ class assignment_base {
 
     /// We need the teacher info
         if (!$teacher = get_record('user', 'id', $graded_by)) {
-            error('Could not find the teacher');
+            print_error('Could not find the teacher');
         }
 
     /// Print the feedback
@@ -782,7 +782,7 @@ class assignment_base {
         $offset = required_param('offset', PARAM_INT);//offset for where to start looking for student.
 
         if (!$user = get_record('user', 'id', $userid)) {
-            error('No such user!');
+            print_error('No such user!');
         }
 
         if (!$submission = $this->get_submission($user->id)) {
@@ -1485,7 +1485,7 @@ class assignment_base {
         }
         $newsubmission = $this->prepare_new_submission($userid, $teachermodified);
         if (!insert_record("assignment_submissions", $newsubmission)) {
-            error("Could not insert a new empty submission");
+            print_error("Could not insert a new empty submission");
         }
 
         return get_record('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $userid);
index 7bf25f53b3677d717f2d6a05767fd985f66ce33e..33a0eb0e28a75b33d8e2217d2870366cc1ef6c79 100644 (file)
@@ -12,7 +12,7 @@ class mod_assignment_mod_form extends moodleform_mod {
             if($ass = get_record('assignment', 'id', (int)$this->_instance)) {
                 $type = $ass->assignmenttype;
             } else {
-                error('incorrect assignment');
+                print_error('incorrect assignment');
             }
         } else {
             $type = required_param('type', PARAM_ALPHA);
index 79e0caf594a33a6fd91fbd486981ec6229258c49..14428765b18eb66e28dfb367bfb31c127b64b36e 100644 (file)
@@ -9,25 +9,25 @@
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('assignment', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
 
         if (! $assignment = get_record("assignment", "id", $cm->instance)) {
-            error("assignment ID was incorrect");
+            print_error("assignment ID was incorrect");
         }
 
         if (! $course = get_record("course", "id", $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
     } else {
         if (!$assignment = get_record("assignment", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
 
index 349ada611c6f7edb5443f91528429093b453fa2a..eab82852791bb4fb5e25886ad1d546a5665cc722 100644 (file)
@@ -52,7 +52,7 @@ function assignment_type_online_upgrade($oldversion)  {
                 $newcm->added    = time();
 
                 if (! $newcm->id = add_course_module($newcm) ) {
-                    error("Could not add a new course module");
+                    print_error("Could not add a new course module");
                 }
                 
             /// And locate it above the old one
@@ -65,7 +65,7 @@ function assignment_type_online_upgrade($oldversion)  {
                 $newcm->section      = $section->section;  // need relative reference
 
                 if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) {  // Add it before Journal
-                    error("Could not add the new course module to that section");
+                    print_error("Could not add the new course module to that section");
                 }
                 
             /// Convert any existing entries from users
index 349ada611c6f7edb5443f91528429093b453fa2a..eab82852791bb4fb5e25886ad1d546a5665cc722 100644 (file)
@@ -52,7 +52,7 @@ function assignment_type_online_upgrade($oldversion)  {
                 $newcm->added    = time();
 
                 if (! $newcm->id = add_course_module($newcm) ) {
-                    error("Could not add a new course module");
+                    print_error("Could not add a new course module");
                 }
                 
             /// And locate it above the old one
@@ -65,7 +65,7 @@ function assignment_type_online_upgrade($oldversion)  {
                 $newcm->section      = $section->section;  // need relative reference
 
                 if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) {  // Add it before Journal
-                    error("Could not add the new course module to that section");
+                    print_error("Could not add the new course module to that section");
                 }
                 
             /// Convert any existing entries from users
index 2a613364eb05cdffc29004614bb179b432770aa6..63df4d05e45edc22ee00138abb78e1479003d675 100644 (file)
@@ -8,29 +8,29 @@
     $userid = required_param('userid', PARAM_INT);  // User ID
 
     if (! $cm = get_coursemodule_from_id('assignment', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $assignment = get_record("assignment", "id", $cm->instance)) {
-        error("Assignment ID was incorrect");
+        print_error("Assignment ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $assignment->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $user = get_record("user", "id", $userid)) {
-        error("User is misconfigured");
+        print_error("User is misconfigured");
     }
 
     require_login($course->id, false, $cm);
 
     if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
-        error("You can not view this assignment");
+        print_error("You can not view this assignment");
     }
 
     if ($assignment->assignmenttype != 'online') {
-        error("Incorrect assignment type");
+        print_error("Incorrect assignment type");
     }
 
     $assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course);
index e9bf56698799f9b99c96c4a4ed13d64aa6df8a25..428d4aed644b41139233698829409a4b43d1dc7b 100644 (file)
@@ -105,7 +105,7 @@ class assignment_upload extends assignment_base {
 
     /// We need the teacher info
         if (!$teacher = get_record('user', 'id', $graded_by)) {
-            error('Could not find the teacher');
+            print_error('Could not find the teacher');
         }
 
     /// Print the feedback
@@ -468,7 +468,7 @@ class assignment_upload extends assignment_base {
             case 'editnotes':
                 $this->upload_notes();
             default:
-                error('Error: Unknow upload action ('.$action.').');
+                print_error('Error: Unknow upload action ('.$action.').');
         }
     }
 
index 0887c9eb741b20692fefcdaf01d93fe4a1637d65..77cc82a6bb1f02a237d089840a7105fab1abb601 100644 (file)
     $mode   = optional_param('mode', '', PARAM_ALPHA);
 
     if (! $cm = get_coursemodule_from_id('assignment', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $assignment = get_record('assignment', 'id', $cm->instance)) {
-        error("Assignment ID was incorrect");
+        print_error("Assignment ID was incorrect");
     }
 
     if (! $course = get_record('course', 'id', $assignment->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $user = get_record('user', 'id', $userid)) {
-        error("User is misconfigured");
+        print_error("User is misconfigured");
     }
 
     require_login($course->id, false, $cm);
 
     if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
-        error("You can not view this assignment");
+        print_error("You can not view this assignment");
     }
 
     if ($assignment->assignmenttype != 'upload') {
-        error("Incorrect assignment type");
+        print_error("Incorrect assignment type");
     }
 
     $assignmentinstance = new assignment_upload($cm->id, $assignment, $cm, $course);
index e866cdff02381e0783fa55a14179bfad24fb0c28..759a4724c88f01a30284e5367e036ca5c7cdbe26 100644 (file)
@@ -8,25 +8,25 @@
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('assignment', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
 
         if (! $assignment = get_record("assignment", "id", $cm->instance)) {
-            error("assignment ID was incorrect");
+            print_error("assignment ID was incorrect");
         }
 
         if (! $course = get_record("course", "id", $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
     } else {
         if (!$assignment = get_record("assignment", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
 
index 495a719a14ce4db73d2823de3317d37444f2bf0a..123b54a2d469ce926e40599f52e17c3aad1e2aa5 100644 (file)
@@ -8,25 +8,25 @@
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('assignment', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
 
         if (! $assignment = get_record("assignment", "id", $cm->instance)) {
-            error("assignment ID was incorrect");
+            print_error("assignment ID was incorrect");
         }
 
         if (! $course = get_record("course", "id", $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
     } else {
         if (!$assignment = get_record("assignment", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $assignment->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
 
index 79509f18cf57ef6428639ab6eb9e5887ebbd4d85..58a5a48e5b2ef4cdaae7cccb80b04ff31ef8da5f 100644 (file)
     $newonly = optional_param('newonly', 0, PARAM_BOOL); // show only new messages
 
     if (!$chat = get_record('chat', 'id', $id)) {
-        error('Could not find that chat room!');
+        print_error('Could not find that chat room!');
     }
 
     if (!$course = get_record('course', 'id', $chat->course)) {
-        error('Could not find the course this belongs to!');
+        print_error('Could not find the course this belongs to!');
     }
 
     if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -30,7 +30,7 @@
      if ($groupmode = groups_get_activity_groupmode($cm)) {   // Groups are being used
         if ($groupid = groups_get_activity_group($cm)) {
             if (!$group = groups_get_group($groupid, false)) {
-                error("That group (id $groupid) doesn't exist!");
+                print_error("That group (id $groupid) doesn't exist!");
             }
             $groupname = ': '.$group->name;
         } else {
     $strchats = get_string('modulenameplural', 'chat');
     $stridle  = get_String('idle', 'chat');
     if (!$chat_sid = chat_login_user($chat->id, 'basic', $groupid, $course)) {
-        error('Could not log in to chat room!!');
+        print_error('Could not log in to chat room!!');
     }
 
     if (!$chatusers = chat_get_users($chat->id, $groupid, $cm->groupingid)) {
-        error(get_string('errornousers', 'chat'));
+        print_error('errornousers', 'chat');
     }
 
     set_field('chat_users', 'lastping', time(), 'sid', $chat_sid);
@@ -81,7 +81,7 @@
             $newmessage->message = $message;
             $newmessage->timestamp = time();
             if (!insert_record('chat_messages', $newmessage)) {
-                error('Could not insert a chat message!');
+                print_error('Could not insert a chat message!');
             }
 
             set_field('chat_users', 'lastmessageping', time(), 'sid', $chat_sid);
index f01cdd1a72964a0c318ad3039dd2cd2b386faf63..7d37c5cda94145dc64a8e9f71253b520d5dd1e2b 100644 (file)
@@ -8,7 +8,7 @@
     $chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
 
     if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
-        error('Not logged in!');
+        print_error('Not logged in!');
     }
 
     //Get the user theme
index f82eb5060b9adf48f35b3fac3be4df5abd17b0f8..ee8984e782a7561f039c80e8c42d24c09dd27c4a 100644 (file)
@@ -7,15 +7,15 @@
     $groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
 
     if (!$chat = get_record('chat', 'id', $id)) {
-        error('Could not find that chat room!');
+        print_error('Could not find that chat room!');
     }
 
     if (!$course = get_record('course', 'id', $chat->course)) {
-        error('Could not find the course this belongs to!');
+        print_error('Could not find the course this belongs to!');
     }
 
     if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -33,7 +33,7 @@
      if ($groupmode = groups_get_activity_groupmode($cm)) {   // Groups are being used
         if ($groupid = groups_get_activity_group($cm)) {
             if (!$group = groups_get_group($groupid, false)) {
-                error("That group (id $groupid) doesn't exist!");
+                print_error("That group (id $groupid) doesn't exist!");
             }
             $groupname = ': '.$group->name;
         } else {
@@ -47,7 +47,7 @@
     $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
 
     if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course)) {
-        error('Could not log in to chat room!!');
+        print_error('Could not log in to chat room!!');
     }
 
     $params = "chat_sid=$chat_sid";
index 62f0dc8147e96aee0c380de1075a9862f1420445..a7f84873ed67328b05486941db0ce8ceb2255c49 100644 (file)
@@ -7,25 +7,25 @@
     $chat_message = required_param('chat_message', PARAM_RAW);
 
     if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
-        error('Not logged in!');
+        print_error('Not logged in!');
     }
 
     if (!$chat = get_record('chat', 'id', $chatuser->chatid)) {
-        error('No chat found');
+        print_error('No chat found');
     }
 
     if (!$course = get_record('course', 'id', $chat->course)) {
-        error('Could not find the course this belongs to!');
+        print_error('Could not find the course this belongs to!');
     }
 
     if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     
     require_login($course->id, false, $cm);
 
     if (isguest()) {
-        error('Guest does not have access to chat rooms');
+        print_error('Guest does not have access to chat rooms');
     }
 
     session_write_close();
@@ -50,7 +50,7 @@
         $message->timestamp = time();
 
         if (!insert_record('chat_messages', $message)) {
-            error('Could not insert a chat message!');
+            print_error('Could not insert a chat message!');
         }
 
         $chatuser->lastmessageping = time() - 2;
index d288f0ed0dddf30a7cc73a16e68a01f30d98af99..9ec8d240d60182ecd3d70a9024fb8a79d293f17c 100644 (file)
     $chat_lastrow  = optional_param('chat_lastrow', 1, PARAM_INT);
 
     if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
-        error('Not logged in!');
+        print_error('Not logged in!');
     }
 
     //Get the minimal course
     if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
-        error('incorrect course id');
+        print_error('incorrect course id');
     }
 
     //Get the user theme and enough info to be used in chat_format_message() which passes it along to
     if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future!
-        error('User does not exist!');
+        print_error('User does not exist!');
     }
     $USER->description = '';
 
index 4bee2b32f6ea3322d1ca5126dea307bbeaee43c3..ee7fd84c2fdb15f7ef787691b89f93dee4efc9d1 100644 (file)
     $chat_lastid   = optional_param('chat_lastid',    0, PARAM_INT);
 
     if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
-        error('Not logged in!');
+        print_error('Not logged in!');
     }
 
     //Get the minimal course
     if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
-        error('incorrect course id');
+        print_error('incorrect course id');
     }
 
     //Get the user theme and enough info to be used in chat_format_message() which passes it along to
     // chat_format_message_manually() -- and only id and timezone are used.
     if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future!
-        error('User does not exist!');
+        print_error('User does not exist!');
     }
     $USER->description = '';
 
index ea1ef674a765fabb3f743cf08b58b18a9224f296..de13609f3da8509249942b2544b569797ba92b79 100644 (file)
@@ -9,17 +9,17 @@
     $beep       = optional_param('beep', 0, PARAM_INT);  // beep target
 
     if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
-        error('Not logged in!');
+        print_error('Not logged in!');
     }
 
     //Get the minimal course
     if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
-        error('incorrect course id');
+        print_error('incorrect course id');
     }
 
     //Get the user theme and enough info to be used in chat_format_message() which passes it along to
     if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future!
-        error('User does not exist!');
+        print_error('User does not exist!');
     }
     $USER->description = '';
 
@@ -29,7 +29,7 @@
     $courseid = $chatuser->course;
 
     if (!$cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $courseid)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     if ($beep) {
@@ -41,7 +41,7 @@
         $message->timestamp = time();
 
         if (!insert_record('chat_messages', $message)) {
-            error('Could not insert a chat message!');
+            print_error('Could not insert a chat message!');
         }
 
         $chatuser->lastmessageping = time();          // A beep is a ping  ;-)
@@ -55,7 +55,7 @@
     /// Get list of users
 
     if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid)) {
-        error(get_string('errornousers', 'chat'));
+        print_error('errornousers', 'chat');
     }
 
     ob_start();
index 51697bcfe4d7a5c3e9b26b2299209892e8c1bdd3..3d32f4123c33dfbbb57517744d70458d97cb873d 100644 (file)
@@ -8,7 +8,7 @@
     $chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
 
     if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
-        error('Not logged in!');
+        print_error('Not logged in!');
     }
 
     //Get the user theme
index a7953abaea7cd5668cb7cb92460aa9aea8d775ef..30bfd4430e81b81ae625ac914b0143d9e79fb316 100644 (file)
@@ -7,21 +7,21 @@
     $groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
 
     if (!$chat = get_record('chat', 'id', $id)) {
-        error('Could not find that chat room!');
+        print_error('Could not find that chat room!');
     }
 
     if (!$course = get_record('course', 'id', $chat->course)) {
-        error('Could not find the course this belongs to!');
+        print_error('Could not find the course this belongs to!');
     }
 
     if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     require_login($course->id, false, $cm);
 
     if (isguest()) {
-        error('Guest does not have access to chat rooms');
+        print_error('Guest does not have access to chat rooms');
     }
 
     if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) {
@@ -33,7 +33,7 @@
      if ($groupmode = groups_get_activity_groupmode($cm)) {   // Groups are being used
         if ($groupid = groups_get_activity_group($cm)) {
             if (!$group = groups_get_group($groupid, false)) {
-                error("That group (id $groupid) doesn't exist!");
+                print_error("That group (id $groupid) doesn't exist!");
             }
             $groupname = ': '.$group->name;
         } else {
@@ -47,7 +47,7 @@
     $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
 
     if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) {
-        error('Could not log in to chat room!!');
+        print_error('Could not log in to chat room!!');
     }
 
     $params = "chat_sid=$chat_sid";
index a9a365fe9bbfcafaa6b4687dca18fe76c59313a3..c6bcaf0ee8cd6ee3672d832788124906c3eebcb3 100644 (file)
@@ -6,7 +6,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (! $course = get_record('course', 'id', $id)) {
-        error('Course ID is incorrect');
+        print_error('Course ID is incorrect');
     }
 
     require_course_login($course);
index ae361b9aab592601d6203bd43a9df3a8882b7621..ab5fa4215b00811b144fc0d8094ed50e4540bcb9 100644 (file)
@@ -496,7 +496,7 @@ function chat_login_user($chatid, $version, $groupid, $course) {
             $message->timestamp = time();
 
             if (!insert_record('chat_messages', $message)) {
-                error('Could not insert a chat message!');
+                print_error('Could not insert a chat message!');
             }
         }
     }
@@ -526,7 +526,7 @@ function chat_delete_old_users() {
             $message->timestamp = time();
 
             if (!insert_record('chat_messages', $message)) {
-                error('Could not insert a chat message!');
+                print_error('Could not insert a chat message!');
             }
         }
     }
index e1718f0509860a3432e2c9e9047f7beb016d1ff4..1243b3f38fe1a84cc517b8e2629c3f9a975496ee 100644 (file)
@@ -19,7 +19,7 @@ class page_chat extends page_generic_activity {
 
     function init_quick($data) {
         if(empty($data->pageid)) {
-            error('Cannot quickly initialize page: empty course id');
+            print_error('Cannot quickly initialize page: empty course id');
         }
         $this->activityname = 'chat';
         parent::init_quick($data);
index 44cfcd25a0e8957ed4ce80f1fc79b9f722c1a26e..00bdf1a93b6c40585684bf682b7563eecaea6612 100644 (file)
     $confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL);
 
     if (! $cm = get_coursemodule_from_id('chat', $id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (! $chat = get_record('chat', 'id', $cm->instance)) {
-        error('Course module is incorrect');
+        print_error('Course module is incorrect');
     }
     if (! $course = get_record('course', 'id', $chat->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
index 9637f60366210cd4d8158af6d4b3aa5bb5654b0c..be086082ecc3febb8f21446fb2e40c0d9a2e022a 100644 (file)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('chat', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
 
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
 
         chat_update_chat_times($cm->instance);
 
         if (! $chat = get_record('chat', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
 
     } else {
         chat_update_chat_times($c);
 
         if (! $chat = get_record('chat', 'id', $c)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
         if (! $course = get_record('course', 'id', $chat->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     }
 
index 2b5cdead0b7014d75537d71a1ccc2190756bccb1..b12652907b85e244749543412636885ccafbd07c 100644 (file)
@@ -6,7 +6,7 @@
     $id = required_param('id',PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index 51ea48b4e0f00d87fcb9c883e62d668d5d2f8c61..9917fecd29beb0b2e35b5b9bf2f1dbff4775223d 100644 (file)
@@ -264,7 +264,7 @@ function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $
             $newanswer->optionid = $formanswer;
             $newanswer->timemodified = time();
             if (! update_record("choice_answers", $newanswer)) {
-                error("Could not update your choice because of a database error");
+                print_error("Could not update your choice because of a database error");
             }
             add_to_log($courseid, "choice", "choose again", "view.php?id=$cm->id", $choice->id, $cm->id);
         } else {
@@ -274,13 +274,13 @@ function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $
             $newanswer->optionid = $formanswer;
             $newanswer->timemodified = time();
             if (! insert_record("choice_answers", $newanswer)) {
-                error("Could not save your choice");
+                print_error("Could not save your choice");
             }
             add_to_log($courseid, "choice", "choose", "view.php?id=$cm->id", $choice->id, $cm->id);
         }
     } else {
         if (!($current->optionid==$formanswer)) { //check to see if current choice already selected - if not display error
-            error("this choice is full!");
+            print_error("this choice is full!");
         }
     }
 }
index 6e0730f2c78bb23d6f76cdaa4d4651a814a71055..5e2a62e422cdf7a4921cee14994d34d847c5fbb7 100644 (file)
@@ -9,11 +9,11 @@
     $action   = optional_param('action', '', PARAM_ALPHA);
 
     if (! $cm = get_coursemodule_from_id('choice', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course module is misconfigured");
+        print_error("Course module is misconfigured");
     }
 
     require_login($course->id, false, $cm);
@@ -23,7 +23,7 @@
     require_capability('mod/choice:readresponses', $context);
     
     if (!$choice = choice_get_choice($cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     $strchoice = get_string("modulename", "choice");
index b82864d4df9b3e4a31c8250182ab43e116ef8b56..0db511b476d98f0d835350aa22fbed46e56f368c 100644 (file)
@@ -8,17 +8,17 @@
     $attemptids = optional_param('attemptid', array(), PARAM_INT); // array of attempt ids for delete action
     
     if (! $cm = get_coursemodule_from_id('choice', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_course_login($course, false, $cm);
 
     if (!$choice = choice_get_choice($cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
     
     $strchoice = get_string('modulename', 'choice');
index f9c696de26c638e470b70945b229f2240861745a..bc24ed021405b667cf05da00e5d6f4b572973d35 100755 (executable)
 
 
     if (! $record = get_record('data_records', 'id', $rid)) {
-        error('Record ID is incorrect');
+        print_error('Record ID is incorrect');
     }
     if (! $data = get_record('data', 'id', $record->dataid)) {
-        error('Data ID is incorrect');
+        print_error('Data ID is incorrect');
     }
     if (! $course = get_record('course', 'id', $data->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     require_login($course->id, false, $cm);
 
     if ($commentid) {
         if (! $comment = get_record('data_comments', 'id', $commentid)) {
-            error('Comment ID is misconfigured');
+            print_error('Comment ID is misconfigured');
         }
         if ($comment->recordid != $record->id) {
-            error('Comment ID is misconfigured');
+            print_error('Comment ID is misconfigured');
         }
         if (!has_capability('mod/data:managecomments', $context) && $comment->userid != $USER->id) {
-            error('Comment is not yours to edit!');
+            print_error('Comment is not yours to edit!');
         }
     } else {
         $comment = false;
@@ -81,7 +81,7 @@
             if (insert_record('data_comments',$newcomment)) {
                 redirect('view.php?rid='.$record->id.'&amp;page='.$page);
             } else {
-                error('Error while saving comment.');
+                print_error('Error while saving comment.');
             }
 
         break;
             if (update_record('data_comments',$updatedcomment)) {
                 redirect('view.php?rid='.$record->id.'&amp;page='.$page);
             } else {
-                error('Error while saving comment.');
+                print_error('Error while saving comment.');
             }
         break;
 
index 58f7cc8c491f462cec6c5e74f6a28155b3f961c8..40eb0e7a0c53ab870defaf65110e280985fa1688 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $data = get_record('data', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
 
     } else {
         if (! $data = get_record('data', 'id', $d)) {
-            error('Data ID is incorrect');
+            print_error('Data ID is incorrect');
         }
         if (! $course = get_record('course', 'id', $data->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     }
 
@@ -82,7 +82,7 @@
 
     if ($rid) {    // So do you have access?
         if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey() ) {
-            error(get_string('noaccess','data'));
+            print_error('noaccess','data');
         }
     }
 
         } else { /// Add some new records
 
             if (!data_user_can_add_entry($data, $currentgroup, $groupmode)) {
-                error('Can not add entries!');
+                print_error('Can not add entries!');
             }
 
         /// Check if maximum number of entry as specified by this database is reached
 
     // Print the stuff that need to come after the form fields.
     if (!$fields = get_records('data_fields', 'dataid', $data->id)) {
-        error(get_string('nofieldindatabase', 'data'));
+        print_error('nofieldindatabase', 'data');
     }
     foreach ($fields as $eachfield) {
         $field = data_get_field($eachfield, $data);
index 541db45b0f60fd66015f9436f0df9c4f3a216e72..5a3d9b22063a274e356794dd82abfad145dc3e50 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $data = get_record('data', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
 
     } else {
         if (! $data = get_record('data', 'id', $d)) {
-            error('Data ID is incorrect');
+            print_error('Data ID is incorrect');
         }
         if (! $course = get_record('course', 'id', $data->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     }
 
                             $rec->defaultsort = 0;
                             $rec->defaultsortdir = 0;
                             if (!update_record('data', $rec)) {
-                                error('There was an error updating the database');
+                                print_error('There was an error updating the database');
                             }
                         }
 
                 if (update_record('data', $rec)) {
                     redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id, get_string('changessaved'), 2);
                 } else {
-                    error('There was an error updating the database');
+                    print_error('There was an error updating the database');
                 }
                 exit;
             }
index 37bb83065c08a534af5fb735e4fa23b7147b5682..e806ff7fa0d5990d4859a50f378bd8ca842b0a82 100755 (executable)
@@ -135,7 +135,7 @@ class data_field_file extends data_field_base {
             $oldcontent->fieldid = $this->field->id;
             $oldcontent->recordid = $recordid;
             if ($oldcontent->id = insert_record('data_content', $oldcontent)) {
-                error('Could not make an empty record!');
+                print_error('Could not make an empty record!');
             }
         }
 
index 7af26312b5e439d408a6dc8ac57dba11ba6b984a..e2609d238a44cbb0c62e5ad134a0d6b238166c78 100644 (file)
@@ -14,41 +14,41 @@ $rid     = optional_param('rid', 0, PARAM_INT);    //record id
 
 if ($rid) {
     if (! $record = get_record('data_records', 'id', $rid)) {
-        error('Record ID is incorrect');
+        print_error('Record ID is incorrect');
     }
     if (! $data = get_record('data', 'id', $record->dataid)) {
-        error('Data ID is incorrect');
+        print_error('Data ID is incorrect');
     }
     if (! $course = get_record('course', 'id', $data->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (! $field = get_record('data_fields', 'id', $fieldid)) {
-        error('Field ID is incorrect');
+        print_error('Field ID is incorrect');
     }
     if (! $field->type == 'latlong') { // Make sure we're looking at a latlong data type!
-        error('Field ID is incorrect');
+        print_error('Field ID is incorrect');
     }
     if (! $content = get_record('data_content', 'fieldid', $fieldid, 'recordid', $rid)) {
-        error('Field content not found');
+        print_error('Field content not found');
     }
 } else {   // We must have $d
     if (! $data = get_record('data', 'id', $d)) {
-        error('Data ID is incorrect');
+        print_error('Data ID is incorrect');
     }
     if (! $course = get_record('course', 'id', $data->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (! $field = get_record('data_fields', 'id', $fieldid)) {
-        error('Field ID is incorrect');
+        print_error('Field ID is incorrect');
     }
     if (! $field->type == 'latlong') { // Make sure we're looking at a latlong data type!
-        error('Field ID is incorrect');
+        print_error('Field ID is incorrect');
     }
     $record = NULL;
 }
index f66faa9a52e1a43335149c9a49b41ff1d2b6440a..a5ac877cab46affa325347149046ab3acd14e7ae 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $data = get_record('data', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
 
     } else {
         if (! $data = get_record('data', 'id', $d)) {
-            error('Data ID is incorrect');
+            print_error('Data ID is incorrect');
         }
         if (! $course = get_record('course', 'id', $data->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     }
 
         $recordsadded = 0;
 
         if (!$records = data_get_records_csv($filename, $fielddelimiter, $fieldenclosure)) {
-            error('get_records_csv failed to read data from the uploaded file. Please check file for field name typos and formatting errors.');
+            print_error('get_records_csv failed to read data from the uploaded file. Please check file for field name typos and formatting errors.');
         } else {
             //$db->debug = true;
             $fieldnames = array_shift($records);
@@ -176,7 +176,7 @@ function data_get_records_csv($filename, $fielddelimiter=',', $fieldenclosure="\
     }
 
     if (!$fp = fopen($filename, "r")) {
-        error('get_records_csv failed to open '.$filename);
+        print_error('get_records_csv failed to open '.$filename);
     }
     $fieldnames = array();
     $rows = array();
index 2e0be42a8541606baa9a975e07738e0f15be8a66..6f8d6c7b106c0821021fd79d7005d51357c60266 100755 (executable)
@@ -28,7 +28,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index f35970584eb65dd65b6decf64a0181a1166e33e1..53ba3293361add9f4de53d74d925d594f08f2a98 100755 (executable)
@@ -40,18 +40,18 @@ class data_field_base {     /// Base class for Database Field Types (see field/*
     function data_field_base($field=0, $data=0) {   // Field or data or both, each can be id or object
 
         if (empty($field) && empty($data)) {
-            error('Programmer error: You must specify field and/or data when defining field class. ');
+            print_error('Programmer error: You must specify field and/or data when defining field class. ');
         }
 
         if (!empty($field)) {
             if (is_object($field)) {
                 $this->field = $field;  // Programmer knows what they are doing, we hope
             } else if (!$this->field = get_record('data_fields','id',$field)) {
-                error('Bad field ID encountered: '.$field);
+                print_error('Bad field ID encountered: '.$field);
             }
             if (empty($data)) {
                 if (!$this->data = get_record('data','id',$this->field->dataid)) {
-                    error('Bad data ID encountered in field data');
+                    print_error('Bad data ID encountered in field data');
                 }
             }
         }
@@ -61,10 +61,10 @@ class data_field_base {     /// Base class for Database Field Types (see field/*
                 if (is_object($data)) {
                     $this->data = $data;  // Programmer knows what they are doing, we hope
                 } else if (!$this->data = get_record('data','id',$data)) {
-                    error('Bad data ID encountered: '.$data);
+                    print_error('Bad data ID encountered: '.$data);
                 }
             } else {                      // No way to define it!
-                error('Data id or object must be provided to field class');
+                print_error('Data id or object must be provided to field class');
             }
         }
 
@@ -1705,7 +1705,7 @@ function data_user_can_add_entry($data, $currentgroup, $groupmode) {
     global $USER;
 
     if (!$cm = get_coursemodule_from_instance('data', $data->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
@@ -1835,7 +1835,7 @@ function data_presets_export($course, $cm, $data) {
 
     /* Check all is well */
     if (!is_directory_a_preset($tempfolder)) {
-        error("Not all files generated!");
+        print_error("Not all files generated!");
     }
 
     $filelist = array(
@@ -1878,7 +1878,7 @@ class PresetImporter {
         global $CFG;
 
         if (!is_directory_a_preset($this->folder)) {
-            error("$this->userid/$this->shortname Not a preset");
+            print_error("$this->userid/$this->shortname Not a preset");
         }
 
         /* Grab XML */
@@ -1929,7 +1929,7 @@ class PresetImporter {
 
     function import_options() {
         if (!confirm_sesskey()) {
-            error("Sesskey Invalid");
+            print_error("Sesskey Invalid");
         }
 
         $strblank = get_string('blank', 'data');
@@ -1981,7 +1981,7 @@ class PresetImporter {
             echo "<p>$strwarning</p>";
         }
         else if (empty($newfields)) {
-            error("New preset has no defined fields!");
+            print_error("New preset has no defined fields!");
         }
         echo '<input type="submit" value="'.$strcontinue.'" /></fieldset></form></div>';
 
@@ -2000,7 +2000,7 @@ class PresetImporter {
                 $cid = optional_param("field_$nid", -1, PARAM_INT);
                 if ($cid == -1) continue;
 
-                if (array_key_exists($cid, $preservedfields)) error("Not an injective map");
+                if (array_key_exists($cid, $preservedfields)) print_error("Not an injective map");
                 else $preservedfields[$cid] = true;
             }
 
index 0ff3a02b8341ff549176cbefa599af68b788a533..5e444b068e3f83616879f11a8147f42b6f0aab50 100755 (executable)
@@ -22,7 +22,7 @@ class page_data extends page_generic_activity {
 
     function init_quick($data) {
         if(empty($data->pageid)) {
-            error('Cannot quickly initialize page: empty course id');
+            print_error('Cannot quickly initialize page: empty course id');
         }
         $this->activityname = 'data';
         parent::init_quick($data);
index 255159764a25898240e57ac7854d8dad9d17564a..3d66a5a560c6d380e13b229376740be12378e868 100644 (file)
@@ -25,26 +25,26 @@ unset($fullname);
 
 if ($id) {
     if (! $cm = get_coursemodule_from_id('data', $id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (! $course = get_record('course', 'id', $cm->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $data = get_record('data', 'id', $cm->instance)) {
-        error('Module Incorrect');
+        print_error('Module Incorrect');
     }
 } else if ($d) {
     if (! $data = get_record('data', 'id', $d)) {
-        error('Database ID Incorrect');
+        print_error('Database ID Incorrect');
     }
     if (! $course = get_record('course', 'id', $data->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 } else {
-    error('Parameter missing');
+    print_error('Parameter missing');
 }
 
 // fill in missing properties needed for updating of instance
@@ -53,7 +53,7 @@ $data->cmidnumber = $cm->idnumber;
 $data->instance   = $cm->instance;
 
 if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
-    error('Could not find context');
+    print_error('Could not find context');
 }
 
 require_login($course->id, false, $cm);
@@ -61,7 +61,7 @@ require_login($course->id, false, $cm);
 require_capability('mod/data:managetemplates', $context);
 
 if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpresets', $context)) {
-    error('You are not allowed to access presets from other users');
+    print_error('You are not allowed to access presets from other users');
 }
 
 /* Need sesskey security check here for import instruction */
@@ -76,13 +76,13 @@ switch ($action) {
         /***************** Deleting *****************/
     case 'confirmdelete' :
         if (!confirm_sesskey()) { // GET request ok here
-            error("Sesskey Invalid");
+            print_error("Sesskey Invalid");
         }
 
         if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) {
            //ok can delete
         } else {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         $path = data_preset_path($course, $userid, $shortname);
@@ -105,19 +105,19 @@ switch ($action) {
 
     case 'delete' :
         if (!data_submitted() and !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) {
            //ok can delete
         } else {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         $presetpath = data_preset_path($course, $userid, $shortname);
 
         if (!clean_preset($presetpath)) {
-            error("Error deleting a preset!");
+            print_error("Error deleting a preset!");
         }
         @rmdir($presetpath);
 
@@ -130,7 +130,7 @@ switch ($action) {
         /***************** Importing *****************/
     case 'importpreset' :
         if (!data_submitted() or !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         $pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname);
@@ -143,18 +143,18 @@ switch ($action) {
         /* Imports a zip file. */
     case 'importzip' :
         if (!data_submitted() or !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         if (!make_upload_directory('temp/data/'.$USER->id)) {
-            error("Can't Create Directory");
+            print_error("Can't Create Directory");
         }
 
         $presetfile = $CFG->dataroot.'/temp/data/'.$USER->id;
         clean_preset($presetfile);
 
         if (!unzip_file($CFG->dataroot."/$course->id/$file", $presetfile, false)) {
-            error("Can't unzip file");
+            print_error("Can't unzip file");
         }
 
         $pimporter = new PresetImporter($course, $cm, $data, -$USER->id, $shortname);
@@ -166,7 +166,7 @@ switch ($action) {
 
     case 'finishimport':
         if (!data_submitted() or !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         $pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname);
@@ -185,7 +185,7 @@ switch ($action) {
         /* Exports as a zip file ready for download. */
     case 'export':
         if (!data_submitted() or !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         echo '<div style="text-align:center">';
@@ -197,7 +197,7 @@ switch ($action) {
         make_upload_directory("$course->id/moddata/data/$data->id");
 
         /* now just move the zip into this folder to allow a nice download */
-        if (!rename($file, $perminantfile)) error("Can't move zip");
+        if (!rename($file, $perminantfile)) print_error("Can't move zip");
         echo "<a href='$CFG->wwwroot/file.php/$course->id/moddata/data/$data->id/preset.zip'>".get_string('download', 'data')."</a>";
         echo '</div>';
         break;
@@ -205,7 +205,7 @@ switch ($action) {
         /***************** Exporting *****************/
     case 'save1':
         if (!data_submitted() or !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         $strcontinue = get_string('continue');
@@ -227,7 +227,7 @@ switch ($action) {
 
     case 'save2':
         if (!data_submitted() or !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         $strcontinue = get_string('continue');
@@ -263,7 +263,7 @@ switch ($action) {
 
     case 'save3':
         if (!data_submitted() or !confirm_sesskey()) {
-            error("Invalid request");
+            print_error("Invalid request");
         }
 
         $name = optional_param('name', $data->name, PARAM_FILE);
@@ -274,7 +274,7 @@ switch ($action) {
 
         $file = data_presets_export($course, $cm, $data);
         if (!unzip_file($file, $CFG->dataroot.$presetdirectory, false)) {
-            error("Can't unzip to the preset directory");
+            print_error("Can't unzip to the preset directory");
         }
         notify(get_string('savesuccess', 'data'), 'notifysuccess');
         break;
index c482eda5db0fa6f1e96031662aecce6262831335..6e4a1ddf5fb05298b872080c8e9aa86e4b6e5423 100755 (executable)
@@ -26,30 +26,30 @@ unset($fullname);
 
 if ($id) {
     if (! $cm = get_coursemodule_from_id('data', $id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (! $course = get_record('course', 'id', $cm->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $data = get_record('data', 'id', $cm->instance)) {
-        error('Module Incorrect');
+        print_error('Module Incorrect');
     }
 } else if ($d) {
     if (! $data = get_record('data', 'id', $d)) {
-        error('Database ID Incorrect');
+        print_error('Database ID Incorrect');
     }
     if (! $course = get_record('course', 'id', $data->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 } else {
-    error('Parameter missing');
+    print_error('Parameter missing');
 }
 
 if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
-    error('Could not find context');
+    print_error('Could not find context');
 }
 
 require_login($course->id, false, $cm);
@@ -57,7 +57,7 @@ require_login($course->id, false, $cm);
 require_capability('mod/data:managetemplates', $context);
 
 if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpresets', $context)) {
-    error('You are not allowed to access presets from other users');
+    print_error('You are not allowed to access presets from other users');
 }
 
 /* Need sesskey security check here for import instruction */
index e756de4878a52eaff14e17fa2a3585487767c51c..06950926c930571c875573496c95542516e16ece 100755 (executable)
@@ -5,32 +5,32 @@
     $dataid = required_param('dataid', PARAM_INT); // The forum the rated posts are from
 
     if (!$data = get_record('data', 'id', $dataid)) {
-        error("Incorrect data id");
+        print_error("Incorrect data id");
     }
 
     if (!$course = get_record('course', 'id', $data->course)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
     if (!$cm = get_coursemodule_from_instance('data', $data->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     require_login($course, false, $cm);
 
     if (isguestuser()) {
-        error("Guests are not allowed to rate entries.");
+        print_error("Guests are not allowed to rate entries.");
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     require_capability('mod/data:rate', $context);
 
     if (!$data->assessed) {
-        error("Rating of items not allowed!");
+        print_error("Rating of items not allowed!");
     }
 
     if (!$frmdata = data_submitted() or !confirm_sesskey()) {
-        error("This page was not accessed correctly");
+        print_error("This page was not accessed correctly");
     }
 
     $count = 0;
         }
 
         if (!$record = get_record('data_records', 'id', $recordid)) {
-            error("Record ID is incorrect");
+            print_error("Record ID is incorrect");
         }
 
         if ($data->id != $record->dataid) {
-            error("Incorrect record.");
+            print_error("Incorrect record.");
         }
 
         if ($record->userid == $USER->id) {
@@ -64,7 +64,7 @@
             } else if ($rating != $oldrating->rating) {
                 $oldrating->rating = $rating;
                 if (! update_record('data_ratings', $oldrating)) {
-                    error("Could not update an old rating ($record->id = $rating)");
+                    print_error("Could not update an old rating ($record->id = $rating)");
                 }
                 data_update_grades($data, $record->userid);
 
             $newrating->recordid = $record->id;
             $newrating->rating   = $rating;
             if (! insert_record('data_ratings', $newrating)) {
-                error("Could not insert a new rating ($record->id = $rating)");
+                print_error("Could not insert a new rating ($record->id = $rating)");
             }
             data_update_grades($data, $record->userid);
         }
     }
 
     if ($count == 0) {
-        error("Incorrect submitted ratings data");
+        print_error("Incorrect submitted ratings data");
     }
 
     if (!empty($_SERVER['HTTP_REFERER'])) {
index fafbc549e2cb775eab76d10997d653beeda58f83..621d2f5cc984b48eb9dbac729d64a95587d4ee9c 100755 (executable)
@@ -9,30 +9,30 @@
     $sort = optional_param('sort', '', PARAM_ALPHA);
 
     if (!$record = get_record('data_records', 'id', $id)) {
-        error("Record ID is incorrect");
+        print_error("Record ID is incorrect");
     }
 
     if (!$data = get_record('data', 'id', $record->dataid)) {
-        error("Data ID is incorrect");
+        print_error("Data ID is incorrect");
     }
 
     if (!$course = get_record('course', 'id', $data->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     if (!$data->assessed) {
-        error("This activity does not use ratings");
+        print_error("This activity does not use ratings");
     }
 
     if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) {
-        error("You can not view ratings");
+        print_error("You can not view ratings");
     }
 
     switch ($sort) {
@@ -50,7 +50,7 @@
     print_header($strratings);
 
     if (!$ratings = data_get_ratings($record->id, $sqlsort)) {
-        error("No ratings for this record!");
+        print_error("No ratings for this record!");
 
     } else {
         echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
index 75c59b4f290fc943e04bd596cc46bc488014afb5..7a11f4390ede8b6d89a7029d6981e2e8284a69d2 100755 (executable)
@@ -26,7 +26,7 @@
 
 
     if (empty($currenttab) or empty($data) or empty($course)) {
-        error('You cannot call this script in that way');
+        print_error('You cannot call this script in that way');
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
index bb1acf3e64d09514aa53593ce4be9960af488b0e..ca94a363bb0249c84c87452a78a78db435705aba 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $data = get_record('data', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
 
     } else {
         if (! $data = get_record('data', 'id', $d)) {
-            error('Data ID is incorrect');
+            print_error('Data ID is incorrect');
         }
         if (! $course = get_record('course', 'id', $data->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     }
 
index 4427a6aaa6432608df73b7b30411eac94a29bc00..146507cf03ea49ac3bbf8329b8533534a1c4cf1f 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $data = get_record('data', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
         $record = NULL;
 
     } else if ($rid) {
         if (! $record = get_record('data_records', 'id', $rid)) {
-            error('Record ID is incorrect');
+            print_error('Record ID is incorrect');
         }
         if (! $data = get_record('data', 'id', $record->dataid)) {
-            error('Data ID is incorrect');
+            print_error('Data ID is incorrect');
         }
         if (! $course = get_record('course', 'id', $data->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     } else {   // We must have $d
         if (! $data = get_record('data', 'id', $d)) {
-            error('Data ID is incorrect');
+            print_error('Data ID is incorrect');
         }
         if (! $course = get_record('course', 'id', $data->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         $record = NULL;
     }
index 0e5d2f9b68d11c4a3e5c741189164d2810e96cb5..5327aff1b362f2497fba30dafbc1340c53e054f4 100644 (file)
 
     // get some esential stuff...
     if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     exercise_add_custom_scales($exercise);
     if ($action == 'adminamendgradinggrade' ) {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         if (empty($aid)) {
-            error("Admin Amend Grading grade: assessment id missing");
+            print_error("Admin Amend Grading grade: assessment id missing");
         }
 
         if (!$assessment = get_record("exercise_assessments", "id", $aid)) {
-            error("Amin Amend Grading grade: assessment not found");
+            print_error("Amin Amend Grading grade: assessment not found");
         }
         print_heading(get_string("amend", "exercise")." ".get_string("gradeforstudentsassessment",
                     "exercise", $course->student));
     elseif ($action == 'adminconfirmdelete' ) {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         if (empty($aid)) {
-            error("Admin confirm delete: assessment id missing");
+            print_error("Admin confirm delete: assessment id missing");
         }
 
         notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")),
     elseif ($action == 'admindelete' ) {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         if (empty($aid)) {
-            error("Admin delete: submission id missing");
+            print_error("Admin delete: submission id missing");
         }
 
         print_string("deleting", "exercise");
     elseif ($action == 'adminlist') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         if (empty($sid)) {
     elseif ($action == 'adminlistbystudent') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         if (empty($userid)) {
         }
 
         if (! $submission = get_record("exercise_submissions", "id", $sid)) {
-            error("Assess submission is misconfigured - no submission record!");
+            print_error("Assess submission is misconfigured - no submission record!");
         }
         if (!$submissionowner = get_record("user", "id", $submission->userid)) {
-            error("Assess resubmission: user record not found");
+            print_error("Assess resubmission: user record not found");
         }
 
         // there can be an assessment record, if there isn't...
         if (!$assessment = exercise_get_submission_assessment($submission, $USER)) {
             if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) {
-                error("Assess resubmission: submission records not found");
+                print_error("Assess resubmission: submission records not found");
             }
             $lastone= '';
             // just the last but one submission
             }
             // get the teacher's assessment of the student's previous submission
             if (!$prevassessment = exercise_get_submission_assessment($prevsubmission, $USER)) {
-                error("Assess resubmission: Previous assessment record not found");
+                print_error("Assess resubmission: Previous assessment record not found");
             }
             // copy this assessment with comments...
             $assessment = exercise_copy_assessment($prevassessment, $submission, true);
         }
 
         if (! $submission = get_record("exercise_submissions", "id", $sid)) {
-            error("Assess submission is misconfigured - no submission record!");
+            print_error("Assess submission is misconfigured - no submission record!");
         }
 
         // there can be an assessment record (for teacher submissions), if there isn't...
             $assessment->timecreated = $yearfromnow;
             $assessment->timegraded = 0;
             if (!$assessment->id = insert_record("exercise_assessments", $assessment)) {
-                error("Could not insert exercise assessment!");
+                print_error("Could not insert exercise assessment!");
             }
         }
 
     elseif ($action == 'editelements') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         $count = count_records("exercise_grades", "exerciseid", $exercise->id);
     elseif ($action == 'insertelements') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         $form = data_submitted();
                         $element->exerciseid = $exercise->id;
                         $element->elementno = clean_param($key, PARAM_INT);
                         if (!$element->id = insert_record("exercise_elements", $element)) {
-                            error("Could not insert exercise element!");
+                            print_error("Could not insert exercise element!");
                         }
                     }
                 }
                             $element->weight = $form->weight[$key];
                         }
                         if (!$element->id = insert_record("exercise_elements", $element)) {
-                            error("Could not insert exercise element!");
+                            print_error("Could not insert exercise element!");
                         }
                     }
                 }
                         $element->weight = $form->weight[$key];
                     }
                     if (!$element->id = insert_record("exercise_elements", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                 }
                 break;
                     }
                     $element->maxscore = $j - 1;
                     if (!$element->id = insert_record("exercise_elements", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                 }
                 // let's not fool around here, dump the junk!
                         $element->rubricno = $j;
                         $element->description   = $form->rubric[$i][$j];
                         if (!$element->id = insert_record("exercise_rubrics", $element)) {
-                            error("Could not insert exercise element!");
+                            print_error("Could not insert exercise element!");
                         }
                     }
                 }
     elseif ($action == 'listungradedstudentsubmissions') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         exercise_list_ungraded_assessments($exercise, "student");
         print_continue("view.php?id=$cm->id");
     elseif ($action == 'listungradedstudentassessments') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         exercise_list_ungraded_assessments($exercise, "teacher");
         print_continue("view.php?id=$cm->id");
     elseif ($action == 'regradestudentassessments' ) {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         // get all the student assessments
         if ($assessments = exercise_get_teacher_submission_assessments($exercise)) {
                 if ($studentassessment->timegraded > 0) {
                     if (!$submissions = get_records_select("exercise_submissions",
                            "userid = $studentassessment->userid AND exerciseid = $exercise->id", "timecreated ASC")) {
-                        error("Regrade student assessments: student submission not found");
+                        print_error("Regrade student assessments: student submission not found");
                     }
                     foreach ($submissions as $submission) { // only the first one is relavant
                         if (!$teacherassessments = get_records("exercise_assessments", "submissionid",
                                     $submission->id, "timecreated ASC")) {
-                            error("Regrade student assessments: teacher assessment(s) not found");
+                            print_error("Regrade student assessments: teacher assessment(s) not found");
                         }
                         foreach ($teacherassessments as $teacherassessment) { // only the first one is relavent
                             $newgrade = exercise_compare_assessments($exercise, $studentassessment, $teacherassessment);
     elseif ($action == 'teacherassessment') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         if (empty($aid)) {
-            error("assessment id missing");
+            print_error("assessment id missing");
         }
         if (empty($sid)) {
             error ("no sid");
         }
         if (!$assessment = get_record("exercise_assessments", "id", $aid)) {
-            error("Teacher assessment: User's assessment record not found");
+            print_error("Teacher assessment: User's assessment record not found");
         }
         if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            error("Teacher assessment: User's submission record not found");
+            print_error("Teacher assessment: User's submission record not found");
         }
         exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $_SERVER["HTTP_REFERER"]);
     }
     elseif ($action == 'teachertable') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         exercise_print_teacher_table($course);
         $form = data_submitted();
 
         if (empty($aid)) {
-            error("assessment id missing");
+            print_error("assessment id missing");
         }
         if (! $assessment = get_record("exercise_assessments", "id", $aid)) {
-            error("exercise assessment is misconfigured");
+            print_error("exercise assessment is misconfigured");
         }
 
         // first get the assignment elements for maxscores and weights...
                     $element->elementno = clean_param($key, PARAM_INT);
                     $element->feedback   = clean_param($thefeedback, PARAM_CLEAN);
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                         }
                     }
                 $grade = 0; // set to satisfy save to db
                     $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                 }
                 // now work out the grade...
                     $element->feedback   = clean_param($form->feedback[$i], PARAM_CLEAN);
                     $element->grade = $form->grade[$i];
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                     if (empty($form->grade[$i])){
                         $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight];
                 $element->elementno = $i;
                 $element->grade = $form->grade[$i];
                 if (!$element->id = insert_record("exercise_grades", $element)) {
-                    error("Could not insert exercise element!");
+                    print_error("Could not insert exercise element!");
                 }
                 $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i])
                     * 100.0 / $exercise->grade;
                 $element->elementno = 0;
                 $element->grade = $form->grade[0];
                 if (!$element->id = insert_record("exercise_grades", $element)) {
-                    error("Could not insert exercise element!");
+                    print_error("Could not insert exercise element!");
                 }
                 // now save the adjustment in element one
                 unset($element);
                 $element->elementno = 1;
                 $element->grade = $form->grade[1];
                 if (!$element->id = insert_record("exercise_grades", $element)) {
-                    error("Could not insert exercise element!");
+                    print_error("Could not insert exercise element!");
                 }
                 $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade;
                 // check the grade for sanity!
                     $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                 }
                 // now work out the grade...
     elseif ($action == 'updateteacherassessment') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         $timenow = time();
 
         // first do the (teacher's) assessment of the student's submission
         if (! $submission = get_record("exercise_submissions", "id", $form->sid)) {
-            error("Update teacher assessment: student's submission record not found");
+            print_error("Update teacher assessment: student's submission record not found");
         }
         if (!$assessment = exercise_get_submission_assessment($submission, $USER)) {
-            error("Update teacher assessment: teacher's assessment record not found");
+            print_error("Update teacher assessment: teacher's assessment record not found");
         }
 
         // first get the assignment elements for maxscores and weights...
                     $element->elementno = clean_param($key, PARAM_INT);
                     $element->feedback   = clean_param($thefeedback, PARAM_CLEAN);
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                 }
                 $grade = 0; // set to satisfy save to db
                     $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                 }
                 // now work out the grade...
                     $element->feedback   = clean_param($form->feedback[$i], PARAM_CLEAN);
                     $element->grade = $form->grade[$i];
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                     if (empty($form->grade[$i])){
                         $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight];
                 $element->elementno = $i;
                 $element->grade = $form->grade[$i];
                 if (!$element->id = insert_record("exercise_grades", $element)) {
-                    error("Could not insert exercise element!");
+                    print_error("Could not insert exercise element!");
                 }
                 $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $exercise->grade;
                 echo "<p><b>".get_string("weightederrorcount", "exercise", intval($error + 0.5))."</b></p>\n";
                 $element->elementno = 0;
                 $element->grade = $form->grade[0];
                 if (!$element->id = insert_record("exercise_grades", $element)) {
-                    error("Could not insert exercise element!");
+                    print_error("Could not insert exercise element!");
                 }
                 // now save the adjustment in element one
                 unset($element);
                 $element->elementno = 1;
                 $element->grade = $form->grade[1];
                 if (!$element->id = insert_record("exercise_grades", $element)) {
-                    error("Could not insert exercise element!");
+                    print_error("Could not insert exercise element!");
                 }
                 $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade;
                 break;
                     $element->feedback   = clean_param($form->feedback[$key], PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("exercise_grades", $element)) {
-                        error("Could not insert exercise element!");
+                        print_error("Could not insert exercise element!");
                     }
                 }
                 // now work out the grade...
 
         // now calculate the (grading) grade of the student's assessment...
         if (!$stassessment = get_record("exercise_assessments", "id", $form->said)) {
-            error("Update teacher assessment: student's assessment record not found");
+            print_error("Update teacher assessment: student's assessment record not found");
         }
         $gradinggrade = exercise_compare_assessments($exercise, $assessment, $stassessment);
         // ...and save the grade for the assessment
     elseif ($action == 'updategradinggrade') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
             }
 
         if (empty($aid)) {
-            error("submission id missing");
+            print_error("submission id missing");
         }
         // normalise gradinggrade
         $gradinggrade = $_POST['gradinggrade'] * 100 / $exercise->gradinggrade;
         if (!set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id",
                     $aid)) {
-            error("Update grading grade: asseesment not updated");
+            print_error("Update grading grade: asseesment not updated");
         }
         redirect("submissions.php?id=$cm->id&amp;action=adminlist", get_string("savedok", "exercise"), 1);
     }
     elseif ($action == 'userconfirmdelete' ) {
 
         if (empty($aid)) {
-            error("User confirm delete: assessment id missing");
+            print_error("User confirm delete: assessment id missing");
         }
 
         notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")),
     elseif ($action == 'userdelete' ) {
 
         if (empty($aid)) {
-            error("User delete: assessment id missing");
+            print_error("User delete: assessment id missing");
         }
 
         print_string("deleting", "exercise");
     elseif ($action == 'viewassessment') {
 
         if (empty($aid)) {
-            error("assessment id missing");
+            print_error("assessment id missing");
         }
 
         // get the assessment record
         if (!$assessment = get_record("exercise_assessments", "id", $aid)) {
-            error("Assessment record not found");
+            print_error("Assessment record not found");
         }
 
         // show assessment but don't allow changes
 
     /*************** no man's land **************************************/
     else {
-        error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error("Fatal Error: Unknown Action: ".$action."\n");
     }
 
     print_footer($course);
index 7b50f834f829d0c8abe85160e34ced06e9429164..6a8084c31f7e33d038ef3602ba668e7fd1f69bd9 100644 (file)
@@ -7,7 +7,7 @@
     $id = required_param('id', PARAM_INT); // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_login($course->id);
index 1d7ec9b2bbd39644c8a883cdac9c8acfb3ad1ab1..28abcb5a70f55ab11f94a9d60415e8b35665b2bb 100644 (file)
@@ -167,7 +167,7 @@ function exercise_cron() {
                 continue;
             }
             if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-                error("Course Module ID was incorrect");
+                print_error("Course Module ID was incorrect");
                 continue;
             }
             if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
@@ -280,11 +280,11 @@ function exercise_delete_instance($id) {
 function exercise_grades($exerciseid) {
 /// Must return an array of grades, indexed by user, and a max grade.
     if (!$exercise = get_record("exercise", "id", $exerciseid)) {
-        error("Exercise record not found");
+        print_error("Exercise record not found");
     }
 
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (!$return->maxgrade = ($exercise->grade + $exercise->gradinggrade)) {
@@ -707,7 +707,7 @@ function exercise_get_user_submissions($exercise, $user) {
     // return submission of user oldest first, newest last
     // teachers submit "exercises"
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     if (isteacher($course->id, $user->id)) {
         return get_records_select("exercise_submissions",
index 365ee1e634e9c801cb279159a8aa81c0a61d9463..d8364a128e38b5404357d87c1d9c83ed1cb2653b 100644 (file)
@@ -81,7 +81,7 @@ function exercise_add_custom_scales($exercise) {
     global $EXERCISE_SCALES;
 
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if ($scales = get_records("scale", "courseid", $course->id, "name ASC")) {
@@ -168,7 +168,7 @@ function exercise_copy_assessment($assessment, $submission, $withfeedback = fals
         $newassessment->teachercomment = addslashes($assessment->teachercomment);
     }
     if (!$newassessment->id = insert_record("exercise_assessments", $newassessment)) {
-        error("Copy Assessment: Could not insert exercise assessment!");
+        print_error("Copy Assessment: Could not insert exercise assessment!");
     }
 
     if ($grades = get_records("exercise_grades", "assessmentid", $assessment->id)) {
@@ -183,7 +183,7 @@ function exercise_copy_assessment($assessment, $submission, $withfeedback = fals
             }
             $grade->assessmentid = $newassessment->id;
             if (!$grade->id = insert_record("exercise_grades", $grade)) {
-                error("Copy Assessment: Could not insert exercise grade!");
+                print_error("Copy Assessment: Could not insert exercise grade!");
             }
         }
     }
@@ -298,7 +298,7 @@ function exercise_count_unassessed_student_submissions($exercise) {
     global $CFG;
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     $timenow = time();
     $n = 0;
@@ -740,10 +740,10 @@ function exercise_list_submissions_for_admin($exercise) {
     global $CFG, $USER;
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     $groupid = get_current_group($course->id);
     
@@ -802,7 +802,7 @@ function exercise_list_submissions_for_admin($exercise) {
                 $title ='';
                 foreach ($assessments as $assessment) {
                     if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-                        error("exercise_list_submissions_for_admin: Submission record not found!");
+                        print_error("exercise_list_submissions_for_admin: Submission record not found!");
                         }
                     $title .= $submission->title;
                     // test for allocated assesments which have not been done
@@ -830,7 +830,7 @@ function exercise_list_submissions_for_admin($exercise) {
         if (isset($table->data)) {
             if ($groupid) {
                 if (! groups_group_exists($groupid)) { //TODO:
-                    error("List unassessed student submissions: group not found");
+                    print_error("List unassessed student submissions: group not found");
                 }
                 print_heading("$group->name ".get_string("studentassessments", "exercise", $course->student).
                         " [$nassessments]");
@@ -943,7 +943,7 @@ function exercise_list_submissions_for_admin($exercise) {
         if (isset($table->data)) {
             if ($groupid) {
                 if (! groups_group_exists($groupid)) {
-                    error("List unassessed student submissions: group not found");
+                    print_error("List unassessed student submissions: group not found");
                 }
                 print_heading("$group->name ".get_string("studentsubmissions", "exercise", $course->student).
                         " [$nsubmissions]");
@@ -997,7 +997,7 @@ function exercise_list_teacher_assessments($exercise, $user) {
     $timenow = time();
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), get_string("comment", "exercise"));
     $table->align = array ("left", "left", "left");
@@ -1043,10 +1043,10 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false)
     global $CFG;
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     $strexercises = get_string("modulenameplural", "exercise");
@@ -1080,7 +1080,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false)
                     $assessment->timecreated = $yearfromnow;
                     $assessment->mailed = 1; // no need to email to the teacher!
                     if (!$assessment->id = insert_record("exercise_assessments", $assessment)) {
-                        error("Could not insert exercise assessment!");
+                        print_error("Could not insert exercise assessment!");
                     }
                     break;
                 }
@@ -1089,7 +1089,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false)
     } else {
         // get hold of the teacher submission
         if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
-            error("List teacher submissions: submission record not found");
+            print_error("List teacher submissions: submission record not found");
         }
     }
     print_simple_box_start("center");
@@ -1178,10 +1178,10 @@ function exercise_list_unassessed_student_submissions($exercise, $user) {
     $timenow = time();
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     $table->head = array (get_string("title", "exercise"), get_string("submittedby", "exercise"),
@@ -1197,7 +1197,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) {
     $groupid = get_current_group($course->id);
     if ($groupid) {
         if (! groups_group_exists($groupid)) {
-            error("List unassessed student submissions: group not found");
+            print_error("List unassessed student submissions: group not found");
         }
         print_heading(get_string("studentsubmissionsforassessment", "exercise", $group->name));
     }
@@ -1263,7 +1263,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) {
                             if (isteacher($course->id, $assessment->userid)) {
                                 $teacherassessed = true;
                                 if (!$teacher = get_record("user", "id", $assessment->userid)) {
-                                    error("List unassessed student submissions: teacher record not found");
+                                    print_error("List unassessed student submissions: teacher record not found");
                                 }
                                 $comment = get_string("resubmissionfor", "exercise",
                                                 fullname($teacher));
@@ -1291,7 +1291,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) {
                         // no teacher's assessment
                         // find who did the previous assessment
                         if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) {
-                            error("List unassessed student submissions: submission records not found");
+                            print_error("List unassessed student submissions: submission records not found");
                         }
                         // get the oldest submission, exercise_get_user_submissions returns that first
                         foreach ($submissions as $tempsubmission) {
@@ -1304,7 +1304,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) {
                             foreach ($assessments as $assessment) {
                                 if (isteacher($course->id, $assessment->userid)) {
                                     if (!$teacher = get_record("user", "id", $assessment->userid)) {
-                                        error("List unassessed student submissions: teacher record not found");
+                                        print_error("List unassessed student submissions: teacher record not found");
                                     }
                                     $comment = get_string("resubmissionfor", "exercise",
                                                     fullname($teacher));
@@ -1377,10 +1377,10 @@ function exercise_list_ungraded_assessments($exercise, $stype) {
     global $CFG;
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     // lists all the assessments of student submissions for grading by teacher
@@ -1431,10 +1431,10 @@ function exercise_list_user_submissions($exercise, $user) {
     global $CFG;
 
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     
     $timenow = time();
@@ -1498,10 +1498,10 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
     global $CFG, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS;
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     
     $timenow = time();
@@ -1576,7 +1576,7 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
     <?php
     if ($assessment) {
         if (!$assessmentowner = get_record("user", "id", $assessment->userid)) {
-            error("Exercise_print_assessment_form: could not find user record");
+            print_error("Exercise_print_assessment_form: could not find user record");
             }
         if ($assessmentowner->id == $USER->id) {
             $formtitle = get_string("yourassessment", "exercise");
@@ -2035,10 +2035,10 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
 function exercise_print_assessments_by_user_for_admin($exercise, $user) {
 
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
         }
 
     if ($assessments =exercise_get_user_assessments($exercise, $user)) {
@@ -2059,10 +2059,10 @@ function exercise_print_assessments_by_user_for_admin($exercise, $user) {
 function exercise_print_assessments_for_admin($exercise, $submission) {
 
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
         }
 
     if ($assessments = exercise_get_assessments($submission)) {
@@ -2083,10 +2083,10 @@ function exercise_print_assessments_for_admin($exercise, $submission) {
 function exercise_print_assignment_info($exercise) {
 
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     // print standard assignment heading
     $strdifference = format_time($exercise->deadline - time());
@@ -2133,7 +2133,7 @@ function exercise_print_feedback($course, $submission) {
     global $CFG, $RATING;
 
     if (! $teacher = get_record("user", "id", $submission->teacher)) {
-        error("Weird exercise error");
+        print_error("Weird exercise error");
     }
 
     echo "\n<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\"><tr><td bgcolor=#888888>";
@@ -2168,7 +2168,7 @@ function exercise_print_league_table($exercise) {
     // print an order table of (student) submissions in grade order, only print the student's best submission when
     // there are multiple submissions
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Print league table: Course is misconfigured");
+        print_error("Print league table: Course is misconfigured");
     }
     $groupid = get_current_group($course->id);
     $nentries = $exercise->showleaguetable;
@@ -2196,7 +2196,7 @@ function exercise_print_league_table($exercise) {
                     continue;
                 }
                 if (!$user = get_record("user", "id", $submission->userid)) {
-                    error("Print league table: user not found");
+                    print_error("Print league table: user not found");
                     }
                 if ($exercise->anonymous and isstudent($course->id)) {
                     $table->data[] = array(exercise_print_submission_title($exercise, $submission),
@@ -2224,10 +2224,10 @@ function exercise_print_submission_assessments($exercise, $submission) {
     // Returns a list of grades for this submission
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     
     $str = '';
@@ -2342,16 +2342,16 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss
     global $CFG, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS;
     
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     
     $timenow = time();
 
     if(!$submissionowner = get_record("user", "id", $submission->userid)) {
-        error("Print teacher assessment form: User record not found");
+        print_error("Print teacher assessment form: User record not found");
     }
 
     echo "<center><table border=\"1\" width=\"30%\"><tr>
@@ -2406,7 +2406,7 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss
     
     // get the assignment elements...
     if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) {
-        error("Teacher assessment form: Elements not found");
+        print_error("Teacher assessment form: Elements not found");
     }
     foreach ($elementsraw as $element) {
         $elements[] = $element;   // to renumber index 0,1,2...
@@ -2817,7 +2817,7 @@ function exercise_print_teacher_table($course) {
     $table->cellspacing = 0;
 
     if (!$teachers = get_course_teachers($course->id, "u.firstname, u.lastname")) {
-        error("No teachers on this course!");
+        print_error("No teachers on this course!");
     }
     for ($j = 0; $j < count($exercises); $j++) {
         $grand[$j] = 0;
@@ -2861,10 +2861,10 @@ function exercise_print_upload_form($exercise) {
     global $CFG;
 
     if (! $course = get_record("course", "id", $exercise->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     echo "<div align=\"center\">";
index 68d5bb4d9b3f4f115b07d5770bbc19cb070a08eb..e3aa4c7ced4a691540215542f5a9797f4a64a12f 100644 (file)
 
     // get some essential stuff...
     if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
     if ($action == 'adminamendtitle' ) {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         if (empty($sid)) {
-            error("Admin Amend Title: submission id missing");
+            print_error("Admin Amend Title: submission id missing");
         }
 
         $submission = get_record("exercise_submissions", "id", $sid);
     elseif ($action == 'adminclearlate' ) {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         if (empty($sid)) {
-            error("Admin clear late flag: submission id missing");
+            print_error("Admin clear late flag: submission id missing");
         }
 
         if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            error("Admin clear late flag: can not get submission record");
+            print_error("Admin clear late flag: can not get submission record");
         }
         if (set_field("exercise_submissions", "late", 0, "id", $sid)) {
             print_heading(get_string("clearlateflag", "exercise")." ".get_string("ok"));
     elseif ($action == 'adminconfirmdelete' ) {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
         if (empty($sid)) {
-            error("Admin confirm delete: submission id missing");
+            print_error("Admin confirm delete: submission id missing");
         }
         if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            error("Admin delete: can not get submission record");
+            print_error("Admin delete: can not get submission record");
         }
 
         if (isteacher($course->id, $submission->userid)) {
             if (!isteacheredit($course->id)) {
-                error("Only teacher with editing permissions can delete teacher submissions.");
+                print_error("Only teacher with editing permissions can delete teacher submissions.");
             }
             if ($assessments = exercise_get_assessments($submission)) {
                 echo "<p align=\"center\">".get_string("deletesubmissionwarning", "exercise", count($assessments)).
     elseif ($action == 'admindelete' ) {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
             }
         if (empty($sid)) {
-            error("Admin delete: submission id missing");
+            print_error("Admin delete: submission id missing");
             }
 
         if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            error("Admin delete: can not get submission record");
+            print_error("Admin delete: can not get submission record");
             }
         print_string("deleting", "exercise");
         // first get any assessments...
     elseif ($action == 'adminlateflag' ) {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
             }
         if (empty($sid)) {
-            error("Admin confirm late flag: submission id missing");
+            print_error("Admin confirm late flag: submission id missing");
             }
         if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            error("Admin confirm late flag: can not get submission record");
+            print_error("Admin confirm late flag: can not get submission record");
             }
 
         notice_yesno(get_string("clearlateflag","exercise")."?",
     elseif ($action == 'adminlist' ) {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         echo "<p><small>Exercise Version-> $module->version</small></p>";
     elseif ($action == 'adminupdatetitle' ) {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
             }
         if (empty($sid)) {
-            error("Admin Update Title: submission id missing");
+            print_error("Admin Update Title: submission id missing");
             }
 
         if (set_field("exercise_submissions", "title", $title, "id", $sid)) {
             exit;
             }
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
             }
         exercise_list_unassessed_student_submissions($exercise, $USER);
         print_continue("view.php?id=$cm->id");
         $form = (object)$_POST;
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
             }
 
         // save the number of league table entries from the form...
         $form = (object)$_POST;
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
             }
 
         // save the weights from the form...
     elseif ($action == 'userconfirmdelete' ) {
 
         if (empty($sid)) {
-            error("User Confirm Delete: submission id missing");
+            print_error("User Confirm Delete: submission id missing");
             }
 
         notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("submission", "exercise")),
     elseif ($action == 'userdelete' ) {
 
         if (empty($sid)) {
-            error("User Delete: submission id missing");
+            print_error("User Delete: submission id missing");
             }
 
         if (!$submission = get_record("exercise_submissions", "id", $sid)) {
-            error("User Delete: can not get submission record");
+            print_error("User Delete: can not get submission record");
             }
         print_string("deleting", "exercise");
         // first get any assessments...
 
     else {
 
-        error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error("Fatal Error: Unknown Action: ".$action."\n");
 
         }
 
index 8a6796c0733ed35626aea17041db70daea5765eb..d7ec94ed852f97ac781ad711cce4d61831db356f 100644 (file)
 
     // get some esential stuff...
     if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
@@ -71,7 +71,7 @@
                 $newsubmission->late = 1;
             }
             if (!$newsubmission->id = insert_record("exercise_submissions", $newsubmission)) {
-                error("exercise upload: Failure to create new submission record!");
+                print_error("exercise upload: Failure to create new submission record!");
             }
             $dir = exercise_file_area_name($exercise, $newsubmission);
             if ($um->save_files($dir)) {
@@ -81,7 +81,7 @@
             // upload manager will print errors.
             // clear resubmit flags
             if (!set_field("exercise_submissions", "resubmit", 0, "exerciseid", $exercise->id, "userid", $USER->id)) {
-                error("Exercise Upload: unable to reset resubmit flag");
+                print_error("Exercise Upload: unable to reset resubmit flag");
             }
         }
         // upload manager will print errors.
index 5ee7fc7addc3f784e74e3b41fd9b2737bcf1a267..5bad9a8aace0a0da1e9346b45d97eaf2dc81f977 100644 (file)
 
     // get some esential stuff...
     if (! $cm = get_coursemodule_from_id('exercise', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $exercise = get_record("exercise", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
     elseif ($action == 'makeleaguetableavailable') {
 
         if (!isteacheredit($course->id)) {
-            error("Only teachers with editing permissions can do this.");
+            print_error("Only teachers with editing permissions can do this.");
         }
 
         set_field("exercise", "phase", 3, "id", "$exercise->id");
     elseif ($action == 'openexercise') {
 
         if (!isteacheredit($course->id)) {
-            error("Only teachers with editing permissions can do this.");
+            print_error("Only teachers with editing permissions can do this.");
         }
 
         // move to phase 2, check that teacher has made enough submissions
     elseif ($action == 'setupassignment') {
 
         if (!isteacher($course->id)) {
-            error("Only teachers with editing permissions can do this.");
+            print_error("Only teachers with editing permissions can do this.");
         }
 
         set_field("exercise", "phase", 1, "id", "$exercise->id");
     elseif ($action == 'submitassignment') {
 
         if (!has_capability('mod/exercise:assess', $context)) {
-            error("Only teachers with editing permissions can do this.");
+            print_error("Only teachers with editing permissions can do this.");
         }
 
         exercise_print_assignment_info($exercise);
     elseif ($action == 'teachersview') {
 
         if (!isteacher($course->id)) {
-            error("Only teachers can look at this page");
+            print_error("Only teachers can look at this page");
         }
 
         /// Check to see if groups are being used in this exercise
 
     /*************** no man's land **************************************/
     else {
-        error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error("Fatal Error: Unknown Action: ".$action."\n");
     }
 
     print_footer($course);
index fd3d5bd7a9669ef858e3e43c043149d591506ef5..3f019815a3d5c0a9569d0f287ef0760ef7b38fcd 100644 (file)
     $postid = optional_param('postid', 0, PARAM_INT);        // Used for tracking read posts if user initiated.
 
     if (!$discussion = get_record('forum_discussions', 'id', $d)) {
-        error("Discussion ID was incorrect or no longer exists");
+        print_error("Discussion ID was incorrect or no longer exists");
     }
 
     if (!$course = get_record('course', 'id', $discussion->course)) {
-        error("Course ID is incorrect - discussion is faulty");
+        print_error("Course ID is incorrect - discussion is faulty");
     }
 
     if (!$forum = get_record('forum', 'id', $discussion->forum)) {
@@ -26,7 +26,7 @@
     }
 
     if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     require_course_login($course, true, $cm);
@@ -38,7 +38,7 @@
         if (!($USER->id == $discussion->userid || (($discussion->timestart == 0
             || $discussion->timestart <= time())
             && ($discussion->timeend == 0 || $discussion->timeend > time())))) {
-            error('Discussion ID was incorrect or no longer exists', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
+            print_error('Discussion ID was incorrect or no longer exists', '', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
         }
     }
 
         require_capability('mod/forum:movediscussions', $modcontext);
 
         if ($forum->type == 'single') {
-            error('Cannot move discussion from a simple single discussion forum', $return);
+            print_error('Cannot move discussion from a simple single discussion forum', '', $return);
         }
 
         if (!$forumto = get_record('forum', 'id', $move)) {
-            error('You can\'t move to that forum - it doesn\'t exist!', $return);
+            print_error('You can\'t move to that forum - it doesn\'t exist!', '', $return);
         }
 
         if (!$cmto = get_coursemodule_from_instance('forum', $forumto->id, $course->id)) {
-            error('Target forum not found in this course.', $return);
+            print_error('Target forum not found in this course.', '', $return);
         }
 
         if (!coursemodule_visible_for_user($cmto)) {
-            error('Forum not visible', $return);
+            print_error('Forum not visible', '', $return);
         }
 
         if (!forum_move_attachments($discussion, $forumto->id)) {
@@ -77,8 +77,8 @@
         // the regeneration of the feeds since the discussions have been
         // moved.
         if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($forumto)) {
-            error('Could not purge the cached RSS feeds for the source and/or'.
-                   'destination forum(s) - check your file permissionsforums', $return);
+            print_error('Could not purge the cached RSS feeds for the source and/or'.
+                   'destination forum(s) - check your file permissionsforums', '', $return);
         }
 
         redirect($return.'&amp;moved=-1&amp;sesskey='.sesskey());
     }
 
     if (! $post = forum_get_post_full($parent)) {
-        error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
+        print_error("Discussion no longer exists", '', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
     }
 
 
     if (!forum_user_can_view_post($post, $course, $cm, $forum, $discussion)) {
-        error('You do not have permissions to view this post', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id");
+        print_error('You do not have permissions to view this post', '', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id");
     }
 
     if ($mark == 'read' or $mark == 'unread') {
index 282a3ae8ba93b56eb091743119699b6ca8549b47..b567c69efea02e58bb97bb606d06f02cf8037f85 100644 (file)
@@ -9,11 +9,11 @@
 
     if ($id) {
         if (! $course = get_record('course', 'id', $id)) {
-            error("Course ID is incorrect");
+            print_error("Course ID is incorrect");
         }
     } else {
         if (! $course = get_site()) {
-            error("Could not find a top-level course!");
+            print_error("Could not find a top-level course!");
         }
     }
 
index b3872402d4f24bcd946d84472785f13e7a62e3e5..178058e42b2cda374a3a34d1fb43ce4d93834845 100644 (file)
@@ -63,7 +63,7 @@ function forum_add_instance($forum) {
         $discussion->mailnow  = false;
 
         if (! forum_add_discussion($discussion, $discussion->intro)) {
-            error('Could not add the discussion for this forum');
+            print_error('Could not add the discussion for this forum');
         }
     }
 
@@ -114,11 +114,11 @@ function forum_update_instance($forum) {
                 notify('Warning! There is more than one discussion in this forum - using the most recent');
                 $discussion = array_pop($discussions);
             } else {
-                error('Could not find the discussion in this forum');
+                print_error('Could not find the discussion in this forum');
             }
         }
         if (! $post = get_record('forum_posts', 'id', $discussion->firstpost)) {
-            error('Could not find the first post in this forum discussion');
+            print_error('Could not find the first post in this forum discussion');
         }
 
         $post->subject  = $forum->name;
@@ -126,18 +126,18 @@ function forum_update_instance($forum) {
         $post->modified = $forum->timemodified;
 
         if (! update_record('forum_posts', ($post))) {
-            error('Could not update the first post');
+            print_error('Could not update the first post');
         }
 
         $discussion->name = $forum->name;
 
         if (! update_record('forum_discussions', ($discussion))) {
-            error('Could not update the discussion');
+            print_error('Could not update the discussion');
         }
     }
 
     if (!update_record('forum', $forum)) {
-        error('Can not update forum');
+        print_error('Can not update forum');
     }
 
     $forum = stripslashes_recursive($forum);
@@ -791,7 +791,7 @@ function forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $u
 
     if (!isset($userto->viewfullnames[$forum->id])) {
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
         $viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id);
@@ -941,7 +941,7 @@ function forum_user_complete($course, $user, $mod, $forum) {
     if ($posts = forum_get_user_posts($forum->id, $user->id)) {
 
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         $discussions = get_records('forum_discussions', 'forum', $forum->id); // TODO: improve
 
@@ -1508,7 +1508,7 @@ function forum_get_readable_forums($userid, $courseid=0) {
     global $CFG, $USER;
 
     if (!$forummod = get_record('modules', 'name', 'forum')) {
-        error('The forum module is not installed');
+        print_error('The forum module is not installed');
     }
 
     if ($courseid) {
@@ -2206,7 +2206,7 @@ function forum_make_mail_post($course, $forum, $discussion, $post, $userfrom, $u
 
     if (!isset($userto->viewfullnames[$forum->id])) {
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
         $viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id);
@@ -2246,7 +2246,7 @@ function forum_make_mail_post($course, $forum, $discussion, $post, $userfrom, $u
         $groups = $userfrom->groups[$forum->id];
     } else {
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         $group = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
     }
@@ -2682,7 +2682,7 @@ function forum_print_discussion_header(&$post, $forum, $group=-1, $datestring=""
 
     if (empty($modcontext)) {
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
     }
@@ -3858,7 +3858,7 @@ function forum_user_can_post_discussion($forum, $currentgroup=-1, $groupmode=-1,
         if (!$cm) {
             debugging('missing cm', DEBUG_DEVELOPER);
             if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
-                error('Course Module ID was incorrect');
+                print_error('Course Module ID was incorrect');
             }
         }
         $context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -3931,7 +3931,7 @@ function forum_user_can_post($forum, $user=NULL, $cm=NULL, $context=NULL) {
         if (!$cm) {
             debugging('missing cm', DEBUG_DEVELOPER);
             if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
-                error('Course Module ID was incorrect');
+                print_error('Course Module ID was incorrect');
             }
         }
         $context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -4047,7 +4047,7 @@ function forum_user_can_see_post($forum, $discussion, $post, $user=NULL, $cm=NUL
     if (!$cm) {
         debugging('missing cm', DEBUG_DEVELOPER);
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     }
 
@@ -4107,7 +4107,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis
 
     if (!$cm) {
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -5635,7 +5635,7 @@ function forum_check_throttling($forum) {
     }
 
     if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
     if(!has_capability('mod/forum:throttlingapplies', $modcontext)) {
@@ -5657,7 +5657,7 @@ function forum_check_throttling($forum) {
     $a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
 
     if ($forum->blockafter <= $numposts) {
-        error(get_string('forumblockingtoomanyposts','error',$a),$CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id);
+        print_error('forumblockingtoomanyposts', 'error', $CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id, $a);
     }
     if ($forum->warnafter <= $numposts) {
         notify(get_string('forumblockingalmosttoomanyposts','forum',$a));
@@ -5890,14 +5890,14 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
             $mod->groupmode = 0;
 
             if (!$cmid = add_course_module($mod)) {
-                error('Could not create new course module instance for the teacher forum');
+                print_error('Could not create new course module instance for the teacher forum');
             } else {
                 $mod->coursemodule = $cmid;
                 if (!$sectionid = add_mod_to_section($mod)) {
-                    error('Could not add converted teacher forum instance to section 0 in the course');
+                    print_error('Could not add converted teacher forum instance to section 0 in the course');
                 } else {
                     if (!set_field('course_modules', 'section', $sectionid, 'id', $cmid)) {
-                        error('Could not update course module with section id');
+                        print_error('Could not update course module with section id');
                     }
                 }
             }
@@ -5905,7 +5905,7 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
             // Change the forum type to general.
             $forum->type = 'general';
             if (!update_record('forum', $forum)) {
-                error('Could not change forum from type teacher to type general');
+                print_error('Could not change forum from type teacher to type general');
             }
 
             $context = get_context_instance(CONTEXT_MODULE, $cmid);
index aca13d435532ff53b768f43ad54c82926f4d216a..8c460356875092a1898c0537e010a9b2f12ed294 100644 (file)
     $returnpage = optional_param('returnpage', 'index.php', PARAM_FILE);    // Page to return to.
 
     if (! $forum = get_record("forum", "id", $f)) {
-        error("Forum ID was incorrect");
+        print_error("Forum ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $forum->course)) {
-        error("Forum doesn't belong to a course!");
+        print_error("Forum doesn't belong to a course!");
     }
 
     if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) {
@@ -66,7 +66,7 @@
 //            add_to_log($course->id, "forum", "mark unread", "view.php?f=$forum->id", $forum->id, $cm->id);
 //            redirect($returnto, get_string("nowtracking", "forum", $info), 1);
 //        } else {
-//            error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);
+//            print_error("Could not start tracking that forum", '', $_SERVER["HTTP_REFERER"]);
 //        }
     }
 
index 7d42ba5040a7010ad5aa6179e92415c6c83c6848..803ab30353b205f8123ff02ace7187759b1a5b6a 100644 (file)
 
         if (!empty($forum)) {      // User is starting a new discussion in a forum
             if (! $forum = get_record('forum', 'id', $forum)) {
-                error('The forum number was incorrect');
+                print_error('The forum number was incorrect');
             }
         } else if (!empty($reply)) {      // User is writing a new reply
             if (! $parent = forum_get_post_full($reply)) {
-                error('Parent post ID was incorrect');
+                print_error('Parent post ID was incorrect');
             }
             if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) {
-                error('This post is not part of a discussion!');
+                print_error('This post is not part of a discussion!');
             }
             if (! $forum = get_record('forum', 'id', $discussion->forum)) {
-                error('The forum number was incorrect');
+                print_error('The forum number was incorrect');
             }
         }
         if (! $course = get_record('course', 'id', $forum->course)) {
-            error('The course number was incorrect');
+            print_error('The course number was incorrect');
         }
 
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { // For the logs
-            error('Could not get the course module for the forum instance.');
+            print_error('Could not get the course module for the forum instance.');
         } else {
             $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
         }
 
     if (!empty($forum)) {      // User is starting a new discussion in a forum
         if (! $forum = get_record("forum", "id", $forum)) {
-            error("The forum number was incorrect ($forum)");
+            print_error("The forum number was incorrect ($forum)");
         }
         if (! $course = get_record("course", "id", $forum->course)) {
-            error("The course number was incorrect ($forum->course)");
+            print_error("The course number was incorrect ($forum->course)");
         }
         if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
-            error("Incorrect course module");
+            print_error("Incorrect course module");
         }
 
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -91,7 +91,7 @@
         }
 
         if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) {
-            error(get_string("activityiscurrentlyhidden"));
+            print_error("activityiscurrentlyhidden");
         }
 
         if (isset($_SERVER["HTTP_REFERER"])) {
     } else if (!empty($reply)) {      // User is writing a new reply
 
         if (! $parent = forum_get_post_full($reply)) {
-            error("Parent post ID was incorrect");
+            print_error("Parent post ID was incorrect");
         }
         if (! $discussion = get_record("forum_discussions", "id", $parent->discussion)) {
-            error("This post is not part of a discussion!");
+            print_error("This post is not part of a discussion!");
         }
         if (! $forum = get_record("forum", "id", $discussion->forum)) {
-            error("The forum number was incorrect ($discussion->forum)");
+            print_error("The forum number was incorrect ($discussion->forum)");
         }
         if (! $course = get_record("course", "id", $discussion->course)) {
-            error("The course number was incorrect ($discussion->course)");
+            print_error("The course number was incorrect ($discussion->course)");
         }
         if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
-            error("Incorrect cm");
+            print_error("Incorrect cm");
         }
 
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
             }
         }
         if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) {
-            error(get_string("activityiscurrentlyhidden"));
+            print_error("activityiscurrentlyhidden");
         }
 
         // Load up the $post variable.
     } else if (!empty($edit)) {  // User is editing their own post
 
         if (! $post = forum_get_post_full($edit)) {
-            error("Post ID was incorrect");
+            print_error("Post ID was incorrect");
         }
         if ($post->parent) {
             if (! $parent = forum_get_post_full($post->parent)) {
-                error("Parent post ID was incorrect ($post->parent)");
+                print_error("Parent post ID was incorrect ($post->parent)");
             }
         }
 
         if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
-            error("This post is not part of a discussion! ($edit)");
+            print_error("This post is not part of a discussion! ($edit)");
         }
         if (! $forum = get_record("forum", "id", $discussion->forum)) {
-            error("The forum number was incorrect ($discussion->forum)");
+            print_error("The forum number was incorrect ($discussion->forum)");
         }
         if (! $course = get_record("course", "id", $discussion->course)) {
-            error("The course number was incorrect ($discussion->course)");
+            print_error("The course number was incorrect ($discussion->course)");
         }
         if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
-            error('Could not get the course module for the forum instance.');
+            print_error('Could not get the course module for the forum instance.');
         } else {
             $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
         }
         if (!($forum->type == 'news' && !$post->parent && $discussion->timestart > time())) {
             if (((time() - $post->created) > $CFG->maxeditingtime) and
                         !has_capability('mod/forum:editanypost', $modcontext)) {
-                error( get_string("maxtimehaspassed", "forum", format_time($CFG->maxeditingtime)) );
+                print_error('maxtimehaspassed', 'forum', '', format_time($CFG->maxeditingtime));
             }
         }
         if (($post->userid <> $USER->id) and
                     !has_capability('mod/forum:editanypost', $modcontext)) {
-            error("You can't edit other people's posts!");
+            print_error("You can't edit other people's posts!");
         }
 
 
     }else if (!empty($delete)) {  // User is deleting a post
 
         if (! $post = forum_get_post_full($delete)) {
-            error("Post ID was incorrect");
+            print_error("Post ID was incorrect");
         }
         if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
-            error("This post is not part of a discussion!");
+            print_error("This post is not part of a discussion!");
         }
         if (! $forum = get_record("forum", "id", $discussion->forum)) {
-            error("The forum number was incorrect ($discussion->forum)");
+            print_error("The forum number was incorrect ($discussion->forum)");
         }
         if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) {
-            error('Could not get the course module for the forum instance.');
+            print_error('Could not get the course module for the forum instance.');
         }
         if (!$course = get_record('course', 'id', $forum->course)) {
-            error('Incorrect course');
+            print_error('Incorrect course');
         }
 
         require_login($course, false, $cm);
 
         if ( !(($post->userid == $USER->id && has_capability('mod/forum:deleteownpost', $modcontext))
                     || has_capability('mod/forum:deleteanypost', $modcontext)) ) {
-            error("You can't delete this post!");
+            print_error("You can't delete this post!");
         }
 
 
                         forum_go_back_to("discuss.php?d=$post->discussion"));
 
             } else if ($replycount && !has_capability('mod/forum:deleteanypost', $modcontext)) {
-                error(get_string("couldnotdeletereplies", "forum"),
+                print_error("couldnotdeletereplies", "forum",
                         forum_go_back_to("discuss.php?d=$post->discussion"));
 
             } else {
 
                     redirect(forum_go_back_to($discussionurl));
                 } else {
-                    error("An error occurred while deleting record $post->id");
+                    print_error("An error occurred while deleting record $post->id");
                 }
             }
 
 
             if ($replycount) {
                 if (!has_capability('mod/forum:deleteanypost', $modcontext)) {
-                    error(get_string("couldnotdeletereplies", "forum"),
+                    print_error("couldnotdeletereplies", "forum",
                           forum_go_back_to("discuss.php?d=$post->discussion"));
                 }
                 print_header();
     } else if (!empty($prune)) {  // Pruning
 
         if (!$post = forum_get_post_full($prune)) {
-            error("Post ID was incorrect");
+            print_error("Post ID was incorrect");
         }
         if (!$discussion = get_record("forum_discussions", "id", $post->discussion)) {
-            error("This post is not part of a discussion!");
+            print_error("This post is not part of a discussion!");
         }
         if (!$forum = get_record("forum", "id", $discussion->forum)) {
-            error("The forum number was incorrect ($discussion->forum)");
+            print_error("The forum number was incorrect ($discussion->forum)");
         }
         if ($forum->type == 'single') {
-            error('Discussions from this forum cannot be split');
+            print_error('Discussions from this forum cannot be split');
         }
         if (!$post->parent) {
-            error('This is already the first post in the discussion');
+            print_error('This is already the first post in the discussion');
         }
         if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { // For the logs
-            error('Could not get the course module for the forum instance.');
+            print_error('Could not get the course module for the forum instance.');
         } else {
             $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
         }
         if (!has_capability('mod/forum:splitdiscussions', $modcontext)) {
-            error("You can't split discussions!");
+            print_error("You can't split discussions!");
         }
 
         if (!empty($name)) {    // User has confirmed the prune
             $newdiscussion->timeend      = $discussion->timeend;
 
             if (!$newid = insert_record('forum_discussions', $newdiscussion)) {
-                error('Could not create new discussion');
+                print_error('Could not create new discussion');
             }
 
             $newpost = new object();
             $newpost->subject = $name;
 
             if (!update_record("forum_posts", $newpost)) {
-                error('Could not update the original post');
+                print_error('Could not update the original post');
             }
 
             forum_change_discussionid($post->id, $newid);
         print_footer($course);
         die;
     } else {
-        error("No operation specified");
+        print_error("No operation specified");
 
     }
 
     }
 
     if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { // For the logs
-        error('Could not get the course module for the forum instance.');
+        print_error('Could not get the course module for the forum instance.');
     }
     $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
 
             if ( !(($realpost->userid == $USER->id && (has_capability('mod/forum:replypost', $modcontext)
                                 || has_capability('mod/forum:startdiscussion', $modcontext))) ||
                                 has_capability('mod/forum:editanypost', $modcontext)) ) {
-                error("You can not update this post");
+                print_error("You can not update this post");
             }
 
             $updatepost = $fromform; //realpost
             $updatepost->forum = $forum->id;
             if (!forum_update_post($updatepost, $message)) {
-                error(get_string("couldnotupdate", "forum"), $errordestination);
+                print_error("couldnotupdate", "forum", $errordestination);
             }
 
             // MDL-11818
                 $forum->intro = $updatepost->message;
                 $forum->timemodified = time();
                 if (!update_record("forum", $forum)) {
-                    error(get_string("couldnotupdate", "forum"), $errordestination);
+                    print_error("couldnotupdate", "forum", $errordestination);
                 }
             }
 
                 redirect(forum_go_back_to("$discussionurl#p$fromform->id"), $message.$subscribemessage, $timemessage);
 
             } else {
-                error(get_string("couldnotadd", "forum"), $errordestination);
+                print_error("couldnotadd", "forum", $errordestination);
             }
             exit;
 
                 redirect(forum_go_back_to("view.php?f=$fromform->forum"), $message.$subscribemessage, $timemessage);
 
             } else {
-                error(get_string("couldnotadd", "forum"), $errordestination);
+                print_error("couldnotadd", "forum", $errordestination);
             }
 
             exit;
 
     if ($post->discussion) {
         if (! $toppost = get_record("forum_posts", "discussion", $post->discussion, "parent", 0)) {
-            error("Could not find top parent of post $post->id");
+            print_error("Could not find top parent of post $post->id");
         }
     } else {
         $toppost->subject = ($forum->type == "news") ? get_string("addanewtopic", "forum") :
 
 // checkup
     if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
-        error("You cannot reply to this post");
+        print_error("You cannot reply to this post");
     }
     if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum, -1, -1, $cm, $modcontext)) {
-        error("You cannot start a new discussion in this forum");
+        print_error("You cannot start a new discussion in this forum");
     }
 
     if ($forum->type == 'qanda'
 
     if (!empty($parent)) {
         if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) {
-            error('This post is not part of a discussion!');
+            print_error('This post is not part of a discussion!');
         }
 
         forum_print_post($parent, $discussion, $forum, $cm, $course, false, false, false);
index 7ad6b57effbf7a23d3fecb74c4a330f4f8278eb4..5d08ce716ffbf71a4c5afee189d76fd847c78dde 100644 (file)
@@ -9,15 +9,15 @@
     $forumid = required_param('forumid', PARAM_INT); // The forum the rated posts are from
 
     if (!$forum = get_record('forum', 'id', $forumid)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
     if (!$course = get_record('course', 'id', $forum->course)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
     if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     } else {
         $forum->cmidnumber = $cm->id; //MDL-12961
         }
     require_login($course, false, $cm);
 
     if (isguestuser()) {
-        error("Guests are not allowed to rate entries.");
+        print_error("Guests are not allowed to rate entries.");
     }
 
     if (!$forum->assessed) {
-        error("Rating of items not allowed!");
+        print_error("Rating of items not allowed!");
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -50,7 +50,7 @@
                      WHERE fp.id = '$postid' AND fp.discussion = fd.id AND fd.forum = $forum->id";
 
             if (!$post = get_record_sql($sql)) {
-                error("Incorrect postid - $postid");
+                print_error("Incorrect postid - $postid");
             }
 
             $discussionid = $post->discussion;
@@ -71,7 +71,7 @@
                     $oldrating->rating = $rating;
                     $oldrating->time   = time();
                     if (! update_record('forum_ratings', $oldrating)) {
-                        error("Could not update an old rating ($post->id = $rating)");
+                        print_error("Could not update an old rating ($post->id = $rating)");
                     }
                     forum_update_grades($forum, $post->userid);
                 }
@@ -84,7 +84,7 @@
                 $newrating->rating = $rating;
 
                 if (! insert_record('forum_ratings', $newrating)) {
-                    error("Could not insert a new rating ($postid = $rating)");
+                    print_error("Could not insert a new rating ($postid = $rating)");
                 }
                 forum_update_grades($forum, $post->userid);
             }
@@ -97,7 +97,7 @@
         }
 
     } else {
-        error("This page was not accessed correctly");
+        print_error("This page was not accessed correctly");
     }
 
 ?>
index ede8b138f83497d4a0241237a9b868ea40b0951b..1ed70073d53bc990e98912528979e0f4bfc2f3f8 100644 (file)
@@ -9,37 +9,37 @@
     $sort = optional_param('sort', '', PARAM_ALPHA);
 
     if (! $post = get_record('forum_posts', 'id', $id)) {
-        error("Post ID was incorrect");
+        print_error("Post ID was incorrect");
     }
 
     if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
-        error("Discussion ID was incorrect");
+        print_error("Discussion ID was incorrect");
     }
 
     if (! $forum = get_record('forum', 'id', $discussion->forum)) {
-        error("Forum ID was incorrect");
+        print_error("Forum ID was incorrect");
     }
 
     if (! $course = get_record('course', 'id', $forum->course)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
     if (! $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     require_login($course, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     if (!$forum->assessed) {
-        error("This activity does not use ratings");
+        print_error("This activity does not use ratings");
     }
 
     if (!has_capability('mod/forum:viewrating', $context)) {
-        error("You do not have the capability to view post ratings");
+        print_error("You do not have the capability to view post ratings");
     }
     if (!has_capability('mod/forum:viewanyrating', $context) and $USER->id != $post->userid) {
-        error("You can only look at results for posts that you made");
+        print_error("You can only look at results for posts that you made");
     }
 
     switch ($sort) {
@@ -58,7 +58,7 @@
     print_header("$strratings: ".format_string($post->subject));
 
     if (!$ratings = forum_get_ratings($post->id, $sqlsort)) {
-        error("No ratings for this post: \"".format_string($post->subject)."\"");
+        print_error("No ratings for this post: \"".format_string($post->subject)."\"");
 
     } else {
         echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
index dcdc15ba1e671881411667d4eeff5ce6583006b1..0f02417a0704eec777102323b2d2132c7b487f48 100644 (file)
@@ -85,7 +85,7 @@
     }
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course id is incorrect.");
+        print_error("Course id is incorrect.");
     }
 
     require_course_login($course);
         // Replace the simple subject with the three items forum name -> thread name -> subject
         // (if all three are appropriate) each as a link.
         if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
-            error('Discussion ID was incorrect');
+            print_error('Discussion ID was incorrect');
         }
         if (! $forum = get_record('forum', 'id', "$discussion->forum")) {
-            error("Could not find forum $discussion->forum");
+            print_error("Could not find forum $discussion->forum");
         }
 
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
 
         $post->subject = highlight($strippedsearch, $post->subject);
index 92238d73015e43d1faeeb920a6df2b63a9572cbb..0835cd0b3870c0dda668b90ad754ba3c2614be2e 100644 (file)
@@ -9,11 +9,11 @@
     $returnpage = optional_param('returnpage', 'index.php', PARAM_FILE);    // Page to return to.
 
     if (! $forum = get_record("forum", "id", $id)) {
-        error("Forum ID was incorrect");
+        print_error("Forum ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $forum->course)) {
-        error("Forum doesn't belong to a course!");
+        print_error("Forum doesn't belong to a course!");
     }
 
     if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) {
@@ -48,7 +48,7 @@
             add_to_log($course->id, "forum", "stop tracking", "view.php?f=$forum->id", $forum->id, $cm->id);
             redirect($returnto, get_string("nownottracking", "forum", $info), 1);
         } else {
-            error("Could not stop tracking that forum", $_SERVER["HTTP_REFERER"]);
+            print_error("Could not stop tracking that forum", $_SERVER["HTTP_REFERER"]);
         }
 
     } else { // subscribe
@@ -56,7 +56,7 @@
             add_to_log($course->id, "forum", "start tracking", "view.php?f=$forum->id", $forum->id, $cm->id);
             redirect($returnto, get_string("nowtracking", "forum", $info), 1);
         } else {
-            error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);
+            print_error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);
         }
     }
 
index 26c96b88ce6454fcc8e24b966170a77e46004112..8938ce97d2f6187f9150e0560fc1468c56f2735c 100644 (file)
     $user = optional_param('user',0,PARAM_INT);
 
     if (! $forum = get_record("forum", "id", $id)) {
-        error("Forum ID was incorrect");
+        print_error("Forum ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $forum->course)) {
-        error("Forum doesn't belong to a course!");
+        print_error("Forum doesn't belong to a course!");
     }
 
     if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
 
     if ($user) {
         if (!has_capability('mod/forum:managesubscriptions', $context)) {
-            error('You do not have the permission to subscribe/unsubscribe other people!');
+            print_error('You do not have the permission to subscribe/unsubscribe other people!');
         }
         if (!$user = get_record("user", "id", $user)) {
-            error("User ID was incorrect");
+            print_error("User ID was incorrect");
         }
     } else {
         $user = $USER;
@@ -39,7 +39,7 @@
                 and !forum_is_subscribed($user->id, $forum->id)
                 and !has_capability('moodle/site:accessallgroups', $context)) {
         if (!mygroupid($course->id)) {
-            error('Sorry, but you must be a group member to subscribe.');
+            print_error('Sorry, but you must be a group member to subscribe.');
         }
     }
 
             add_to_log($course->id, "forum", "unsubscribe", "view.php?f=$forum->id", $forum->id, $cm->id);
             redirect($returnto, get_string("nownotsubscribed", "forum", $info), 1);
         } else {
-            error("Could not unsubscribe you from that forum", $_SERVER["HTTP_REFERER"]);
+            print_error("Could not unsubscribe you from that forum", '', $_SERVER["HTTP_REFERER"]);
         }
 
     } else {  // subscribe
         if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE &&
                     !has_capability('mod/forum:managesubscriptions', $context)) {
-            error(get_string('disallowsubscribe', 'forum'),$_SERVER["HTTP_REFERER"]);
+            print_error('disallowsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
         }
         if (!has_capability('mod/forum:viewdiscussion', $context)) {
-            error("Could not subscribe you to that forum", $_SERVER["HTTP_REFERER"]);
+            print_error("Could not subscribe you to that forum", '', $_SERVER["HTTP_REFERER"]);
         }
         if (forum_subscribe($user->id, $forum->id) ) {
             add_to_log($course->id, "forum", "subscribe", "view.php?f=$forum->id", $forum->id, $cm->id);
             redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
         } else {
-            error("Could not subscribe you to that forum", $_SERVER["HTTP_REFERER"]);
+            print_error("Could not subscribe you to that forum", '', $_SERVER["HTTP_REFERER"]);
         }
     }
 
index 6e0fbf179b97d9ee3e5f2a85fd15a59147a955f0..061610c010076bab9ff4a90a5b1f2cd2556ebb0a 100644 (file)
@@ -8,11 +8,11 @@
     $edit  = optional_param('edit',-1,PARAM_BOOL);     // Turn editing on and off
 
     if (! $forum = get_record("forum", "id", $id)) {
-        error("Forum ID is incorrect");
+        print_error("Forum ID is incorrect");
     }
 
     if (! $course = get_record("course", "id", $forum->course)) {
-        error("Could not find this course!");
+        print_error("Could not find this course!");
     }
 
     if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
@@ -24,7 +24,7 @@
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     if (!has_capability('mod/forum:viewsubscribers', $context)) {
-        error('You do not have the permission to view forum subscribers');
+        print_error('You do not have the permission to view forum subscribers');
     }
 
     unset($SESSION->fromdiscussion);
 
             foreach ($frm->addselect as $addsubscriber) {
                 if (! forum_subscribe($addsubscriber, $id)) {
-                    error("Could not add subscriber with id $addsubscriber to this forum!");
+                    print_error("Could not add subscriber with id $addsubscriber to this forum!");
                 }
             }
         } else if (!empty($frm->remove) and !empty($frm->removeselect)) {
             foreach ($frm->removeselect as $removesubscriber) {
                 if (! forum_unsubscribe($removesubscriber, $id)) {
-                    error("Could not remove subscriber with id $removesubscriber from this forum!");
+                    print_error("Could not remove subscriber with id $removesubscriber from this forum!");
                 }
             }
         } else if (!empty($frm->showall)) {
index e84205a1f4ce1c958b20dc920c0129fcbc925e9b..3362310c51f403f4054c46fa0c0b547ab1b9eb90 100644 (file)
     }
 
     if (! $user = get_record("user", "id", $id)) {
-        error("User ID is incorrect");
+        print_error("User ID is incorrect");
     }
 
     if (! $course = get_record("course", "id", $course)) {
-        error("Course id is incorrect.");
+        print_error("Course id is incorrect.");
     }
 
     $syscontext = get_context_instance(CONTEXT_SYSTEM);
@@ -98,7 +98,7 @@
 
             if (!isset($discussions[$post->discussion])) {
                 if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
-                    error('Discussion ID was incorrect');
+                    print_error('Discussion ID was incorrect');
                 }
                 $discussions[$post->discussion] = $discussion;
             } else {
 
             if (!isset($forums[$discussion->forum])) {
                 if (! $forum = get_record('forum', 'id', $discussion->forum)) {
-                    error("Could not find forum $discussion->forum");
+                    print_error("Could not find forum $discussion->forum");
                 }
                 $forums[$discussion->forum] = $forum;
             } else {
 
             if (!isset($cms[$forum->id])) {
                 if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
-                    error('Course Module ID was incorrect');
+                    print_error('Course Module ID was incorrect');
                 }
                 $cms[$forum->id] = $cm;
                 unset($cm); // do not use cm directly, it would break caching
index e79ac11a744e6ca747267323670bcddcca2ae6de..40b71148f0c9598655328711deeef1f4d8ea911b 100644 (file)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('forum', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $forum = get_record("forum", "id", $cm->instance)) {
-            error("Forum ID was incorrect");
+            print_error("Forum ID was incorrect");
         }
         $strforums = get_string("modulenameplural", "forum");
         $strforum = get_string("modulename", "forum");
     } else if ($f) {
 
         if (! $forum = get_record("forum", "id", $f)) {
-            error("Forum ID was incorrect or no longer exists");
+            print_error("Forum ID was incorrect or no longer exists");
         }
         if (! $course = get_record("course", "id", $forum->course)) {
-            error("Forum is misconfigured - don't know what course it's from");
+            print_error("Forum is misconfigured - don't know what course it's from");
         }
 
         $strforums = get_string("modulenameplural", "forum");
         $strforum = get_string("modulename", "forum");
 
         if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
-            error("Course Module missing");
+            print_error("Course Module missing");
         }
 
         $buttontext = update_module_button($cm->id, $course->id, $strforum);
 
     } else {
-        error('Must specify a course module or a forum ID');
+        print_error('Must specify a course module or a forum ID');
     }
 
     if (!$buttontext) {
                     notify("Warning! There is more than one discussion in this forum - using the most recent");
                     $discussion = array_pop($discussions);
                 } else {
-                    error("Could not find the discussion in this forum");
+                    print_error("Could not find the discussion in this forum");
                 }
             }
             if (! $post = forum_get_post_full($discussion->firstpost)) {
-                error("Could not find the first post in this forum");
+                print_error("Could not find the first post in this forum");
             }
             if ($mode) {
                 set_user_preference("forum_displaymode", $mode);
index 8f717061e94a03a19f5974dcb69babb2a74b32ba..5d03612522f62993a87f264694e0c9b41830dea9 100644 (file)
     $hook = optional_param('hook','ALL', PARAM_CLEAN);
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
@@ -31,7 +31,7 @@
     $newentry->timemodified = time(); // wee need this date here to speed up recent activity, TODO: use timestamp in approved field instead in 2.0
 
     if (! update_record("glossary_entries", $newentry)) {
-        error("Could not update your glossary");
+        print_error("Could not update your glossary");
     } else {
         add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&amp;eid=$eid", "$eid",$cm->id);
     }
index c9c7e0592e084ccb5dac8f85c2e1dae8bf3d967c..fa6e690137f46d4d3d446ca4320fe692b9d10cbd 100644 (file)
@@ -7,7 +7,7 @@ require_once('comment_form.php');
 $action = optional_param('action','add', PARAM_ACTION);
 
 if (isguest()) {
-    error('Guests are not allowed to post comments!');
+    print_error('Guests are not allowed to post comments!');
 }
 
 switch ($action) {
@@ -21,7 +21,7 @@ switch ($action) {
         glossary_comment_edit();
         die;
     default:
-        error('Incorrect action specified');
+        print_error('Incorrect action specified');
 }
 
 /**
@@ -33,23 +33,23 @@ function glossary_comment_add() {
     $eid = optional_param('eid', 0, PARAM_INT); // Entry ID
 
     if (!$entry = get_record('glossary_entries', 'id', $eid)) {
-        error('Entry is incorrect');
+        print_error('Entry is incorrect');
     }
     if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        error('Incorrect glossary');
+        print_error('Incorrect glossary');
     }
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (!$course = get_record('course', 'id', $cm->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// Both the configuration and capability must allow comments
     if (!$glossary->allowcomments or !has_capability('mod/glossary:comment', $context)) {
-        error('You can\'t add comments to this glossary!');
+        print_error('You can\'t add comments to this glossary!');
     }
 
     $mform = new mod_glossary_comment_form();
@@ -70,7 +70,7 @@ function glossary_comment_add() {
         $newcomment->userid       = $USER->id;
 
         if (!$newcomment->id = insert_record('glossary_comments', $newcomment)) {
-            error('Could not insert this new comment');
+            print_error('Could not insert this new comment');
         } else {
             add_to_log($course->id, 'glossary', 'add comment', "comments.php?id=$cm->id&amp;eid=$entry->id", "$newcomment->id", $cm->id);
         }
@@ -94,28 +94,28 @@ function glossary_comment_delete() {
     $confirm = optional_param('confirm', 0, PARAM_BOOL); // delete confirmation
 
     if (!$comment = get_record('glossary_comments', 'id', $cid)) {
-        error('Comment is incorrect');
+        print_error('Comment is incorrect');
     }
     if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) {
-        error('Entry is incorrect');
+        print_error('Entry is incorrect');
     }
     if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        error('Incorrect glossary');
+        print_error('Incorrect glossary');
     }
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (!$course = get_record('course', 'id', $cm->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (($comment->userid <> $USER->id) and !has_capability('mod/glossary:managecomments', $context)) {
-        error('You can\'t delete other people\'s comments!');
+        print_error('You can\'t delete other people\'s comments!');
     }
     if (!$glossary->allowcomments and !has_capability('mod/glossary:managecomments', $context)) {
-        error('You can\'t delete comments in this glossary!');
+        print_error('You can\'t delete comments in this glossary!');
     }
 
     if (data_submitted() and $confirm) {
@@ -147,32 +147,32 @@ function glossary_comment_edit() {
     $cid = optional_param('cid', 0, PARAM_INT); // Comment ID
 
     if (!$comment = get_record('glossary_comments', 'id', $cid)) {
-        error('Comment is incorrect');
+        print_error('Comment is incorrect');
     }
     if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) {
-        error('Entry is incorrect');
+        print_error('Entry is incorrect');
     }
     if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        error('Incorrect glossary');
+        print_error('Incorrect glossary');
     }
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
     if (!$course = get_record('course', 'id', $cm->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (!$glossary->allowcomments and !has_capability('mod/glossary:managecomments', $context)) {
-        error('You can\'t edit comments in this glossary!');
+        print_error('You can\'t edit comments in this glossary!');
     }
     if (($comment->userid <> $USER->id) and !has_capability('mod/glossary:managecomments', $context)) {
-        error('You can\'t edit other people\'s comments!');
+        print_error('You can\'t edit other people\'s comments!');
     }
     $ineditperiod = ((time() - $comment->timemodified <  $CFG->maxeditingtime) || $glossary->editalways);
     if ((!has_capability('mod/glossary:comment', $context) or !$ineditperiod) and !has_capability('mod/glossary:managecomments', $context)) {
-        error('You can\'t edit this. Time expired!');
+        print_error('You can\'t edit this. Time expired!');
     }
 
     $mform = new mod_glossary_comment_form();
@@ -189,7 +189,7 @@ function glossary_comment_edit() {
         $updatedcomment->timemodified = time();
 
         if (!update_record('glossary_comments', $updatedcomment)) {
-            error('Could not update this comment');
+            print_error('Could not update this comment');
         } else {
             add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&amp;eid=$entry->id", "$updatedcomment->id",$cm->id);
         }
index cf13f26c1d57f9374b3deb6ffaea93d1e548b31a..ca3c03087d3bed40d100da697f9e3ea802765dd2 100644 (file)
     global $USER, $CFG;
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     if (! $entry = get_record("glossary_entries", "id", $eid)) {
-        error("Entry is incorrect");
+        print_error("Entry is incorrect");
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
index e3a8ab01137a7078fffab05746542190155cb3eb..b1a62d1b25a3027b31608727f5fbfd6f384a3ceb 100644 (file)
 
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $entry = get_record("glossary_entries","id", $entry)) {
-        error("Entry ID was incorrect");
+        print_error("Entry ID was incorrect");
     }
 
     require_login($course->id, false, $cm);
@@ -33,7 +33,7 @@
     $manageentries = has_capability('mod/glossary:manageentries', $context); 
     
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Glossary is incorrect");
+        print_error("Glossary is incorrect");
     }
 
 
                   navmenu($course, $cm));
 
     if (($entry->userid != $USER->id) and !$manageentries) { // guest id is never matched, no need for special check here
-        error("You can't delete other people's entries!");
+        print_error("You can't delete other people's entries!");
     }
     $ineditperiod = ((time() - $entry->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
     if (!$ineditperiod and !$manageentries) {
-        error("You can't delete this. Time expired!");
+        print_error("You can't delete this. Time expired!");
     }
 
 /// If data submitted, then process and store.
@@ -63,7 +63,7 @@
             $dbentry->glossaryid = $entry->sourceglossaryid;
             $dbentry->sourceglossaryid = 0;
             if (! update_record('glossary_entries', $dbentry)) {
-                error("Could not update your glossary");
+                print_error("Could not update your glossary");
             }
 
         } else {
index 7a2734ffd30cb77628ccff2ec3dcb06e7a8d1874..3f304b8e013479fd4d1159acb9d159d26223394b 100644 (file)
@@ -14,34 +14,34 @@ $mode = optional_param('mode', '', PARAM_ALPHA);      // categories if by catego
 $hook = optional_param('hook', '', PARAM_ALPHANUM);   // CategoryID
 
 if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-    error("Course Module ID was incorrect");
+    print_error("Course Module ID was incorrect");
 }
 
 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
 if (! $course = get_record("course", "id", $cm->course)) {
-    error("Course is misconfigured");
+    print_error("Course is misconfigured");
 }
 
 require_login($course->id, false, $cm);
 
 if ( isguest() ) {
-    error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]);
+    print_error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]);
 }
 
 if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-    error("Course module is incorrect");
+    print_error("Course module is incorrect");
 }
 
 
 if ($e) { // if entry is specified
     if (!$entry  = get_record("glossary_entries", "id", $e)) {
-        error("Incorrect entry id");
+        print_error("Incorrect entry id");
     }
     $ineditperiod = ((time() - $entry->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
     if (!has_capability('mod/glossary:manageentries', $context) and !($entry->userid == $USER->id and ($ineditperiod and has_capability('mod/glossary:write', $context)))) {
         //expired edit time is the most probable cause here
-        error(get_string('erredittimeexpired', 'glossary'), "view.php?id=$cm->id&amp;mode=entry&amp;hook=$e");
+        print_error('erredittimeexpired', 'glossary', "view.php?id=$cm->id&amp;mode=entry&amp;hook=$e");
     }
 } else { // new entry
     require_capability('mod/glossary:write', $context);
@@ -98,7 +98,7 @@ if ($mform->is_cancelled()){
                        "view.php?id=$cm->id&amp;mode=entry&amp;hook=$todb->id",
                        $todb->id, $cm->id);
         } else {
-            error("Could not update your glossary");
+            print_error("Could not update your glossary");
         }
     } else {
 
@@ -117,7 +117,7 @@ if ($mform->is_cancelled()){
             add_to_log($course->id, "glossary", "add entry",
                        "view.php?id=$cm->id&amp;mode=entry&amp;hook=$todb->id", $todb->id,$cm->id);
         } else {
-            error("Could not insert this new entry");
+            print_error("Could not insert this new entry");
         }
 
     }
@@ -174,9 +174,9 @@ if ($mform->is_cancelled()){
         $ineditperiod = ((time() - $fromdb->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
         if ((!$ineditperiod  || $USER->id != $fromdb->userid) and !has_capability('mod/glossary:manageentries', $context)) {
             if ( $USER->id != $fromdb->userid ) {
-                error(get_string('errcannoteditothers', 'glossary'));
+                print_error('errcannoteditothers', 'glossary');
             } elseif (!$ineditperiod) {
-                error(get_string('erredittimeexpired', 'glossary'));
+                print_error('erredittimeexpired', 'glossary');
             }
             die;
         }
index ca1b584b9ff9eddf0363a17ba6a486ee6654f0e1..d0da1fea4040f18f71c4321640383337b278d58e 100644 (file)
     $action = strtolower($action);
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     if ($hook > 0) {
         if ($category = get_record("glossary_categories","id",$hook)) {
             //Check it belongs to the same glossary
             if ($category->glossaryid != $glossary->id) {
-                error("Glossary is incorrect");
+                print_error("Glossary is incorrect");
             }
         } else {
-            error("Category is incorrect");
+            print_error("Category is incorrect");
         }
     }
 
@@ -68,7 +68,7 @@
                 $cat->usedynalink = $usedynalink;
 
                 if ( !update_record("glossary_categories", $cat) ) {
-                    error("Weird error. The category was not updated.");
+                    print_error("Weird error. The category was not updated.");
                     redirect("editcategories.php?id=$cm->id");
                 } else {
                     add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id);
                 $cat->glossaryid = $glossary->id;
 
                 if ( ! $cat->id = insert_record("glossary_categories", $cat) ) {
-                    error("Weird error. The category was not inserted.");
+                    print_error("Weird error. The category was not inserted.");
 
                     redirect("editcategories.php?id=$cm->id");
                 } else {
index 0f91fabf214baf6c30e6b094e463b0d669b0bda8..ae77f1497eb635910db0e8789ffebf1d2b9bba6b 100644 (file)
     $cat = optional_param('cat',0, PARAM_ALPHANUM);
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);  
index 5013abd96d6190c0eafbacd2c3b3c6f948d92ae2..05e2a09820016056f2330e396b0cb694bf405a17 100644 (file)
     require_capability('mod/glossary:export', $context);
 
     if (! $course = get_record('course', 'id', $cm->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     if (! $glossary = get_record('glossary', 'id', $cm->instance)) {
-        error('Course module is incorrect');
+        print_error('Course module is incorrect');
     }
 
     $strglossaries   = get_string('modulenameplural', 'glossary');
@@ -66,7 +66,7 @@
                 $dbentry->sourceglossaryid = $glossary->id;
                 
                 if (! update_record('glossary_entries', $dbentry)) {
-                    error('Could not export the entry to the main glossary');
+                    print_error('Could not export the entry to the main glossary');
                 } else {
                     print_simple_box_start('center', '60%');
                     echo '<p align="center"><font size="3">'.$entryexported.'</font></p></font>';
index b88059b5ce2548df966cfd3edc3af47a8d0a057e..6df185d19cc4efdd4775d7f00f430f2b9c1834d5 100644 (file)
     $cat = optional_param('cat',0, PARAM_ALPHANUM);
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
index 56edc02a42aae3d280dc61fa931c52115b0fb1b6..26bf0b8bb12d6f1a549dd580db8fcf92473351d3 100644 (file)
     $hook     = optional_param('hook', 'ALL', PARAM_ALPHANUM);
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);  
                     // to each other, so we have to update one of them twice.
 
                     if (! $currmodule = get_record("modules", "name", 'glossary')) {
-                        error("Glossary module doesn't exist");
+                        print_error("Glossary module doesn't exist");
                     }
                     $mod->module = $currmodule->id;
                     $mod->course = $course->id;
                     $mod->section = 0;
 
                     if (! $mod->coursemodule = add_course_module($mod) ) {
-                        error("Could not add a new course module");
+                        print_error("Could not add a new course module");
                     }
 
                     if (! $sectionid = add_mod_to_section($mod) ) {
-                        error("Could not add the new course module to that section");
+                        print_error("Could not add the new course module to that section");
                     }
                     //We get the section's visible field status
                     $visible = get_field("course_sections","visible","id",$sectionid);
 
                     if (! set_field("course_modules", "visible", $visible, "id", $mod->coursemodule)) {
-                        error("Could not update the course module with the correct visibility");
+                        print_error("Could not update the course module with the correct visibility");
                     }
 
                     if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
-                        error("Could not update the course module with the correct section");
+                        print_error("Could not update the course module with the correct section");
                     }
                     add_to_log($course->id, "course", "add mod",
                                "../mod/$mod->modulename/view.php?id=$mod->coursemodule",
index 6b53b9e2669082fb956fc5f34a8f5e0c00d7fa8a..5537e15d8b19b3e875af810cdd453619351ecbd2 100644 (file)
@@ -11,7 +11,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index 7b41ebb02fa88b35f9fe96531b69762f9485d938..ef27bfc5c66f5acb63148990fbf5948744623a76 100644 (file)
@@ -49,7 +49,7 @@ function glossary_add_instance($glossary) {
     //Check displayformat is a valid one
     $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
     if (!in_array($glossary->displayformat, $formats)) {
-        error("This format doesn't exist!");
+        print_error("This format doesn't exist!");
     }
 
     if ($returnid = insert_record("glossary", $glossary)) {
@@ -92,7 +92,7 @@ function glossary_update_instance($glossary) {
     //Check displayformat is a valid one
     $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
     if (!in_array($glossary->displayformat, $formats)) {
-        error("This format doesn't exist!");
+        print_error("This format doesn't exist!");
     }
 
     if ($return = update_record("glossary", $glossary)) {
@@ -1644,13 +1644,13 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
     if ( $entries ) {
         foreach ( $entries as $entry ) {
             if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-                error('Glossary ID was incorrect or no longer exists');
+                print_error('Glossary ID was incorrect or no longer exists');
             }
             if (! $course = get_record('course', 'id', $glossary->course)) {
-                error('Glossary is misconfigured - don\'t know what course it\'s from');
+                print_error('Glossary is misconfigured - don\'t know what course it\'s from');
             }
             if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid, $glossary->course) ) {
-                error('Glossary is misconfigured - don\'t know what course module it is');
+                print_error('Glossary is misconfigured - don\'t know what course module it is');
             }
 
             //If displayformat is present, override glossary->displayformat
index 779cafc7a49896816117453c063ddd2e7d198494..278659aaa20c7a2ab377912a21fe9708c2a3c1c3 100644 (file)
     $sortkey = optional_param('sortkey','UPDATE', PARAM_ALPHA); // Sorting key
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     if ( !$entriesbypage = $glossary->entbypage ) {
index 3d086b7f76c629dbb3de25dbe5cf81ea7f688286..c323e72c1c2614f8503705a5535e7e23c3a86f52 100644 (file)
@@ -9,27 +9,27 @@
     $glossaryid = required_param('glossaryid', PARAM_INT); // The forum the rated posts are from
 
     if (!$glossary = get_record('glossary', 'id', $glossaryid)) {
-        error("Incorrect glossary id");
+        print_error("Incorrect glossary id");
     }
 
     if (!$course = get_record('course', 'id', $glossary->course)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     require_login($course, false, $cm);
 
     if (isguestuser()) {
-        error("Guests are not allowed to rate entries.");
+        print_error("Guests are not allowed to rate entries.");
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     if (!$glossary->assessed) {
-        error("Rating of items not allowed!");
+        print_error("Rating of items not allowed!");
     }
 
     if ($glossary->assessed == 2) {
@@ -52,7 +52,7 @@
             }
 
             if ($entry->glossaryid != $glossary->id) {
-                error("This is not valid entry!");
+                print_error("This is not valid entry!");
             }
 
             if ($glossary->assesstimestart and $glossary->assesstimefinish) {
@@ -77,7 +77,7 @@
                     $oldrating->rating = $rating;
                     $oldrating->time = time();
                     if (! update_record("glossary_ratings", $oldrating)) {
-                        error("Could not update an old rating ($entry = $rating)");
+                        print_error("Could not update an old rating ($entry = $rating)");
                     }
                     glossary_update_grades($glossary, $entry->userid);
                 }
@@ -90,7 +90,7 @@
                 $newrating->rating  = $rating;
 
                 if (! insert_record("glossary_ratings", $newrating)) {
-                    error("Could not insert a new rating ($entry->id = $rating)");
+                    print_error("Could not insert a new rating ($entry->id = $rating)");
                 }
                 glossary_update_grades($glossary, $entry->userid);
             }
@@ -99,7 +99,7 @@
         redirect($returnurl, get_string("ratingssaved", "glossary"));
 
     } else {
-        error("This page was not accessed correctly");
+        print_error("This page was not accessed correctly");
     }
 
 ?>
index 93496ca6379856d1127453e03df1f74819dbcd39..b89d56d3bd1621a9127da8c66b4271228d4d7772 100644 (file)
@@ -9,30 +9,30 @@
     $sort = optional_param('sort', '', PARAM_ALPHA);
 
     if (! $entry = get_record('glossary_entries', 'id', $id)) {
-        error("Entry ID was incorrect");
+        print_error("Entry ID was incorrect");
     }
 
     if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        error("Glossary ID was incorrect");
+        print_error("Glossary ID was incorrect");
     }
 
     if (! $course = get_record('course', 'id', $glossary->course)) {
-        error("Course ID was incorrect");
+        print_error("Course ID was incorrect");
     }
 
     if (! $cm = get_coursemodule_from_instance('glossary', $glossary->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     require_login($course, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     if (!$glossary->assessed) {
-        error("This activity does not use ratings");
+        print_error("This activity does not use ratings");
     }
 
     if (!has_capability('mod/glossary:manageentries', $context) and $USER->id != $entry->userid) {
-        error("You can only look at results for your own entries");
+        print_error("You can only look at results for your own entries");
     }
 
     switch ($sort) {
@@ -51,7 +51,7 @@
     print_header("$strratings: $entry->concept");
 
     if (!$ratings = glossary_get_ratings($entry->id, $sqlsort)) {
-        error("No ratings for this entry: \"$entry->concept\"");
+        print_error("No ratings for this entry: \"$entry->concept\"");
 
     } else {
         echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" style=\"width:100%\">";
index 9d4338badb8a7400b9e91ce9b80798631975e257..1650643fe5cc7cf6ff72cd7bc768089ced3464d6 100644 (file)
@@ -16,7 +16,7 @@
         $glossary = get_record('glossary','id',$entry->glossaryid);
         $entry->glossaryname = format_string($glossary->name,true);
         if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id)) {
-            error("Could not determine which course module this belonged to!");
+            print_error("Could not determine which course module this belonged to!");
         }
         if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) {
             redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course, get_string('activityiscurrentlyhidden'));
@@ -27,7 +27,7 @@
     } else if ($concept) {
         $entries = glossary_get_entries_search($concept, $courseid);
     } else {
-        error('No valid entry specified');
+        print_error('No valid entry specified');
     }
 
     if ($entries) {
index 166afef13b1e5fc5fa03244d0c124528a2e2cbc9..efac7625e884890d61d82ea4cefb9c4f2c76a589 100644 (file)
 
     if (!empty($id)) {
         if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
     } else if (!empty($g)) {
         if (! $glossary = get_record("glossary", "id", $g)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $glossary->course)) {
-            error("Could not determine which course this belonged to!");
+            print_error("Could not determine which course this belonged to!");
         }
         if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id)) {
-            error("Could not determine which course module this belonged to!");
+            print_error("Could not determine which course module this belonged to!");
         }
         $id = $cm->id;
     } else {
-        error("Must specify glossary ID or course module ID");
+        print_error("Must specify glossary ID or course module ID");
     }
 
     require_course_login($course->id, true, $cm);
index 790d92b9b32f20290baa3fe093a989752eaafa03..b64e8bc0bf69b09d8e2d1790b82e9bb083eb756a 100644 (file)
@@ -6,19 +6,19 @@
 
     // get attempt, hotpot, course and course_module records
     if (! $attempt = get_record("hotpot_attempts", "id", $attemptid)) {
-        error("Hot Potatoes attempt record $attemptid could not be accessed: ".$db->ErrorMsg());
+        print_error("Hot Potatoes attempt record $attemptid could not be accessed: ".$db->ErrorMsg());
     }
     if ($attempt->userid != $USER->id) {
-        error("User ID is incorrect");
+        print_error("User ID is incorrect");
     }
     if (! $hotpot = get_record("hotpot", "id", $attempt->hotpot)) {
-        error("Hot Potatoes ID is incorrect (attempt id = $attempt->id)");
+        print_error("Hot Potatoes ID is incorrect (attempt id = $attempt->id)");
     }
     if (! $course = get_record("course", "id", $hotpot->course)) {
-        error("Course ID is incorrect (hotpot id = $hotpot->id)");
+        print_error("Course ID is incorrect (hotpot id = $hotpot->id)");
     }
     if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
-        error("Course Module ID is incorrect");
+        print_error("Course Module ID is incorrect");
     }
 
     // make sure this user is enrolled in this course
@@ -82,7 +82,7 @@
             $attempt->id = insert_record("hotpot_attempts", $attempt);
 
             if (empty($attempt->id)) {
-                error("Could not insert attempt record: ".$db->ErrorMsg(), $next_url);
+                print_error("Could not insert attempt record: ".$db->ErrorMsg(), '', $next_url);
             }
 
             // 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)) {
-                    error("Could not insert attempt details record: ".$db->ErrorMsg(), $next_url);
+                    print_error("Could not insert attempt details record: ".$db->ErrorMsg(), '', $next_url);
                 }
             }
         } else {
 
     // update the attempt record
     if (! update_record("hotpot_attempts", $attempt)) {
-        error("Could not update attempt record: ".$db->ErrorMsg(), $next_url);
+        print_error("Could not update attempt record: ".$db->ErrorMsg(), '', $next_url);
     }
 
     // update grades for this user
             $details->attempt = $attempt->id;
             $details->details = $attempt->details;
             if (! insert_record("hotpot_details", $details)) {
-                error("Could not insert attempt details record: ".$db->ErrorMsg(), $next_url);
+                print_error("Could not insert attempt details record: ".$db->ErrorMsg(), '', $next_url);
             }
         }
     }
@@ -214,8 +214,8 @@ function hotpot_set_attempt_details(&$attempt) {
     }
     if (!$ok) {
         return;
-        // error('Quiz type is missing or invalid');
-        // error(get_string('error_invalidquiztype', 'hotpot'));
+        // print_error('Quiz type is missing or invalid');
+        // print_error('error_invalidquiztype', 'hotpot');
         //
         // script finishes here if quiztype is invalid
         //
index 1afda285f854c73bbe78e2e153a23835872bd569..0b7e9eef4762311405932c4abc18259935757d0d 100644 (file)
@@ -5,15 +5,15 @@
     $id   = required_param('id', PARAM_INT);          // Course module ID
 
     if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $hotpot = get_record("hotpot", "id", $cm->instance)) {
-        error("hotpot ID was incorrect");
+        print_error("hotpot ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $hotpot->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
index 7077710f8da8a0018fe734849eab34456231a2dd..88870004c4351ffb8e74a88d28091f562ffef6e9 100644 (file)
@@ -8,7 +8,7 @@
 
     $id = required_param('id', PARAM_INT);   // course    
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_login($course->id);
                             if ($attempt->details) {
                                 hotpot_add_attempt_details($attempt);
                                 if (! update_record('hotpot_attempts', $attempt)) {
-                                    error("Could not update attempt record: ".$db->ErrorMsg(), $next_url);
+                                    print_error("Could not update attempt record: ".$db->ErrorMsg(), '', $next_url);
                                 }
                             }
                             $attemptcount++;
index ea663bed829f8c98f89e1f9d1fd089025986f384..fcea20a8d208bc264ff7f4ff2a29fef5be31ae19 100644 (file)
@@ -455,7 +455,7 @@ function hotpot_is_visible(&$cm) {
 
     if (!isset($cm->sectionvisible)) {
         if (! $section = get_record('course_sections', 'id', $cm->section)) {
-            error('Course module record contains invalid section');
+            print_error('Course module record contains invalid section');
         }
         $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)) {
-                error("Could not add a new instance of $hotpot->modulename", "view.php?id=$hotpot->course");
+                print_error("Could not add a new instance of $hotpot->modulename", '', "view.php?id=$hotpot->course");
             }
 
             // store (hotpot table) id of start of chain
@@ -582,14 +582,14 @@ function hotpot_add_chain(&$hotpot) {
             }
 
             if (! $hotpot->coursemodule = add_course_module($hotpot)) {
-                error("Could not add a new course module");
+                print_error("Could not add a new course module");
             }
             if (! $sectionid = add_mod_to_section($hotpot) ) {
-                error("Could not add the new course module to that section");
+                print_error("Could not add the new course module to that section");
             }
 
             if (! set_field("course_modules", "section", $sectionid, "id", $hotpot->coursemodule)) {
-                error("Could not update the course module with the correct section");
+                print_error("Could not update the course module with the correct section");
             }
 
             add_to_log($hotpot->course, "course", "add mod",
@@ -868,7 +868,7 @@ function hotpot_update_chain(&$hotpot) {
 
                 // update $thishotpot, if required
                 if ($require_update && !update_record("hotpot", $thishotpot)) {
-                    error("Could not update the $hotpot->modulename", "view.php?id=$hotpot->course");
+                    print_error("Could not update the $hotpot->modulename", '', "view.php?id=$hotpot->course");
                 }
             }
         } // end foreach $ids
@@ -1586,7 +1586,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
 
         // check xmlize functions are available
         if (! function_exists("xmlize")) {
-            error('xmlize functions are not available');
+            print_error('xmlize functions are not available');
         }
 
         $this->read_file = $read_file;
@@ -1611,7 +1611,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
         if (empty($this->course) || empty($this->reference)) {
             $this->error = get_string('error_nocourseorfilename', 'hotpot');
             if ($this->report_errors) {
-                error($this->error);
+                print_error($this->error);
             }
             return;
         }
@@ -1647,7 +1647,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
             if (!file_exists($this->filepath) || !is_readable($this->filepath)) {
                 $this->error = get_string('error_couldnotopensourcefile', 'hotpot', $this->filepath);
                 if ($this->report_errors) {
-                    error($this->error, $this->course_homeurl);
+                    print_error($this->error, '', $this->course_homeurl);
                 }
                 return;
             }
@@ -1754,7 +1754,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
                     if (!file_exists($this->template_filepath) || !is_readable($this->template_filepath)) {
                         $this->error = get_string('error_couldnotopentemplate', 'hotpot', $this->template_dir);
                         if ($this->report_errors) {
-                            error($this->error, $this->course_homeurl);
+                            print_error($this->error, '', $this->course_homeurl);
                         }
                         return;
                     }
@@ -2206,7 +2206,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)) {
-                error("Could not add question record (attempt_id=$attempt->id): ".$db->ErrorMsg(), $next_url);
+                print_error("Could not add question record (attempt_id=$attempt->id): ".$db->ErrorMsg(), '', $next_url);
             }
         }
 
@@ -2231,7 +2231,7 @@ function hotpot_add_response(&$attempt, &$question, &$response) {
 
             // add response record
             if(!$response->id = insert_record('hotpot_responses', $response)) {
-                error("Could not add response record (attempt_id=$attempt->id, question_id=$question->id): ".$db->ErrorMsg(), $next_url);
+                print_error("Could not add response record (attempt_id=$attempt->id, question_id=$question->id): ".$db->ErrorMsg(), '', $next_url);
             }
 
             // we can stop looping now
@@ -2385,7 +2385,7 @@ function hotpot_string_id($str) {
             // try and add the new string record
             if (!$id = insert_record('hotpot_strings', $record)) {
                 global $db;
-                error("Could not add string record for '".htmlspecialchars($str)."': ".$db->ErrorMsg());
+                print_error("Could not add string record for '".htmlspecialchars($str)."': ".$db->ErrorMsg());
             }
         }
     }
index bc233a3e7da0f357566913d166b43cc34ae67766..d7b2c2a1f4b06ab5d21c302b205cc650037e8df9 100644 (file)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }    
         if (! $hotpot = get_record("hotpot", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
 
     } else {
         if (! $hotpot = get_record("hotpot", "id", $hp)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $hotpot->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
 
 /// Open the selected hotpot report and display it
 
     if (! is_readable("report/$mode/report.php")) {
-        error("Report not known (".clean_text($mode).")", $course_homeurl);
+        print_error("Report not known (".clean_text($mode).")", '', $course_homeurl);
     }
 
     include("report/default.php");  // Parent class
     $report = new hotpot_report();
 
     if (! $report->display($hotpot, $cm, $course, $users, $attempts, $questions, $formdata)) {
-        error("Error occurred during report processing!", $course_homeurl);
+        print_error("Error occurred during report processing!", '', $course_homeurl);
     }
 
     if ($formdata['reportformat']=='htm') {
index 0eef8953cf2f6b614a59ad7f74dad2450b8e27b6..583cf178574f498c1ed8a4d61130f7849dd2938e 100644 (file)
@@ -9,27 +9,27 @@
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $hotpot = get_record("hotpot", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
     } else {
         if (! $hotpot = get_record("hotpot", "id", $hp)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $hotpot->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
     if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) {
-        error("Attempt ID was incorrect");
+        print_error("Attempt ID was incorrect");
     }
 
     require_login($course, true, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (!has_capability('mod/hotpot:viewreport',$context)) {
         if (!$hotpot->review) {
-            error(get_string("noreview", "quiz"));
+            print_error("noreview", "quiz");
         }
         //if (time() < $hotpot->timeclose) {
-        //  error(get_string("noreviewuntil", "quiz", userdate($hotpot->timeclose)));
+        //  print_error("noreviewuntil", "quiz", '', userdate($hotpot->timeclose));
         //}
         if ($attempt->userid != $USER->id) {
-            error("This is not your attempt!");
+            print_error("This is not your attempt!");
         }
     }
     add_to_log($course->id, "hotpot", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id");
index a87d3318cff0a56fbe838f208a94e8fdb2e66d8e..23d7b1dca096343c9e644ada7c85ad402af90c5a 100644 (file)
@@ -11,7 +11,7 @@
     require_login($params->course);
 
     if (!has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $params->course))) {
-        error("You are not allowed to view this page!");
+        print_error("You are not allowed to view this page!");
     }
     if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
         $params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES, PARAM_INT);
index b570e4b3400f3e33b1e2159c87f0ae254495e962..307199c0fd6e5f19f6fbaec10b562cfaae99c7d0 100644 (file)
@@ -6,7 +6,7 @@ class hotpot_xml_template_default {
         // try and open the template file
         if (!file_exists($filepath) || !is_readable($filepath)) {
             $msg = 'Could not open the '.$this->parent->template_dir.' template file &quot;'.$filepath.'&quot;';
-            error($msg, $this->parent->course_homeurl);
+            print_error($msg, '', $this->parent->course_homeurl);
         }
         // read in the template and close the file
         $this->$tag = file_get_contents($filepath);
@@ -40,7 +40,7 @@ class hotpot_xml_template_default {
                 }
             } else {
                 $msg = 'Template block expand method not found: &quot;'.$method.'&quot;';
-                error($msg, $this->parent->course_homeurl);
+                print_error($msg, '', $this->parent->course_homeurl);
             }
         }
     }
index c04afd7d933541dd84cb6b153ec8fe2882cfc72c..b5d8e405f109d010c50794764aa0f446ceecacc0 100644 (file)
 
         if ($id) {
             if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
-                error("Course Module ID was incorrect");
+                print_error("Course Module ID was incorrect");
             }
             if (! $course = get_record("course", "id", $cm->course)) {
-                error("Course is misconfigured");
+                print_error("Course is misconfigured");
             }
             if (! $hotpot = get_record("hotpot", "id", $cm->instance)) {
-                error("Course module is incorrect");
+                print_error("Course module is incorrect");
             }
 
         } else {
             if (! $hotpot = get_record("hotpot", "id", $hp)) {
-                error("Course module is incorrect");
+                print_error("Course module is incorrect");
             }
             if (! $course = get_record("course", "id", $hotpot->course)) {
-                error("Course is misconfigured");
+                print_error("Course is misconfigured");
             }
             if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
-                error("Course Module ID was incorrect");
+                print_error("Course Module ID was incorrect");
             }
 
         }
     }
     // open and parse the source file
     if(!$hp = new hotpot_xml_quiz($hotpot)) {
-        error("Quiz is unavailable at the moment");
+        print_error("Quiz is unavailable at the moment");
     }
     $get_js = optional_param('js', '', PARAM_ALPHA);
     $get_css = optional_param('css', '', PARAM_ALPHA);
 
                 $attemptid = hotpot_add_attempt($hotpot->id);
                 if (! is_numeric($attemptid)) {
-                    error('Could not insert attempt record: '.$db->ErrorMsg);
+                    print_error('Could not insert attempt record: '.$db->ErrorMsg);
                 }
             }
             $hp->adjust_media_urls();
index 79ed2eada6ee3d8148665ba29342108b47d9697e..136d96f3dd82541ba6af925138db93d2dfc6deca 100644 (file)
@@ -5,21 +5,21 @@
     $id = required_param('id', PARAM_INT);    // Course Module ID
 
     if (! $cm = get_coursemodule_from_id('journal', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
 
     if (isguest()) {
-        error("Guests are not allowed to edit journals", $_SERVER["HTTP_REFERER"]);
+        print_error("Guests are not allowed to edit journals", '', $_SERVER["HTTP_REFERER"]);
     }
 
     if (! $journal = get_record("journal", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     $entry = get_record("journal_entries", "userid", $USER->id, "journal", $journal->id);
@@ -39,7 +39,7 @@
             $newentry->format = $form->format;
             $newentry->modified = $timenow;
             if (! update_record("journal_entries", $newentry)) {
-                error("Could not update your journal");
+                print_error("Could not update your journal");
             }
             add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id", $cm->id);
         } else {
@@ -49,7 +49,7 @@
             $newentry->format = $form->format;
             $newentry->modified = $timenow;
             if (! $newentry->id = insert_record("journal_entries", $newentry)) {
-                error("Could not insert a new journal entry");
+                print_error("Could not insert a new journal entry");
             }
             add_to_log($course->id, "journal", "add entry", "view.php?id=$cm->id", "$newentry->id", $cm->id);
         }
index 0a9a90791d848abd6c0dfc84ff05feb68067122d..4a06991c9a0a1e58db5ab5b295feca95a059b393 100644 (file)
@@ -6,7 +6,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index 90e9c9aa471e164d2c05f65c78e2abd94c150d71..47c48f20ad8fbaef6c0c6b587530262c7b98f392 100644 (file)
@@ -506,7 +506,7 @@ function journal_print_feedback($course, $entry, $grades) {
     global $CFG;
 
     if (! $teacher = get_record('user', 'id', $entry->teacher)) {
-        error('Weird journal error');
+        print_error('Weird journal error');
     }
 
     echo '<table cellspacing="0" align="center" class="feedbackbox">';
index 441f9d86f767c7871e0c19b0aa7d2e49179721ca..58762c6656c0cc179328ca8d2403af58ca4bc37e 100644 (file)
@@ -6,21 +6,21 @@
     $id = required_param('id', PARAM_INT);   // course module
 
     if (! $cm = get_coursemodule_from_id('journal', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course module is misconfigured");
+        print_error("Course module is misconfigured");
     }
 
     require_login($course->id, false, $cm);
 
     if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
+        print_error("Only teachers can look at this page");
     }
 
     if (! $journal = get_record("journal", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     // make some easy ways to access the entries.
index 7dad3fcd826344832bba1210e1d0445b240664e0..0283f5f68bd0581648bbefe37d0c56ef1f9cb67a 100644 (file)
@@ -6,23 +6,23 @@
     $id = required_param('id', PARAM_INT);    // Course Module ID
 
     if (! $cm = get_coursemodule_from_id('journal', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, true, $cm);
 
     if (! $journal = get_record("journal", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     add_to_log($course->id, "journal", "view", "view.php?id=$cm->id", $journal->id, $cm->id);
 
     if (! $cw = get_record("course_sections", "id", $cm->section)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     $strjournal = get_string("modulename", "journal");
index 74a8b3011261d67b093b7001303f388705519124..f450a55dd3f749932ba9a26f8700f4db4b250854 100644 (file)
@@ -7,26 +7,26 @@
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('label', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
     
         if (! $label = get_record("label", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
 
     } else {
         if (! $label = get_record("label", "id", $l)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $label->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("label", $label->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
 
index 94fae61b8142c273b0f48f9b8f5be4108334d214..97789e928d6fb96323b9760b38f6d08d70a126fc 100644 (file)
@@ -8,7 +8,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_login($course->id);
index 527c7ab159d745c0eaff8eba6feab382bb24d8c1..c3755a10cd601f376f159f17ccb062a3b5786b09 100644 (file)
@@ -10,15 +10,15 @@ require_once("constants.php");
 $id = optional_param('id', 0, PARAM_INT);    // Course Module ID, or
 
 if (! $cm = get_coursemodule_from_id('lams', $id)) {
-    error("Course Module ID was incorrect");
+    print_error("Course Module ID was incorrect");
 }
 
 if (! $course = get_record("course", "id", $cm->course)) {
-    error("Course is misconfigured");
+    print_error("Course is misconfigured");
 }
 
 if (! $lams = get_record("lams", "id", $cm->instance)) {
-    error("Course module is incorrect");
+    print_error("Course module is incorrect");
 }
 
 require_login($course, true, $cm);
index 3fb28ef18e0b6b16e332fb9e42dcbbbb38ab95bc..7b1ffba6dde0e38ec54a68a4334eb9bb069644da 100644 (file)
@@ -20,7 +20,7 @@
     $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
     if (!optional_param('firstpage', 0, PARAM_INT)) {
         if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
-            error("Add page: first page not found");
+            print_error("Add page: first page not found");
         }
         while (true) {
             if ($apageid) {
index baf5aa0b6ad01d49d12fc14fbb98203cecdaca1b..fc8025ea24785ea87a296f4e09c101eb9f5ddc17 100644 (file)
     
     if ($pageid == 0) {
         if (!$page = get_record("lesson_pages", "prevpageid", 0, "lessonid", $lesson->id)) {
-            error("Error: Add cluster: page record not found");
+            print_error("Error: Add cluster: page record not found");
         }
     } else {
         if (!$page = get_record("lesson_pages", "id", $pageid)) {
-            error("Error: Add cluster: page record not found");
+            print_error("Error: Add cluster: page record not found");
         }
     }
     $newpage = new stdClass;
     $newpage->title = get_string("clustertitle", "lesson");
     $newpage->contents = get_string("clustertitle", "lesson");
     if (!$newpageid = insert_record("lesson_pages", $newpage)) {
-        error("Insert page: new page not inserted");
+        print_error("Insert page: new page not inserted");
     }
     // update the linked list...
     if ($pageid != 0) {
         if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) {
-            error("Add cluster: unable to update link");
+            print_error("Add cluster: unable to update link");
         }
     }
     
@@ -51,7 +51,7 @@
     if ($page->nextpageid) {
         // the new page is not the last page
         if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) {
-            error("Insert page: unable to update previous link");
+            print_error("Insert page: unable to update previous link");
         }
     }
     // ..and the single "answer"
@@ -61,7 +61,7 @@
     $newanswer->timecreated = $timenow;
     $newanswer->jumpto = LESSON_CLUSTERJUMP;
     if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
-        error("Add cluster: answer record not inserted");
+        print_error("Add cluster: answer record not inserted");
     }
     lesson_set_message(get_string('addedcluster', 'lesson'), 'notifysuccess');
     redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
index 5decb9f2f9fe58d1d6a3f4b6104e46316aeabe25..83c025017274be78cf3f57a67c89f87c111be42d 100644 (file)
 
     // the new page is not the first page (end of branch always comes after an existing page)
     if (!$page = get_record("lesson_pages", "id", $pageid)) {
-        error("Add end of branch: page record not found");
+        print_error("Add end of branch: page record not found");
     }
     // chain back up to find the (nearest branch table)
     $btpageid = $pageid;
     if (!$btpage = get_record("lesson_pages", "id", $btpageid)) {
-        error("Add end of branch: btpage record not found");
+        print_error("Add end of branch: btpage record not found");
     }
     while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) {
         $btpageid = $btpage->prevpageid;
         if (!$btpage = get_record("lesson_pages", "id", $btpageid)) {
-            error("Add end of branch: btpage record not found");
+            print_error("Add end of branch: btpage record not found");
         }
     }
     if ($btpage->qtype == LESSON_BRANCHTABLE) {
         $newpage->title = get_string("endofbranch", "lesson");
         $newpage->contents = get_string("endofbranch", "lesson");
         if (!$newpageid = insert_record("lesson_pages", $newpage)) {
-            error("Insert page: new page not inserted");
+            print_error("Insert page: new page not inserted");
         }
         // update the linked list...
         if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) {
-            error("Add end of branch: unable to update link");
+            print_error("Add end of branch: unable to update link");
         }
         if ($page->nextpageid) {
             // the new page is not the last page
             if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) {
-                error("Insert page: unable to update previous link");
+                print_error("Insert page: unable to update previous link");
             }
         }
         // ..and the single "answer"
@@ -57,7 +57,7 @@
         $newanswer->timecreated = $timenow;
         $newanswer->jumpto = $btpageid;
         if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
-            error("Add end of branch: answer record not inserted");
+            print_error("Add end of branch: answer record not inserted");
         }
         
         lesson_set_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess');
index be1d261d9ff6dd9b7728f7c47865c1c18c2eb8db..23a085259b9a3e0048a2604da3622706a1b94b81 100644 (file)
@@ -15,7 +15,7 @@
     
     // the new page is not the first page (end of cluster always comes after an existing page)
     if (!$page = get_record("lesson_pages", "id", $pageid)) {
-        error("Error: Could not find page");
+        print_error("Error: Could not find page");
     }
     
     // could put code in here to check if the user really can insert an end of cluster
     $newpage->title = get_string("endofclustertitle", "lesson");
     $newpage->contents = get_string("endofclustertitle", "lesson");
     if (!$newpageid = insert_record("lesson_pages", $newpage)) {
-        error("Insert page: end of cluster page not inserted");
+        print_error("Insert page: end of cluster page not inserted");
     }
     // update the linked list...
     if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) {
-        error("Add end of cluster: unable to update link");
+        print_error("Add end of cluster: unable to update link");
     }
     if ($page->nextpageid) {
         // the new page is not the last page
         if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) {
-            error("Insert end of cluster: unable to update previous link");
+            print_error("Insert end of cluster: unable to update previous link");
         }
     }
     // ..and the single "answer"
@@ -48,7 +48,7 @@
     $newanswer->timecreated = $timenow;
     $newanswer->jumpto = LESSON_NEXTPAGE;
     if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
-        error("Add end of cluster: answer record not inserted");
+        print_error("Add end of cluster: answer record not inserted");
     }
     lesson_set_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess');
     redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
\ No newline at end of file
index 586312a6326c01c48d460aa688140837a4be6a24..580d44bd928b45933849093654c41d5b7f36b3ac 100644 (file)
@@ -10,7 +10,7 @@
 
     $pageid = required_param('pageid', PARAM_INT);
     if (!$thispage = get_record("lesson_pages", "id", $pageid)) {
-        error("Confirm delete: the page record not found");
+        print_error("Confirm delete: the page record not found");
     }
     print_heading(get_string("deletingpage", "lesson", format_string($thispage->title)));
     // print the jumps to this page
@@ -19,7 +19,7 @@
         echo "<p align=\"center\">\n";
         foreach ($answers as $answer) {
             if (!$title = get_field("lesson_pages", "title", "id", $answer->pageid)) {
-                error("Confirm delete: page title not found");
+                print_error("Confirm delete: page title not found");
             }
             echo $title."<br />\n";
         }
index e23fc86d3694746d7781d85e760a2ca38f01f1c8..e0c13f34be45bcb8998f2cc4315980714c3e568c 100644 (file)
@@ -22,7 +22,7 @@
     $timer = new stdClass;
     if (!has_capability('mod/lesson:manage', $context)) {
         if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
-            error('Error: could not find records');
+            print_error('Error: could not find records');
         } else {
             $timer = array_pop($timer); // this will get the latest start time record
         }
         
         $timer->lessontime = time();
         if (!update_record("lesson_timer", $timer)) {
-            error("Error: could not update lesson_timer table");
+            print_error("Error: could not update lesson_timer table");
         }
     }
 
     // record answer (if necessary) and show response (if none say if answer is correct or not)
     $pageid = required_param('pageid', PARAM_INT);
     if (!$page = get_record("lesson_pages", "id", $pageid)) {
-        error("Continue: Page record not found");
+        print_error("Continue: Page record not found");
     }
     // set up some defaults
     $answerid        = 0;
@@ -69,7 +69,7 @@
             $useranswer = clean_param($useranswer, PARAM_RAW);
         
             if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
-                error("Continue: No answers found");
+                print_error("Continue: No answers found");
             }
             $correctanswer = false;
             foreach ($answers as $answer) {
@@ -94,7 +94,7 @@
             $useranswer = stripslashes(clean_param($useranswer, PARAM_RAW));
             $userresponse = addslashes($useranswer);
             if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
-                error("Continue: No answers found");
+                print_error("Continue: No answers found");
             }
             $i=0;
             foreach ($answers as $answer) {
             }
             $answerid = required_param('answerid', PARAM_INT); 
             if (!$answer = get_record("lesson_answers", "id", $answerid)) {
-                error("Continue: answer record not found");
+                print_error("Continue: answer record not found");
             } 
             if (lesson_iscorrect($pageid, $answer->jumpto)) {
                 $correctanswer = true;
                 $userresponse = implode(",", $useranswers);
                 // get the answers in a set order, the id order
                 if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
-                    error("Continue: No answers found");
+                    print_error("Continue: No answers found");
                 }
                 $ncorrect = 0;
                 $nhits = 0;
                 }
                 $answerid = required_param('answerid', PARAM_INT); 
                 if (!$answer = get_record("lesson_answers", "id", $answerid)) {
-                    error("Continue: answer record not found");
+                    print_error("Continue: answer record not found");
                 }
                 if (lesson_iscorrect($pageid, $answer->jumpto)) {
                     $correctanswer = true;
             }
 
             if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
-                error("Continue: No answers found");
+                print_error("Continue: No answers found");
             }
 
             $ncorrect = 0;
             }
             $studentanswer = $userresponse = $useranswer;
             if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
-                error("Continue: No answers found");
+                print_error("Continue: No answers found");
             }
             foreach ($answers as $answer) {
                 if (strpos($answer->answer, ':')) {
             $branch->timeseen = time();
         
             if (!insert_record("lesson_branch", $branch)) {
-                error("Error: could not insert row into lesson_branch table");
+                print_error("Error: could not insert row into lesson_branch table");
             }
 
             //  this is called when jumping to random from a branch table
                 $attempt->retry = $nretakes - 1; // they are going through on review, $nretakes will be too high
             }
             if (!$newattemptid = insert_record("lesson_attempts", $attempt)) {
-                error("Continue: attempt not inserted");
+                print_error("Continue: attempt not inserted");
             }
             // "number of attempts remaining" message if $lesson->maxattempts > 1
             // displaying of message(s) is at the end of page for more ergonomic display
         }
     } elseif ($newpageid != LESSON_CLUSTERJUMP && $pageid != 0 && $newpageid > 0) {  // going to check to see if the page that the user is going to view next, is a cluster page.  If so, dont display, go into the cluster.  The $newpageid > 0 is used to filter out all of the negative code jumps.
         if (!$page = get_record("lesson_pages", "id", $newpageid)) {
-            error("Error: could not find page");
+            print_error("Error: could not find page");
         }
         if ($page->qtype == LESSON_CLUSTER) {
             $newpageid = lesson_cluster_jump($lesson->id, $USER->id, $page->id);
index 48aa1a84371e6be591bf75ffe01ab0f3758a0f25..b747b50477d6115222eeb1f36decfb734d6e8c39 100644 (file)
@@ -10,7 +10,7 @@
 
     $pageid = required_param('pageid', PARAM_INT);
     if (!$thispage = get_record("lesson_pages", "id", $pageid)) {
-        error("Delete: page record not found");
+        print_error("Delete: page record not found");
     }
 
     // first delete all the associated records...
     if (!$thispage->prevpageid) {
         // this is the first page...
         if (!$page = get_record("lesson_pages", "id", $thispage->nextpageid)) {
-            error("Delete: next page not found");
+            print_error("Delete: next page not found");
         }
         if (!set_field("lesson_pages", "prevpageid", 0, "id", $page->id)) {
-            error("Delete: unable to set prevpage link");
+            print_error("Delete: unable to set prevpage link");
         }
     } elseif (!$thispage->nextpageid) {
         // this is the last page...
         if (!$page = get_record("lesson_pages", "id", $thispage->prevpageid)) {
-            error("Delete: prev page not found");
+            print_error("Delete: prev page not found");
         }
         if (!set_field("lesson_pages", "nextpageid", 0, "id", $page->id)) {
-            error("Delete: unable to set nextpage link");
+            print_error("Delete: unable to set nextpage link");
         }
     } else {
         // page is in the middle...
         if (!$prevpage = get_record("lesson_pages", "id", $thispage->prevpageid)) {
-            error("Delete: prev page not found");
+            print_error("Delete: prev page not found");
         }
         if (!$nextpage = get_record("lesson_pages", "id", $thispage->nextpageid)) {
-            error("Delete: next page not found");
+            print_error("Delete: next page not found");
         }
         if (!set_field("lesson_pages", "nextpageid", $nextpage->id, "id", $prevpage->id)) {
-            error("Delete: unable to set next link");
+            print_error("Delete: unable to set next link");
         }
         if (!set_field("lesson_pages", "prevpageid", $prevpage->id, "id", $nextpage->id)) {
-            error("Delete: unable to set prev link");
+            print_error("Delete: unable to set prev link");
         }
     }
     lesson_set_message(get_string('deletedpage', 'lesson').': '.format_string($thispage->title, true), 'notifysuccess');
index dbf47605934ab50cef071d8d72007b2322b22f34..aee538b99b6e849e55385ed2f2e632d86788372d 100644 (file)
@@ -12,7 +12,7 @@
     $redirect = optional_param('redirect', '', PARAM_ALPHA);
     
     if (!$page = get_record("lesson_pages", "id", $pageid)) {
-        error("Edit page: page record not found");
+        print_error("Edit page: page record not found");
     }
 
     $page->qtype = optional_param('qtype', $page->qtype, PARAM_INT);
     }
     $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
     if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
-        error("Edit page: first page not found");
+        print_error("Edit page: first page not found");
     }
     while (true) {
         if ($apageid) {
             if (!$apage = get_record("lesson_pages", "id", $apageid)) {
-                error("Edit page: apage record not found");
+                print_error("Edit page: apage record not found");
             }
             // removed != LESSON_ENDOFBRANCH...
             if (trim($page->title)) { // ...nor nuffin pages
index e4217dd73e0cb039f14c366ee8ba51a6822d8e00..aeda9b80c860f92b794464f08e0375e4551b6a3b 100644 (file)
@@ -21,7 +21,7 @@
     if ($form->pageid) {
         // the new page is not the first page
         if (!$page = get_record("lesson_pages", "id", $form->pageid)) {
-            error("Insert page: page record not found");
+            print_error("Insert page: page record not found");
         }
         $newpage->lessonid = clean_param($lesson->id, PARAM_INT);
         $newpage->prevpageid = clean_param($form->pageid, PARAM_INT);
         $newpage->title = addslashes($newpage->title);
         $newpageid = insert_record("lesson_pages", $newpage);
         if (!$newpageid) {
-            error("Insert page: new page not inserted");
+            print_error("Insert page: new page not inserted");
         }
         // update the linked list (point the previous page to this new one)
         if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $newpage->prevpageid)) {
-            error("Insert page: unable to update next link");
+            print_error("Insert page: unable to update next link");
         }
         if ($page->nextpageid) {
             // new page is not the last page
             if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) {
-                error("Insert page: unable to update previous link");
+                print_error("Insert page: unable to update previous link");
             }
         }
     } else {
@@ -90,7 +90,7 @@
             $newpage->title = addslashes($newpage->title);
             $newpageid = insert_record("lesson_pages", $newpage);
             if (!$newpageid) {
-                error("Insert page: new first page not inserted");
+                print_error("Insert page: new first page not inserted");
             }
         } else {
             // there are existing pages put this at the start
             $newpage->title = addslashes($newpage->title);
             $newpageid = insert_record("lesson_pages", $newpage);
             if (!$newpageid) {
-                error("Insert page: first page not inserted");
+                print_error("Insert page: first page not inserted");
             }
             // update the linked list
             if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $newpage->nextpageid)) {
-                error("Insert page: unable to update link");
+                print_error("Insert page: unable to update link");
             }
         }
     }
         }
         $newanswerid = insert_record("lesson_answers", $newanswer);
         if (!$newanswerid) {
-            error("Insert Page: answer record not inserted");
+            print_error("Insert Page: answer record not inserted");
         }
     } else {
         if ($form->qtype == LESSON_MATCHING) {
                 }
                 $newanswerid = insert_record("lesson_answers", $newanswer);
                 if (!$newanswerid) {
-                    error("Insert Page: answer record $i not inserted");
+                    print_error("Insert Page: answer record $i not inserted");
                 }
             } else {
                 if ($form->qtype == LESSON_MATCHING) {
                         $newanswer->timecreated = $timenow;
                         $newanswerid = insert_record("lesson_answers", $newanswer);
                         if (!$newanswerid) {
-                            error("Insert Page: answer record $i not inserted");
+                            print_error("Insert Page: answer record $i not inserted");
                         }
                     }
                 } else {
index fb296e753027d672fa491fe9d423a73e77284218..0eca9f1c506b4b6d4d3218f092a7b67ec933edd5 100644 (file)
@@ -12,7 +12,7 @@
     print_heading(get_string("moving", "lesson", format_string($title)));
    
     if (!$page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) {
-        error("Move: first page not found");
+        print_error("Move: first page not found");
     }
 
     echo "<center><table cellpadding=\"5\" border=\"1\">\n";
@@ -29,7 +29,7 @@
         }
         if ($page->nextpageid) {
             if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) {
-                error("Teacher view: Next page not found!");
+                print_error("Teacher view: Next page not found!");
             }
         } else {
             // last page reached
index 2e2d0959165017843f6409a3862d0cb47cc952e8..08172e0707c563ab1b38a9f0a8e4ed54ae9fbf67 100644 (file)
@@ -10,7 +10,7 @@
 
     $pageid = required_param('pageid', PARAM_INT); //  page to move
     if (!$page = get_record("lesson_pages", "id", $pageid)) {
-        error("Moveit: page not found");
+        print_error("Moveit: page not found");
     }
     $after = required_param('after', PARAM_INT); // target page
 
@@ -23,7 +23,7 @@
         // (when the pages are in a ring this will in effect be the first page)
         if ($page->nextpageid) {
             if (!$after = get_field("lesson_pages", "id", "lessonid", $lesson->id, "nextpageid", 0)) {
-                error("Moveit: last page id not found");
+                print_error("Moveit: last page id not found");
             }
         } else {
             // the page being moved is the last page, so the new last page will be
     } else {
         // the current first page remains the first page
         if (!$newfirstpageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
-            error("Moveit: current first page id not found");
+            print_error("Moveit: current first page id not found");
         }
     }
     // the rest is all unconditional...
     
     // second step. join pages into a ring 
     if (!$firstpageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
-        error("Moveit: firstpageid not found");
+        print_error("Moveit: firstpageid not found");
     }
     if (!$lastpageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "nextpageid", 0)) {
-        error("Moveit: lastpage not found");
+        print_error("Moveit: lastpage not found");
     }
     if (!set_field("lesson_pages", "prevpageid", $lastpageid, "id", $firstpageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     if (!set_field("lesson_pages", "nextpageid", $firstpageid, "id", $lastpageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
 
     // third step. remove the page to be moved
     if (!$prevpageid = get_field("lesson_pages", "prevpageid", "id", $pageid)) {
-        error("Moveit: prevpageid not found");
+        print_error("Moveit: prevpageid not found");
     }
     if (!$nextpageid = get_field("lesson_pages", "nextpageid", "id", $pageid)) {
-        error("Moveit: nextpageid not found");
+        print_error("Moveit: nextpageid not found");
     }
     if (!set_field("lesson_pages", "nextpageid", $nextpageid, "id", $prevpageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     if (!set_field("lesson_pages", "prevpageid", $prevpageid, "id", $nextpageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     
     // fourth step. insert page to be moved in new place...
     if (!$nextpageid = get_field("lesson_pages", "nextpageid", "id", $after)) {
-        error("Movit: nextpageid not found");
+        print_error("Movit: nextpageid not found");
     }
     if (!set_field("lesson_pages", "nextpageid", $pageid, "id", $after)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     if (!set_field("lesson_pages", "prevpageid", $pageid, "id", $nextpageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     // ...and set the links in the moved page
     if (!set_field("lesson_pages", "prevpageid", $after, "id", $pageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     if (!set_field("lesson_pages", "nextpageid", $nextpageid, "id", $pageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     
     // fifth step. break the ring
     if (!$newlastpageid = get_field("lesson_pages", "prevpageid", "id", $newfirstpageid)) {
-        error("Moveit: newlastpageid not found");
+        print_error("Moveit: newlastpageid not found");
     }
     if (!set_field("lesson_pages", "prevpageid", 0, "id", $newfirstpageid)) {
-        error("Moveit: unable to update link");
+        print_error("Moveit: unable to update link");
     }
     if (!set_field("lesson_pages", "nextpageid", 0, "id", $newlastpageid)) {
-            error("Moveit: unable to update link");
+            print_error("Moveit: unable to update link");
     }
     lesson_set_message(get_string('movedpage', 'lesson'), 'notifysuccess');
     redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
index d54e179f62162d55b50018f6837ec27b6777dbe7..7b978ccfbd7606552b7c16af3fb436f6ab3deaf2 100644 (file)
@@ -48,7 +48,7 @@
     $page->title = addslashes($page->title);
     
     if (!update_record("lesson_pages", $page)) {
-        error("Update page: page not updated");
+        print_error("Update page: page not updated");
     }
     if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_ESSAY || $page->qtype == LESSON_CLUSTER || $page->qtype == LESSON_ENDOFCLUSTER) {
         // there's just a single answer with a jump
             foreach ($answers as $answer) {
                 if ($answer->id != clean_param($form->answerid[0], PARAM_INT)) {
                     if (!delete_records("lesson_answers", "id", $answer->id)) {
-                        error("Update page: unable to delete answer record");
+                        print_error("Update page: unable to delete answer record");
                     }
                 }
             }
         }        
         if (!update_record("lesson_answers", $oldanswer)) {
-            error("Update page: EOB not updated");
+            print_error("Update page: EOB not updated");
         }
     } else {
         // it's an "ordinary" page
                         $oldanswer->score = clean_param($form->score[$i], PARAM_INT);
                     }
                     if (!update_record("lesson_answers", $oldanswer)) {
-                        error("Update page: answer $i not updated");
+                        print_error("Update page: answer $i not updated");
                     }
                 } else {
                     // it's a new answer
                     }
                     $newanswerid = insert_record("lesson_answers", $newanswer);
                     if (!$newanswerid) {
-                        error("Update page: answer record not inserted");
+                        print_error("Update page: answer record not inserted");
                     }
                 }
             } else {
                         if ($form->answerid[$i]) {
                             // need to delete blanked out answer
                             if (!delete_records("lesson_answers", "id", clean_param($form->answerid[$i], PARAM_INT))) {
-                                error("Update page: unable to delete answer record");
+                                print_error("Update page: unable to delete answer record");
                             }
                         }
                     } else {
                         $oldanswer->timemodified = $timenow;
                         $oldanswer->answer = NULL;
                         if (!update_record("lesson_answers", $oldanswer)) {
-                            error("Update page: answer $i not updated");
+                            print_error("Update page: answer $i not updated");
                         }
                     }                        
                 } elseif (!empty($form->answerid[$i])) {
                     // need to delete blanked out answer
                     if (!delete_records("lesson_answers", "id", clean_param($form->answerid[$i], PARAM_INT))) {
-                        error("Update page: unable to delete answer record");
+                        print_error("Update page: unable to delete answer record");
                     }
                 }
             }
index a7259d840f94436832ab74b7a6a472987ad003af..451f9e46662d85a4a7207a2b8fd8f3f23f0d8f40 100644 (file)
                 // move to the next (logical) page
                 if ($page->nextpageid) {
                     if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) {
-                        error("Lesson Backup: Next page not found!");
+                        print_error("Lesson Backup: Next page not found!");
                     }
                 } else {
                     // last page reached
index a267e1b7ed4f769a0e8232b5bd5cec691074e05a..e92507ea71048568cdc95f6bc66df1510ff1c5dc 100644 (file)
     
     if ($firstpage = get_record('lesson_pages', 'lessonid', $lesson->id, 'prevpageid', 0)) {
         if (!$pages = get_records('lesson_pages', 'lessonid', $lesson->id)) {
-            error('Could not find lesson pages');
+            print_error('Could not find lesson pages');
         }
     }
     
     if ($pageid) {
         if (!$singlepage = get_record('lesson_pages', 'id', $pageid)) {
-            error('Could not find page ID: '.$pageid);
+            print_error('Could not find page ID: '.$pageid);
         }
     }
 
index bdccd0653fc219a1ec699ceb638d18c62d807692..2bda00e150c3ac92301283b37566ac0530f47743 100644 (file)
             $attemptid = required_param('attemptid', PARAM_INT);
 
             if (!$attempt = get_record('lesson_attempts', 'id', $attemptid)) {
-                error('Error: could not find attempt');
+                print_error('Error: could not find attempt');
             }
             if (!$page = get_record('lesson_pages', 'id', $attempt->pageid)) {
-                error('Error: could not find lesson page');
+                print_error('Error: could not find lesson page');
             }
             if (!$user = get_record('user', 'id', $attempt->userid)) {
-                error('Error: could not find users');
+                print_error('Error: could not find users');
             }
             if (!$answer = get_record('lesson_answers', 'lessonid', $lesson->id, 'pageid', $page->id)) {
-                error('Error: could not find answer');
+                print_error('Error: could not find answer');
             }
             break;
         case 'update':
                 $attemptid = required_param('attemptid', PARAM_INT);
                 
                 if (!$attempt = get_record('lesson_attempts', 'id', $attemptid)) {
-                    error('Error: could not find essay');
+                    print_error('Error: could not find essay');
                 }
                 if (!$grades = get_records_select('lesson_grades', "lessonid = $lesson->id and userid = $attempt->userid", 'completed', '*', $attempt->retry, 1)) {
-                    error('Error: could not find grades');
+                    print_error('Error: could not find grades');
                 }
 
                 $essayinfo = new stdClass;
                 $attempt->useranswer = addslashes(serialize($essayinfo));
 
                 if (!update_record('lesson_attempts', $attempt)) {
-                    error('Could not update essay score');
+                    print_error('Could not update essay score');
                 }
                 
                 // Get grade information
 
                 redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id");
             } else {
-                error('Something is wrong with the form data');
+                print_error('Something is wrong with the form data');
             }
             break;
         case 'email': // Sending an email(s) to a single user or all
             if ($userid = optional_param('userid', 0, PARAM_INT)) {
                 $queryadd = " AND userid = $userid";
                 if (! $users = get_records('user', 'id', $userid)) {
-                    error('Error: could not find users');
+                    print_error('Error: could not find users');
                 }
             } else {
                 $queryadd = '';
                                          WHERE a.lessonid = '$lesson->id' and
                                                u.id = a.userid
                                          ORDER BY u.lastname")) {
-                    error('Error: could not find users');
+                    print_error('Error: could not find users');
                 }
             }
 
             // Get lesson pages that are essay
             if (!$pages = get_records_select('lesson_pages', "lessonid = $lesson->id AND qtype = ".LESSON_ESSAY)) {
-                error('Error: could not find lesson pages');
+                print_error('Error: could not find lesson pages');
             }
 
             // Get only the attempts that are in response to essay questions
                         // Log it
                         add_to_log($course->id, 'lesson', 'update email essay grade', "essay.php?id=$cm->id", format_string($pages[$attempt->pageid]->title,true).': '.fullname($users[$attempt->userid]), $cm->id);
                     } else {
-                        error('Emailing Failed');
+                        print_error('Emailing Failed');
                     }
                 }
             }
index c547c7b01f8503c8781aa63bb78b4d219ddb7ab2..7fbf98c6c46fe5f1b2c485fe5a7e4e86d9f1afcd 100644 (file)
@@ -92,11 +92,11 @@ class qformat_default {
                         $newpage->nextpageid = $page->nextpageid;
                         // insert the page and reset $pageid
                         if (!$newpageid = insert_record("lesson_pages", $newpage)) {
-                            error("Format: Could not insert new page!");
+                            print_error("Format: Could not insert new page!");
                         }
                         // update the linked list
                         if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) {
-                            error("Format: unable to update link");
+                            print_error("Format: unable to update link");
                         }
 
                     } else {
@@ -108,7 +108,7 @@ class qformat_default {
                             $newpage->nextpageid = 0; // this is the only page
                             $newpageid = insert_record("lesson_pages", $newpage);
                             if (!$newpageid) {
-                                error("Insert page: new first page not inserted");
+                                print_error("Insert page: new first page not inserted");
                             }
                         } else {
                             // there are existing pages put this at the start
@@ -116,11 +116,11 @@ class qformat_default {
                             $newpage->nextpageid = $page->id;
                             $newpageid = insert_record("lesson_pages", $newpage);
                             if (!$newpageid) {
-                                error("Insert page: first page not inserted");
+                                print_error("Insert page: first page not inserted");
                             }
                             // update the linked list
                             if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->id)) {
-                                error("Insert page: unable to update link");
+                                print_error("Insert page: unable to update link");
                             }
                         }
                     }
index 66d2c197e10fbc00eae4e0fbe3cbc2e82e2cf0ae..740730e3718058f91651104cc7241b26ced0b2d9 100644 (file)
@@ -5,15 +5,15 @@
     $id   = required_param('id', PARAM_INT);          // Course module ID
 
     if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $lesson = get_record("lesson", "id", $cm->instance)) {
-        error("lesson ID was incorrect");
+        print_error("lesson ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $lesson->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
index 858f5eb7a3c0ef8410939aab524da730ccd6331d..b411a5dec4e3843a18337142e5b5fff70950ccc3 100644 (file)
@@ -26,7 +26,7 @@
         case 'add':
             // Ensure that we came from view.php
             if (!confirm_sesskey() or !data_submitted("$CFG->wwwroot/mod/lesson/view.php")) {
-                error('Incorrect Form Data');
+                print_error('Incorrect Form Data');
             }
             break;
             
                 }
                 
                 if (!$grades = get_records_select('lesson_grades', "lessonid = $lesson->id", 'completed')) {
-                    error('Error: could not find grades');
+                    print_error('Error: could not find grades');
                 }
                 if (!$newgrade = get_record_sql("SELECT * 
                                                    FROM {$CFG->prefix}lesson_grades 
                                                   WHERE lessonid = $lesson->id
                                                     AND userid = $USER->id 
                                                ORDER BY completed DESC", true)) {
-                    error('Error: could not find newest grade');
+                    print_error('Error: could not find newest grade');
                 }
                 
                 // Check for multiple submissions
                 if (record_exists('lesson_high_scores', 'gradeid', $newgrade->id)) {
-                    error('Only one posting per grade');
+                    print_error('Only one posting per grade');
                 }
                 
                 // Find out if we need to delete any records
                 $newhighscore->nickname = $name;
 
                 if (!insert_record('lesson_high_scores', $newhighscore)) {
-                    error("Insert of new high score Failed!");
+                    print_error("Insert of new high score Failed!");
                 }
                 
                 // Log it
                 lesson_set_message(get_string('postsuccess', 'lesson'), 'notifysuccess');
                 redirect("$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id&amp;link=1");
             } else {
-                error('Something is wrong with the form data');
+                print_error('Something is wrong with the form data');
             }
             break;
     }
index 8e41a64c38ab3b7d461bfc4c902fc0f1c26a70b5..809e09a2a52245672992b66546ac8d672f3c4551 100644 (file)
     $pageid = optional_param('pageid', '', PARAM_INT); // Page ID
 
     if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     if (! $lesson = get_record("lesson", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
 
@@ -52,7 +52,7 @@
         } else {  // Valid file is found
 
             if (! is_readable("$CFG->dirroot/question/format/$form->format/format.php")) {
-                error("Format not known ($form->format)");
+                print_error("Format not known ($form->format)");
             }
 
             require("format.php");  // Parent class
             $format = new $classname();
 
             if (! $format->importpreprocess()) {             // Do anything before that we need to
-                error("Error occurred during pre-processing!");
+                print_error("Error occurred during pre-processing!");
             }
 
             if (! $format->importprocess($_FILES['newfile']['tmp_name'], $lesson, $pageid)) {    // Process the uploaded file
-                error("Error occurred during processing!");
+                print_error("Error occurred during processing!");
             }
 
             if (! $format->importpostprocess()) {                     // In case anything needs to be done after
-                error("Error occurred during post-processing!");
+                print_error("Error occurred during post-processing!");
             }
 
             echo "<hr>";
index a407515be3ba8c6900d91cba593667ea877c3d3e..2d61a9daf4e437294e73a115da6924e94f20b368 100644 (file)
     global $matches;
     
     if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     
     // allows for adaption for multiple modules
     if(! $modname = get_field('modules', 'name', 'id', $cm->module)) {
-        error("Could not find module name");
+        print_error("Could not find module name");
     }
 
     if (! $mod = get_record($modname, "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
                 $objects = $mod_create_objects($pageobjects, $mod->id);  // function to preps the data to be sent to DB
                 
                 if(! $mod_save_objects($objects, $mod->id, $pageid)) {  // sends it to DB
-                    error("could not save");
+                    print_error("could not save");
                 }
             } else {
-                error('could not get data');
+                print_error('could not get data');
             }
 
             echo "<hr>";
@@ -324,7 +324,7 @@ function build_list($list, &$i, $depth) {
                 // set the depth number.  So B1 is depth 1 and B2 is depth 2 and so on
                 $this_depth = substr($class, 1);
                 if (!is_numeric($this_depth)) {
-                    error("Depth not parsed!");
+                    print_error("Depth not parsed!");
                 }
             }
             if ($this_depth < $depth) {
@@ -544,13 +544,13 @@ function lesson_save_objects($branchtables, $lessonid, $after) {
         
         // insert the page
         if(!$id = insert_record('lesson_pages', $branchtable->page)) {
-            error("insert page");
+            print_error("insert page");
         }
     
         // update the link of the page previous to the one we just updated
         if ($prevpageid != 0) {  // if not the first page
             if (!set_field("lesson_pages", "nextpageid", $id, "id", $prevpageid)) {
-                error("Insert page: unable to update next link $prevpageid");
+                print_error("Insert page: unable to update next link $prevpageid");
             }
         }
 
@@ -558,7 +558,7 @@ function lesson_save_objects($branchtables, $lessonid, $after) {
         foreach ($branchtable->answers as $answer) {
             $answer->pageid = $id;
             if(!insert_record('lesson_answers', $answer)) {
-                error("insert answer $id");
+                print_error("insert answer $id");
             }
         }
         
@@ -568,7 +568,7 @@ function lesson_save_objects($branchtables, $lessonid, $after) {
     // all done with inserts.  Now check to update our last page (this is when we import between two lesson pages)
     if ($nextpageid != 0) {  // if the next page is not the end of lesson
         if (!set_field("lesson_pages", "prevpageid", $id, "id", $nextpageid)) {
-            error("Insert page: unable to update next link $prevpageid");
+            print_error("Insert page: unable to update next link $prevpageid");
         }
     }
     
@@ -582,7 +582,7 @@ function book_save_objects($chapters, $bookid, $pageid='0') {
     // nothing fancy, just save them all in order
     foreach ($chapters as $chapter) {
         if (!$chapter->id = insert_record('book_chapters', $chapter)) {
-            error('Could not update your book');
+            print_error('Could not update your book');
         }
     }
     return true;
index ea33f44ebca7b86f1d9dad0a5e76054b104e458b..4433fc6d92799e230ed8498afe4044bd8ab1c545 100644 (file)
@@ -14,7 +14,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (!$course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_login($course->id);
index 902bae5b2096da6da63b16212483bed9df31eda0..f4c0e194423d539cbfbd1592dd96179f36bf73b6 100644 (file)
@@ -55,7 +55,7 @@
             include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php');
             break;
         default:
-            error("Fatal Error: Unknown action\n");
+            print_error("Fatal Error: Unknown action\n");
     }
 
     print_footer($course);
index b6ab81fe8aa818f37ccf27ee08be17d669013b2c..a25a4d03a230b47d3bf3f7c7cd1eb0e99bb485ab 100644 (file)
@@ -270,26 +270,26 @@ function lesson_print_header($cm, $course, $lesson, $currenttab = '') {
 function lesson_get_basics($cmid = 0, $lessonid = 0) {
     if ($cmid) {
         if (!$cm = get_coursemodule_from_id('lesson', $cmid)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (!$course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (!$lesson = get_record('lesson', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
     } else if ($lessonid) {
         if (!$lesson = get_record('lesson', 'id', $lessonid)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
         if (!$course = get_record('course', 'id', $lesson->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (!$cm = get_coursemodule_from_instance('lesson', $lesson->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     } else {
-        error('No course module ID or lesson ID were passed');
+        print_error('No course module ID or lesson ID were passed');
     }
     
     return array($cm, $course, $lesson);
@@ -1064,7 +1064,7 @@ function lesson_cluster_jump($lessonid, $userid, $pageid) {
 
     // get the lesson pages
     if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lessonid")) {
-        error("Error: could not find records in lesson_pages table");
+        print_error("Error: could not find records in lesson_pages table");
     }
     // find the start of the cluster
     while ($pageid != 0) { // this condition should not be satisfied... should be a cluster page
@@ -1192,7 +1192,7 @@ function lesson_unseen_question_jump($lesson, $user, $pageid) {
 
     // get the lesson pages
     if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lesson")) {
-        error("Error: could not find records in lesson_pages table");
+        print_error("Error: could not find records in lesson_pages table");
     }
     
     if ($pageid == LESSON_UNSEENBRANCHPAGE) {  // this only happens when a student leaves in the middle of an unseen question within a branch series
@@ -1249,12 +1249,12 @@ function lesson_unseen_branch_jump($lessonid, $userid) {
 
     if (!$seenbranches = get_records_select("lesson_branch", "lessonid = $lessonid AND userid = $userid AND retry = $retakes",
                 "timeseen DESC")) {
-        error("Error: could not find records in lesson_branch table");
+        print_error("Error: could not find records in lesson_branch table");
     }
 
     // get the lesson pages
     if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lessonid")) {
-        error("Error: could not find records in lesson_pages table");
+        print_error("Error: could not find records in lesson_pages table");
     }
     
     // this loads all the viewed branch tables into $seen untill it finds the branch table with the flag
@@ -1301,7 +1301,7 @@ function lesson_unseen_branch_jump($lessonid, $userid) {
 function lesson_random_question_jump($lessonid, $pageid) {
     // get the lesson pages
     if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lessonid")) {
-        error("Error: could not find records in lesson_pages table");
+        print_error("Error: could not find records in lesson_pages table");
     }
 
     // go up the pages till branch table
index fc52550fb256b30918a098d9caef83f8d1085e79..2839c1713aa66bfb9cafe5694dbe7d8d423ac283 100644 (file)
     $printclose = optional_param('printclose', 0, PARAM_INT);
     
     if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     if (! $course = get_record('course', 'id', $cm->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     if (! $lesson = get_record('lesson', 'id', $cm->instance)) {
-        error('Course module is incorrect');
+        print_error('Course module is incorrect');
     }
 
     require_login($course->id, false, $cm);
     
     //} else if ($mimetype == "application/x-shockwave-flash") {   // It's a flash file
     
-    //    error('Flash is not supported yet');
+    //    print_error('Flash is not supported yet');
     
     } else if ($mimetype == "audio/x-pn-realaudio") {   // It's a realmedia file
         
index 868366fb9f5e27f744a36cd5a0311b9d2c732772..c1291bd111b30e96e6e72b85e98f3a5aa717f16f 100644 (file)
@@ -70,7 +70,7 @@ class page_lesson extends page_generic_activity {
         $activityname = format_string($this->activityrecord->name);
 
         if ($this->lessonpageid === NULL) {
-            error('Programmer error: must set the lesson page ID');
+            print_error('Programmer error: must set the lesson page ID');
         }
         if (empty($title)) {
             $title = "{$this->courserecord->shortname}: $activityname";
index a0f0803cfbf17cf3f7c01d22243d81319e9f60df..15cf1c821983b716dfa61ded4ca5c536dc15d99a 100644 (file)
         $try    = optional_param('try', NULL, PARAM_INT);
 
         if (! $lessonpages = get_records("lesson_pages", "lessonid", $lesson->id)) {
-            error("Could not find Lesson Pages");
+            print_error("Could not find Lesson Pages");
         }
         if (! $pageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
-            error("Could not find first page");
+            print_error("Could not find first page");
         }
 
         // now gather the stats into an object
     }
 
     else {
-        error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error("Fatal Error: Unknown Action: ".$action."\n");
     }
 
 /// Finish the page
index 38e4363d7f22f3afb228b5e79d98ab63643aad62..9e35c8b5b9fb430d2592ecb7d98afafb6abbd193 100644 (file)
             //Fix the forwards link of the previous page
             if ($prevpageid) {
                 if (!set_field("lesson_pages", "nextpageid", $newid, "id", $prevpageid)) {
-                    error("Lesson restorelib: unable to update link");
+                    print_error("Lesson restorelib: unable to update link");
                 }
             }
             $prevpageid = $newid;
                     $page = backup_getid($restore->backup_unique_code,"lesson_pages",$answer->jumpto);
                     if ($page) {
                         if (!set_field("lesson_answers", "jumpto", $page->new_id, "id", $answer->id)) {
-                            error("Lesson restorelib: unable to reset jump");
+                            print_error("Lesson restorelib: unable to reset jump");
                         }
                     }
                 }
index 3c88a5b0393f7705b7d85643c4a5e0c626b66741..4f27e65d09f05830fde62ce2b8a905c7cda02844 100644 (file)
@@ -12,7 +12,7 @@
 /// This file to be included so we can assume config.php has already been included.
 
     if (empty($lesson)) {
-        error('You cannot call this script in that way');
+        print_error('You cannot call this script in that way');
     }
     if (!isset($currenttab)) {
         $currenttab = '';
index 3243160def9bf97c0b81a0fdf1f366bb07c48cf9..d1f5705f7dbee2a739f5d9304c6a715280db0693 100644 (file)
             // get the first page
             if (!$firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id,
                         'prevpageid', 0)) {
-                error('Navigation: first page not found');
+                print_error('Navigation: first page not found');
             }
             lesson_print_header($cm, $course, $lesson);
             if ($lesson->timed) {
         }
         // start at the first page
         if (!$pageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
-                error('Navigation: first page not found');
+                print_error('Navigation: first page not found');
         }
         /// This is the code for starting a timed test
         if(!isset($USER->startlesson[$lesson->id]) && !has_capability('mod/lesson:manage', $context)) {
             $startlesson->lessontime = time();
             
             if (!insert_record('lesson_timer', $startlesson)) {
-                error('Error: could not insert row into lesson_timer table');
+                print_error('Error: could not insert row into lesson_timer table');
             }
             if ($lesson->timed) {
                 lesson_set_message(get_string('maxtimewarning', 'lesson', $lesson->maxtime), 'center');
                     $retries = 0;
                 }
                 if (!delete_records('lesson_attempts', 'userid', $USER->id, 'lessonid', $lesson->id, 'retry', $retries)) {
-                    error('Error: could not delete old attempts');
+                    print_error('Error: could not delete old attempts');
                 }
                 if (!delete_records('lesson_branch', 'userid', $USER->id, 'lessonid', $lesson->id, 'retry', $retries)) {
-                    error('Error: could not delete old seen branches');
+                    print_error('Error: could not delete old seen branches');
                 }
             }
         }
         add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id);
         
         if (!$page = get_record('lesson_pages', 'id', $pageid)) {
-            error('Navigation: the page record not found');
+            print_error('Navigation: the page record not found');
         }
 
         if ($page->qtype == LESSON_CLUSTER) {  //this only gets called when a user starts up a new lesson and the first page is a cluster page
                 $pageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid);
                 // get new page info
                 if (!$page = get_record('lesson_pages', 'id', $pageid)) {
-                    error('Navigation: the page record not found');
+                    print_error('Navigation: the page record not found');
                 }
                 add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id);
             } else {
                 // get the next page
                 $pageid = $page->nextpageid;
                 if (!$page = get_record('lesson_pages', 'id', $pageid)) {
-                    error('Navigation: the page record not found');
+                    print_error('Navigation: the page record not found');
                 }
             }
         } elseif ($page->qtype == LESSON_ENDOFCLUSTER) { // Check for endofclusters
                     break;
                 } 
             } else {
-                error('Navigation: No answers on EOB');
+                print_error('Navigation: No answers on EOB');
             }
         }
         
         $timer = new stdClass;
         if(!has_capability('mod/lesson:manage', $context)) {
             if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
-                error('Error: could not find records');
+                print_error('Error: could not find records');
             } else {
                 $timer = array_pop($timer); // this will get the latest start time record
             }
         if (!has_capability('mod/lesson:manage', $context)) {
             $timer->lessontime = time();
             if (!update_record('lesson_timer', $timer)) {
-                error('Error: could not update lesson_timer table');
+                print_error('Error: could not update lesson_timer table');
             }
         }
 
             $retries = count_records('lesson_grades', "lessonid", $lesson->id, "userid", $USER->id);
             $retries--;
             if (! $attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND userid = $USER->id AND pageid = $page->id AND retry = $retries", "timeseen")) {
-                error("Previous attempt record could not be found!");
+                print_error("Previous attempt record could not be found!");
             }
             $attempt = end($attempts);
         }
         if (!has_capability('mod/lesson:manage', $context)) {
             unset($USER->startlesson[$lesson->id]);
             if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
-                error('Error: could not find records');
+                print_error('Error: could not find records');
             } else {
                 $timer = array_pop($timer); // this will get the latest start time record
             }
             $timer->lessontime = time();
             
             if (!update_record("lesson_timer", $timer)) {
-                error("Error: could not update lesson_timer table");
+                print_error("Error: could not update lesson_timer table");
             }
         }
         
                 if (!$lesson->practice) {
                     if (isset($USER->modattempts[$lesson->id])) { // if reviewing, make sure update old grade record
                         if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $USER->id", "completed")) {
-                            error("Could not find Grade Records");
+                            print_error("Could not find Grade Records");
                         }
                         $oldgrade = end($grades);
                         $grade->id = $oldgrade->id;
                         if (!$update = update_record("lesson_grades", $grade)) {
-                            error("Navigation: grade not updated");
+                            print_error("Navigation: grade not updated");
                         }
                     } else {
                         if (!$newgradeid = insert_record("lesson_grades", $grade)) {
-                            error("Navigation: grade not inserted");
+                            print_error("Navigation: grade not inserted");
                         }
                     }
                 } else {
                     if (!delete_records("lesson_attempts", "lessonid", $lesson->id, "userid", $USER->id, "retry", $ntries)) {
-                        error("Could not delete lesson attempts");
+                        print_error("Could not delete lesson attempts");
                     }
                 }
             } else {
                         $grade->completed = time();
                         if (!$lesson->practice) {
                             if (!$newgradeid = insert_record("lesson_grades", $grade)) {
-                                error("Navigation: grade not inserted");
+                                print_error("Navigation: grade not inserted");
                             }
                         }
                         echo get_string("eolstudentoutoftimenoanswers", "lesson");
index bbd185e1accbe0e93eb10478241acb6692dbc9c9..31fec0ea51fe6c856e7e58710aea5744f9620c46 100644 (file)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('quiz', $id)) {
-            error("There is no coursemodule with id $id");
+            print_error("There is no coursemodule with id $id");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $quiz = get_record("quiz", "id", $cm->instance)) {
-            error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
+            print_error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
         }
     } else {
         if (! $quiz = get_record("quiz", "id", $q)) {
-            error("There is no quiz with id $q");
+            print_error("There is no quiz with id $q");
         }
         if (! $course = get_record("course", "id", $quiz->course)) {
-            error("The course with id $quiz->course that the quiz with id $q belongs to is missing");
+            print_error("The course with id $quiz->course that the quiz with id $q belongs to is missing");
         }
         if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
-            error("The course module for the quiz with id $q is missing");
+            print_error("The course module for the quiz with id $q is missing");
         }
     }
 
         $messages = $accessmanager->prevent_access() +
                 $accessmanager->prevent_new_attempt($attemptnumber - 1, $lastattempt);
         if (!$canpreview && $messages) {
-            error($accessmanager->print_messages($messages, true),
+            print_error($accessmanager->print_messages($messages, true), '',
                     $CFG->wwwroot . '/mod/quiz/view.php?q=' . $quiz->id);
         }
         $accessmanager->do_password_check($canpreview);
 
 /// Restore the question sessions to their most recent states creating new sessions where required.
     if (!$states = get_question_states($questions, $quiz, $attempt, $lastattemptid)) {
-        error('Could not restore question sessions');
+        print_error('Could not restore question sessions');
     }
 
 /// If we are starting a new attempt, save all the newly created states.
     if (!$newattempt) {
         $messages = $accessmanager->prevent_access();
         if (!$canpreview && $messages) {
-            error($accessmanager->print_messages($messages, true),
+            print_error($accessmanager->print_messages($messages, true), '',
                     $CFG->wwwroot . '/mod/quiz/view.php?q=' . $quiz->id);
         }
         $accessmanager->do_password_check($canpreview);
index 721570a42b71bdec533d2b2a5ba8b226c3becf59..c361577dab19324be8d70941e0af6e30ee68bac8 100644 (file)
     $questionid =required_param('question', PARAM_INT); // question id
 
     if (! $attempt = get_record('quiz_attempts', 'uniqueid', $attemptid)) {
-        error('No such attempt ID exists');
+        print_error('No such attempt ID exists');
     }
     if (! $quiz = get_record('quiz', 'id', $attempt->quiz)) {
-        error('Course module is incorrect');
+        print_error('Course module is incorrect');
     }
     if (! $course = get_record('course', 'id', $quiz->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     // Teachers are only allowed to comment and grade on closed attempts
     if (!($attempt->timefinish > 0)) {
-        error('Attempt has not closed yet');
+        print_error('Attempt has not closed yet');
     }
 
     $cm = get_coursemodule_from_instance('quiz', $quiz->id);
@@ -36,7 +36,7 @@
 
     // Load question
     if (! $question = get_record('question', 'id', $questionid)) {
-        error('Question for this session is missing');
+        print_error('Question for this session is missing');
     }
     $question->maxgrade = get_field('quiz_question_instances', 'grade', 'quiz', $quiz->id, 'question', $question->id);
     // Some of the questions code is optimised to work with several questions
@@ -45,7 +45,7 @@
     $questions[$key] = &$question;
     // Add additional questiontype specific information to the question objects.
     if (!get_question_options($questions)) {
-        error("Unable to load questiontype specific question information");
+        print_error("Unable to load questiontype specific question information");
     }
 
     // Load state
index 76f2384c2f6290314f5d14180132736d6b361fb4..97fbf0bbcf67ef500eb75a07aa15a869458dd514 100644 (file)
 
     // Get the course object and related bits.
     if (! $course = get_record("course", "id", $quiz->course)) {
-        error("This course doesn't exist");
+        print_error("This course doesn't exist");
     }
 
     // Log this visit.
             // Avoid duplicate page breaks
             $quiz->questions = str_replace(',0,0', ',0', $quiz->questions);
             if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) {
-                error('Could not save question list');
+                print_error('Could not save question list');
             }
         }
     }
             // Avoid duplicate page breaks
             $quiz->questions = str_replace(',0,0', ',0', $quiz->questions);
             if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) {
-                error('Could not save question list');
+                print_error('Could not save question list');
             }
         }
     }
         $randomcount = required_param('randomcount', PARAM_INT);
         // load category
         if (! $category = get_record('question_categories', 'id', $categoryid)) {
-            error('Category ID is incorrect');
+            print_error('Category ID is incorrect');
         }
         $catcontext = get_context_instance_by_id($category->contextid);
         require_capability('moodle/question:useall', $catcontext);
                 $question->qtype = RANDOM;
                 $question = $QTYPES[RANDOM]->save_question($question, $form, $course);
                 if(!isset($question->id)) {
-                    error('Could not insert new random question!');
+                    print_error('Could not insert new random question!');
                 }
                 quiz_add_quiz_question($question->id, $quiz);
             }
         if (isset($_REQUEST['questionsperpage'])) {
             $quiz->questionsperpage = required_param('questionsperpage', PARAM_INT);
             if (!set_field('quiz', 'questionsperpage', $quiz->questionsperpage, 'id', $quiz->id)) {
-                error('Could not save number of questions per page');
+                print_error('Could not save number of questions per page');
             }
         }
         $quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);
         if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id)) {
-            error('Could not save layout');
+            print_error('Could not save layout');
         }
     }
     if (isset($_REQUEST['delete']) and confirm_sesskey()) { /// Remove a question from the quiz
                 $quiz->questions = str_replace(',0,0', ',0', $quiz->questions);
             }
             if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) {
-                error('Could not save question list');
+                print_error('Could not save question list');
             }
         }
 
         // If rescaling is required save the new maximum
         if (isset($_REQUEST['maxgrade'])) {
             if (!quiz_set_grade(optional_param('maxgrade', 0), $quiz)) {
-                error('Could not set a new maximum grade for the quiz');
+                print_error('Could not set a new maximum grade for the quiz');
             }
         }
     }
 
         $sumgrades = quiz_print_question_list($quiz,  $thispageurl, false, $quiz_showbreaks, $quiz_reordertool);
         if (!set_field('quiz', 'sumgrades', $sumgrades, 'id', $quiz->instance)) {
-            error('Failed to set sumgrades');
+            print_error('Failed to set sumgrades');
         }
 
         print_box_end();
 
     $sumgrades = quiz_print_question_list($quiz, $thispageurl, true, $quiz_showbreaks, $quiz_reordertool);
     if (!set_field('quiz', 'sumgrades', $sumgrades, 'id', $quiz->instance)) {
-        error('Failed to set sumgrades');
+        print_error('Failed to set sumgrades');
     }
 
     print_box_end();
index 67f2c0b0c16779746f4591d3a3484080152fc559..1ea548f590b47602444f958df8470de530d24fdf 100644 (file)
@@ -43,7 +43,7 @@ function quiz_delete_quiz_question($id, &$quiz) {
     $quiz->questions = str_replace(',0,0', ',0', $quiz->questions);
     // save new questionlist in database
     if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) {
-        error('Could not save question list');
+        print_error('Could not save question list');
     }
     delete_records('quiz_question_instances', 'quiz', $quiz->instance, 'question', $question);
     return true;
@@ -86,7 +86,7 @@ function quiz_add_quiz_question($id, &$quiz) {
     // Save new questionslist in database
     $quiz->questions = implode(",", $questions);
     if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id)) {
-        error('Could not save question list');
+        print_error('Could not save question list');
     }
 
     // update question grades
index 04e802344652cd1268013a9848c941759fbe60b5..dcbe4917553b37c6d948b6b66b173e104d7eb8ef 100644 (file)
@@ -5,15 +5,15 @@
     $id   = required_param('id', PARAM_INT);          // Course module ID
 
     if (! $cm = get_coursemodule_from_id('quiz', $id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     if (! $quiz = get_record('quiz', 'id', $cm->instance)) {
-        error('quiz ID was incorrect');
+        print_error('quiz ID was incorrect');
     }
 
     if (! $course = get_record('course', 'id', $quiz->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
 
     require_login($course->id, false, $cm);
index 3193bda57d6578831407c0a25882d2f27e30e919..e29ee821bcb16ac5b866cc6a6f873d4ac2e3c18c 100644 (file)
@@ -11,7 +11,7 @@
 
     $id = required_param('id', PARAM_INT);
     if (!$course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
     $coursecontext = get_context_instance(CONTEXT_COURSE, $id);
     require_login($course->id);
index e98499d8dc391b5f4155595aba7382c908c83692..f570613b16666882c4d40a9deaca2ce777c052fa 100644 (file)
@@ -92,7 +92,7 @@ function quiz_create_attempt($quiz, $attemptnumber, $lastattempt, $timenow, $isp
     } else {
     /// Build on last attempt.
         if (empty($lastattempt)) {
-            error(get_string('cannotfindprevattempt', 'quiz'));
+            print_error('cannotfindprevattempt', 'quiz');
         }
         $attempt = $lastattempt;
     }
index d6d43b0ac0f5498e9de0f89e274c853410b3ea58..698dd341870deb1554b4d0fc1b24a9ee505cd0c7 100644 (file)
@@ -20,7 +20,7 @@ class page_quiz extends page_generic_activity {
 
     function init_quick($data) {
         if(empty($data->pageid)) {
-            error('Cannot quickly initialize page: empty course id');
+            print_error('Cannot quickly initialize page: empty course id');
         }
         $this->activityname = 'quiz';
         parent::init_quick($data);
index 44d3b0f9348a74bcf81804613d3693004071ee48..049870d54ba7522b37b9447cf4202ee5a7802cfc 100644 (file)
     $relativepath = get_file_argument('quizfile.php');
     
     if (!$relativepath) {
-        error('No valid arguments supplied or incorrect server configuration');
+        print_error('No valid arguments supplied or incorrect server configuration');
     }
     
     // extract relative path components
     $args = explode('/', trim($relativepath, '/'));
     if (count($args) < 3) { // always at least category, question and path
-        error('No valid arguments supplied');
+        print_error('No valid arguments supplied');
     }
     
     $quizid       = (int)array_shift($args);
     $relativepath = implode ('/', $args);
 
     if (!($question = get_record('question', 'id', $questionid))) {
-        error('No valid arguments supplied');
+        print_error('No valid arguments supplied');
     }
 
     if (!($questioncategory = get_record('question_categories', 'id', $question->category))) {
-        error('No valid arguments supplied');
+        print_error('No valid arguments supplied');
     }
 
     /////////////////////////////////////
@@ -48,7 +48,7 @@
         if ($questioncategory->publish) {
             require_login();
             if (!isteacherinanycourse()) {
-              error('No valid arguments supplied');
+              print_error('No valid arguments supplied');
             }
         } else {
             require_login($questioncategory->course);
         }        
     } else {
         if (!($quiz = get_record('quiz', 'id', $quizid))) {
-            error('No valid arguments supplied');
+            print_error('No valid arguments supplied');
         }
         if (!($course = get_record('course', 'id', $quiz->course))) {
-            error('No valid arguments supplied');
+            print_error('No valid arguments supplied');
         }
         require_login($course->id);
         
@@ -71,7 +71,7 @@
         //    and ! ($quiz->review  &&  time() > $quiz->timeclose)
         //        || !quiz_get_user_attempts($quiz->id, $USER->id) )
         //{
-        //    error("Logged-in user is not allowed to view this quiz");
+        //    print_error("Logged-in user is not allowed to view this quiz");
         //}
     
         ///////////////////////////////////////////////////
         // For now, let's not worry about this.  The following check doesn't 
         // work for randomly selected questions and it gets complicated
         //if (!in_array($question->id, explode(',', $quiz->questions), FALSE)) {
-        //    error("Specified question is not on the specified quiz");
+        //    print_error("Specified question is not on the specified quiz");
         //}
     }
 
     // Have the question check whether it uses this file or not
     if (!$QTYPES[$question->qtype]->uses_quizfile($question,
                                                        $relativepath)) {
-        error("The specified file path is not on the specified question");
+        print_error("The specified file path is not on the specified question");
     }
 
 
         send_file($pathname, $filename, $lifetime);
     } else {
         header('HTTP/1.0 404 not found');
-        error(get_string('filenotfound', 'error')); //this is not displayed on IIS??
+        print_error('filenotfound', 'error'); //this is not displayed on IIS??
     }
 ?>
index 33f01a307479fcf965c24d6552d6f0f0b8555d7c..4b24e6cd3d361ad54f1514190360539bd04d0b1e 100644 (file)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('quiz', $id)) {
-            error("There is no coursemodule with id $id");
+            print_error("There is no coursemodule with id $id");
         }
 
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
 
         if (! $quiz = get_record("quiz", "id", $cm->instance)) {
-            error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
+            print_error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
         }
 
     } else {
         if (! $quiz = get_record("quiz", "id", $q)) {
-            error("There is no quiz with id $q");
+            print_error("There is no quiz with id $q");
         }
         if (! $course = get_record("course", "id", $quiz->course)) {
-            error("The course with id $quiz->course that the quiz with id $q belongs to is missing");
+            print_error("The course with id $quiz->course that the quiz with id $q belongs to is missing");
         }
         if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
-            error("The course module for the quiz with id $q is missing");
+            print_error("The course module for the quiz with id $q is missing");
         }
     }
 
@@ -61,7 +61,7 @@
     $mode = clean_param($mode, PARAM_SAFEDIR);
 
     if (! is_readable("report/$mode/report.php")) {
-        error("Report not known ($mode)");
+        print_error("Report not known ($mode)");
     }
 
     include("report/default.php");  // Parent class
@@ -70,7 +70,7 @@
     $report = new quiz_report();
 
     if (! $report->display($quiz, $cm, $course)) {             // Run the report!
-        error("Error occurred during pre-processing!");
+        print_error("Error occurred during pre-processing!");
     }
 
 /// Print footer
index 5eae82d89fbf4f2e5f5a349e6172599fe399fa35..dac42cf6bad7a8db05bec13f8f2963590c1905f1 100644 (file)
@@ -142,17 +142,17 @@ class quiz_report extends quiz_default_report {
                    "   AND q.id IN ($questionlist)";
 
             if (!$quizquestions = get_records_sql($sql)) {
-                error('No questions found');
+                print_error('No questions found');
             }
 
             // Load the question type specific information
             if (!get_question_options($quizquestions)) {
-                error('Could not load question options');
+                print_error('Could not load question options');
             }
             // Restore the question sessions to their most recent states
             // creating new sessions where required
             if (!$states = get_question_states($quizquestions, $quiz, $attempt)) {
-                error('Could not restore question sessions');
+                print_error('Could not restore question sessions');
             }
             $numbers = explode(',', $questionlist);
             $statsrow = array();
@@ -488,17 +488,17 @@ class quiz_report extends quiz_default_report {
                    "   AND q.id IN ($questionlist)";
 
             if (!$quizquestions = get_records_sql($sql)) {
-                error('No questions found');
+                print_error('No questions found');
             }
 
             // Load the question type specific information
             if (!get_question_options($quizquestions)) {
-                error('Could not load question options');
+                print_error('Could not load question options');
             }
             // Restore the question sessions to their most recent states
             // creating new sessions where required
             if (!$states = get_question_states($quizquestions, $quiz, $attempt)) {
-                error('Could not restore question sessions');
+                print_error('Could not restore question sessions');
             }
             $numbers = explode(',', $questionlist);
             $statsrow = array();
index 3298bcd7ee9b31fa8e05f9bf4264c7bf7debaf18..de08bf6cd76a29f6fcd29c019eb171e50eb871e7 100644 (file)
@@ -43,7 +43,7 @@ class quiz_report extends quiz_default_report {
 
         if (!empty($questionid)) {
             if (! $question = get_record('question', 'id', $questionid)) {
-                error("Question with id $questionid not found");
+                print_error("Question with id $questionid not found");
             }
             $question->maxgrade = get_field('quiz_question_instances', 'grade', 'quiz', $quiz->id, 'question', $question->id);
 
@@ -56,7 +56,7 @@ class quiz_report extends quiz_default_report {
             // We need to add additional questiontype specific information to
             // the question objects.
             if (!get_question_options($questions)) {
-                error("Unable to load questiontype specific question information");
+                print_error("Unable to load questiontype specific question information");
             }
             // This will have extended the question object so that it now holds
             // all the information about the questions that may be needed later.
@@ -73,7 +73,7 @@ class quiz_report extends quiz_default_report {
             foreach($data->manualgrades as $uniqueid => $response) {
                 // get our attempt
                 if (! $attempt = get_record('quiz_attempts', 'uniqueid', $uniqueid)) {
-                    error('No such attempt ID exists');
+                    print_error('No such attempt ID exists');
                 }
 
                 // Load the state for this attempt (The questions array was created earlier)
@@ -311,7 +311,7 @@ class quiz_report extends quiz_default_report {
                                         WHERE sess.newest = state.id AND
                                         sess.attemptid = $attempt->uniqueid AND
                                         sess.questionid = $question->id")) {
-            error('Could not find question state');
+            print_error('Could not find question state');
         }
 
         return question_state_is_graded($state);
index 75865a6fb9dc117740bb853cf1f62119e48bb415..1774e9316542ca82c2f977fe01390c59c51eee77 100644 (file)
@@ -127,7 +127,7 @@ class quiz_report extends quiz_default_report {
                     " WHERE i.quiz = '$quiz->id' AND q.id = i.question".
                     "   AND q.id IN ($questionlist)";
             if (!$questions = get_records_sql($sql)) {
-                error('No questions found');
+                print_error('No questions found');
             }
             $number = 1;
             foreach ($questionids as $key => $id) {
index 2c0ea4d2b00d3bbe7d6f6699f5f12e974ba2ca37..8f00b09cbc025ffefea5e4c53444d3fa7d853d62 100644 (file)
@@ -31,7 +31,7 @@ class quiz_report extends quiz_default_report {
                 AND i.question = q.id";
 
         if (! $questions = get_records_sql($sql)) {
-            error("Failed to get questions for regrading!");
+            print_error("Failed to get questions for regrading!");
         }
         get_question_options($questions);
 
index c6bf8deebd100c8d93c354f2dfd8a11391c70311..b6e7cf8c8569eaa869eeab6d44108416745b5b27 100644 (file)
     $showall = optional_param('showall', 0, PARAM_BOOL);
 
     if (!$attempt = quiz_load_attempt($attemptid)) {
-        error("No such attempt ID exists");
+        print_error("No such attempt ID exists");
     }
     if (! $quiz = get_record("quiz", "id", $attempt->quiz)) {
-        error("The quiz with id $attempt->quiz belonging to attempt $attempt is missing");
+        print_error("The quiz with id $attempt->quiz belonging to attempt $attempt is missing");
     }
     if (! $course = get_record("course", "id", $quiz->course)) {
-        error("The course with id $quiz->course that the quiz with id $quiz->id belongs to is missing");
+        print_error("The course with id $quiz->course that the quiz with id $quiz->id belongs to is missing");
     }
     if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
-        error("The course module for the quiz with id $quiz->id is missing");
+        print_error("The course module for the quiz with id $quiz->id is missing");
     }
 
 /// Check login and get contexts.
@@ -81,7 +81,7 @@
 
 /// Restore the question sessions to their most recent states creating new sessions where required.
     if (!$states = get_question_states($questions, $quiz, $attempt)) {
-        error('Could not restore question sessions');
+        print_error('Could not restore question sessions');
     }
 
 /// Work out appropriate title.
index b1018a2149ba5efc63552ca50419e8238f30f513..aa1441bcb9e29f314a50be857ac358d677724b26 100644 (file)
 
     if ($stateid) {
         if (! $state = get_record('question_states', 'id', $stateid)) {
-            error('Invalid state id');
+            print_error('Invalid state id');
         }
         if (! $attempt = get_record('quiz_attempts', 'uniqueid', $state->attempt)) {
-            error('No such attempt ID exists');
+            print_error('No such attempt ID exists');
         }
     } elseif ($attemptid) {
         if (! $attempt = get_record('quiz_attempts', 'id', $attemptid)) {
-            error('No such attempt ID exists');
+            print_error('No such attempt ID exists');
         }
         if (! $neweststateid = get_field('question_sessions', 'newest', 'attemptid', $attempt->uniqueid, 'questionid', $questionid)) {
             // newest_state not set, probably because this is an old attempt from the old quiz module code
             if (! $state = get_record('question_states', 'question', $questionid, 'attempt', $attempt->uniqueid)) {
-                error('Invalid question id');
+                print_error('Invalid question id');
             }
         } else {
             if (! $state = get_record('question_states', 'id', $neweststateid)) {
-                error('Invalid state id');
+                print_error('Invalid state id');
             }
         }
     } else {
-        error('Parameter missing');
+        print_error('Parameter missing');
     }
     if (! $question = get_record('question', 'id', $state->question)) {
-        error('Question for this state is missing');
+        print_error('Question for this state is missing');
     }
     if (! $quiz = get_record('quiz', 'id', $attempt->quiz)) {
-        error('Course module is incorrect');
+        print_error('Course module is incorrect');
     }
     if (! $course = get_record('course', 'id', $quiz->course)) {
-        error('Course is misconfigured');
+        print_error('Course is misconfigured');
     }
     if (! $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     require_login($course->id, false, $cm);
         // If not even responses are to be shown in review then we
         // don't allow any review
         if (!($quiz->review & QUIZ_REVIEW_RESPONSES)) {
-            error(get_string("noreview", "quiz"));
+            print_error("noreview", "quiz");
         }
         if ((time() - $attempt->timefinish) > 120) { // always allow review right after attempt
             if ((!$quiz->timeclose or time() < $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_OPEN)) {
-                error(get_string("noreviewuntil", "quiz", userdate($quiz->timeclose)));
+                print_error("noreviewuntil", "quiz", '', userdate($quiz->timeclose));
             }
             if ($quiz->timeclose and time() >= $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_CLOSED)) {
-                error(get_string("noreview", "quiz"));
+                print_error("noreview", "quiz");
             }
         }
         if ($attempt->userid != $USER->id) {
-            error('This is not your attempt!');
+            print_error('This is not your attempt!');
         }
     }
 
     $questions[$key] = &$question;
     // Add additional questiontype specific information to the question objects.
     if (!get_question_options($questions)) {
-        error("Unable to load questiontype specific question information");
+        print_error("Unable to load questiontype specific question information");
     }
 
     $session = get_record('question_sessions', 'attemptid', $attempt->uniqueid, 'questionid', $question->id);
index 55d3b96f090095aad80b9a8c7014e2b314442084..a6f9b75c6b6ecd8f22b1552e4d600febb2035a6e 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 if (empty($quiz)) {
-    error('You cannot call this script in that way');
+    print_error('You cannot call this script in that way');
 }
 if (!isset($currenttab)) {
     $currenttab = '';
index 13a33fb879757687088b7744fc9fb3640d3aa0f1..c28ebc0ca9090dbfbc8d76f1138d1435025eb15b 100644 (file)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('quiz', $id)) {
-            error("There is no coursemodule with id $id");
+            print_error("There is no coursemodule with id $id");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $quiz = get_record("quiz", "id", $cm->instance)) {
-            error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
+            print_error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing");
         }
     } else {
         if (! $quiz = get_record("quiz", "id", $q)) {
-            error("There is no quiz with id $q");
+            print_error("There is no quiz with id $q");
         }
         if (! $course = get_record("course", "id", $quiz->course)) {
-            error("The course with id $quiz->course that the quiz with id $q belongs to is missing");
+            print_error("The course with id $quiz->course that the quiz with id $q belongs to is missing");
         }
         if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
-            error("The course module for the quiz with id $q is missing");
+            print_error("The course module for the quiz with id $q is missing");
         }
     }
 
index 807c029d1b36e41ae033ec693d56983985fa8824..a611aa9245d02b46dffef85a4fe43c4a2f1cb8a6 100644 (file)
@@ -5,7 +5,7 @@
     $id = required_param( 'id', PARAM_INT ); // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course, true);
index 3cc8b2d62c08a889c1e0a32ed04faa9414ff6655..252426f3a35716692c877d3273aa354d0a0e57c9 100644 (file)
@@ -39,15 +39,15 @@ class resource_base {
 
         if ($cmid) {
             if (! $this->cm = get_coursemodule_from_id('resource', $cmid)) {
-                error("Course Module ID was incorrect");
+                print_error("Course Module ID was incorrect");
             }
 
             if (! $this->course = get_record("course", "id", $this->cm->course)) {
-                error("Course is misconfigured");
+                print_error("Course is misconfigured");
             }
 
             if (! $this->resource = get_record("resource", "id", $this->cm->instance)) {
-                error("Resource ID was incorrect");
+                print_error("Resource ID was incorrect");
             }
 
             $this->strresource  = get_string("modulename", "resource");
@@ -598,7 +598,7 @@ function resource_renamefiles($course, $wdir, $oldname, $name) {
                 $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 (!update_record('resource', $r)) {
-                        error("Error updating resource with ID $r->id.");
+                        print_error("Error updating resource with ID $r->id.");
                     }
                 }
             }
index ed7a6156904aef04f0c3d9ae6efb6dc1ea2cd28f..b3dbe33a5a02f4ea75066db53facdecab36c8a7e 100644 (file)
@@ -13,7 +13,7 @@ class mod_resource_mod_form extends moodleform_mod {
             if($res = get_record('resource', 'id', (int)$this->_instance)) {
                 $type = $res->type;
             } else {
-                error('incorrect assignment');
+                print_error('incorrect assignment');
             }
         } else {
             $type = required_param('type', PARAM_ALPHA);
index 292e4616252c51e5568271e364d015e5dd91dec7..e517f0342251f8cd0cd057a0668afd69f6db6c82 100644 (file)
@@ -55,7 +55,7 @@ function display() {
     if ($subdir) {
         $relativepath = "$relativepath$subdir";
         if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) {
-            error("Access not allowed!");
+            print_error("Access not allowed!");
         }
 
         $subs = explode('/', $subdir);
index bf5232d7e80982f80de091d5b9ab384f845b28df..29b3cae7ff92cc0da5ecd608930a25aedeebe230 100644 (file)
@@ -8,7 +8,7 @@
     require_login();
 
     if (!$CFG->resource_allowlocalfiles) {
-        error('You cannot access this script');
+        print_error('You cannot access this script');
     }
 
     print_header(get_string('localfilechoose', 'resource'));
index aeb9c392c529d820b1f4580511c485607cfba968..9a344baf71a0a139322763e0a148b92e896e2e7e 100644 (file)
@@ -8,27 +8,27 @@
 
     if ($r) {  // Two ways to specify the resource
         if (! $resource = get_record('resource', 'id', $r)) {
-            error('Resource ID was incorrect');
+            print_error('Resource ID was incorrect');
         }
 
         if (! $cm = get_coursemodule_from_instance('resource', $resource->id, $resource->course)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
 
     } else if ($id) {
         if (! $cm = get_coursemodule_from_id('resource', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
 
         if (! $resource = get_record('resource', 'id', $cm->instance)) {
-            error('Resource ID was incorrect');
+            print_error('Resource ID was incorrect');
         }
     } else {
-        error('No valid parameters!!');
+        print_error('No valid parameters!!');
     }
 
     if (! $course = get_record('course', 'id', $cm->course)) {
-        error('Incorrect course id');
+        print_error('Incorrect course id');
     }
 
     require_course_login($course, true, $cm);
index 64b2de3a26c72b23ced28cc0ceb316b1d3dd982c..a17de5384b4162504630af83e349edc1bd651477 100755 (executable)
@@ -14,7 +14,7 @@
         if (isset($SESSION->scorm_scoid)) {
             $scoid = $SESSION->scorm_scoid;
         } else {
-            error('Invalid script call');
+            print_error('Invalid script call');
         }
         $mode = 'normal';
         if (isset($SESSION->scorm_mode)) {
 
         if ($sco = scorm_get_sco($scoid, SCO_ONLY)) {
             if (!$scorm = get_record('scorm','id',$sco->scorm)) {
-                error('Invalid script call');
+                print_error('Invalid script call');
             }
         } else {
-            error('Invalid script call');
+            print_error('Invalid script call');
         }
 
         if ($scorm = get_record('scorm','id',$sco->scorm)) {
                             echo 'Max_Time_Allowed = '.$userdata->maxtimeallowed."\n";
                             echo 'Time_Limit_Action = '.$userdata->timelimitaction."\n";
                         } else {
-                            error('Sco not found');
+                            print_error('Sco not found');
                         }
                     }
                 break;
index 97b4c3817e8d58dadce470f828aa19124135fd50..c6dd808411fd3c1e7dec1e1e907d5a6a2c4a17a0 100644 (file)
 
     if (!empty($id)) {
         if (! $cm = get_coursemodule_from_id('scorm', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $scorm = get_record("scorm", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
     } else if (!empty($a)) {
         if (! $scorm = get_record("scorm", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $scorm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     } else {
-        error('A required parameter is missing');
+        print_error('A required parameter is missing');
     }
 
     require_login($course->id, false, $cm);
@@ -62,7 +62,7 @@
             $userdata->$key = $value;
         }
     } else {
-        error('Sco not found');
+        print_error('Sco not found');
     }
     $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR));   // Just to be safe
     if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) {
index d7c6d8766eafc4bd4e5a390e60b397befe21a773..c0a4e0c73ff7fcc28dcc9c6c12f25e6131189188 100755 (executable)
 
     if (!empty($id)) {
         if (! $cm = get_record("course_modules", "id", $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $scorm = get_record("scorm", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
     } else if (!empty($a)) {
         if (! $scorm = get_record("scorm", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $scorm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     } else {
-        error('A required parameter is missing');
+        print_error('A required parameter is missing');
     }
 
     require_login($course->id, false, $cm);
index 5e4fc4ffc136f6c8ce30477a6b79d5d8547a5f63..72089d765e8abe4bd10153c07700f1388bba690c 100755 (executable)
@@ -7,10 +7,10 @@
 
     if (!empty($id)) {
         if (! $course = get_record("course", "id", $id)) {
-            error("Course ID is incorrect");
+            print_error("Course ID is incorrect");
         }
     } else {
-        error('A required parameter is missing');
+        print_error('A required parameter is missing');
     }
 
     require_course_login($course);
index fb3804656ff55813a148dc45f156434eccbabe18..f6225c44a750018f4a7e12b34a9541bf82100eb5 100755 (executable)
 
     if (!empty($id)) {
         if (! $cm = get_coursemodule_from_id('scorm', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
     } else if (!empty($a)) {
         if (! $scorm = get_record('scorm', 'id', $a)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
         if (! $course = get_record('course', 'id', $scorm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
     } else {
-        error('A required parameter is missing');
+        print_error('A required parameter is missing');
     }
 
     require_login($course->id, false, $cm);
index 6440daa8426ad665679c99c3b6e33b416d7b83c7..5996e05130567f684f5ea424868aa4d00c921401 100755 (executable)
@@ -467,7 +467,7 @@ function scorm_course_format_display($user,$course) {
         // The module SCORM activity with the least id is the course  
         $scorm = current($scorms);
         if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         $colspan = '';
         $headertext = '<table width="100%"><tr><td class="title">'.get_string('name').': <b>'.format_string($scorm->name).'</b>';
index d6ca13d317f413f745e03b53323db2f6a2430a51..7ac0f3f372041bfaeac613f047603d928cd48c89 100755 (executable)
 
     if (!empty($id)) {
         if (! $cm = get_coursemodule_from_id('scorm', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $scorm = get_record("scorm", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
     } else if (!empty($a)) {
         if (! $scorm = get_record("scorm", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $scorm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     } else {
-        error('A required parameter is missing');
+        print_error('A required parameter is missing');
     }
 
     require_login($course->id, false, $cm);
index 661eac7c4c573f00eaa4f87fdc549a2dab8f3273..f60422ade4f519c76eb36021a545f4c3fa909563 100755 (executable)
 
     if (!empty($id)) {
         if (! $cm = get_coursemodule_from_id('scorm', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('Course Module ID was incorrect');
         }
         if (! $course = get_record('course', 'id', $cm->course)) {
-            error('Course is misconfigured');
+            print_error('Course is misconfigured');
         }
         if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
-            error('Course module is incorrect');
+            print_error('Course module is incorrect');
         }
     } else {
         if (!empty($b)) {
             if (! $sco = get_record('scorm_scoes', 'id', $b)) {
-                error('Scorm activity is incorrect');
+                print_error('Scorm activity is incorrect');
             }
             $a = $sco->scorm;
         }
         if (!empty($a)) {
             if (! $scorm = get_record('scorm', 'id', $a)) {
-                error('Course module is incorrect');
+                print_error('Course module is incorrect');
             }
             if (! $course = get_record('course', 'id', $scorm->course)) {
-                error('Course is misconfigured');
+                print_error('Course is misconfigured');
             }
             if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
-                error('Course Module ID was incorrect');
+                print_error('Course Module ID was incorrect');
             }
         }
     }
@@ -44,7 +44,7 @@
     require_login($course->id, false, $cm);
 
     if (!has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE,$cm->id))) {
-        error('You are not allowed to use this script');
+        print_error('You are not allowed to use this script');
     }
 
     add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id);
             }                
             print_simple_box_end();
         } else {
-            error('Missing script parameter');
+            print_error('Missing script parameter');
         }
     }
 
index cbfe4b16bde0bcc6073adaf119d6195f53f4b1b7..19ecf86d5d7d6f446125cbe6cc695d0e38fedf41 100755 (executable)
@@ -9,26 +9,26 @@
 
     if (!empty($id)) {
         if (! $cm = get_coursemodule_from_id('scorm', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $scorm = get_record("scorm", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
     } else if (!empty($a)) {
         if (! $scorm = get_record("scorm", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $scorm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     } else {
-        error('A required parameter is missing');
+        print_error('A required parameter is missing');
     }
 
     require_login($course->id, false, $cm);
index bb8f28cd11202a2db2d9853ab227a2b905597f97..eb966aae06aed416d55145ac7b08d9ff52cf104a 100644 (file)
@@ -9,18 +9,18 @@
     $group = optional_param('group', 0, PARAM_INT);
 
     if (! $cm = get_record("course_modules", "id", $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
     require_capability('mod/survey:download', get_context_instance(CONTEXT_MODULE, $cm->id)) ;
 
     if (! $survey = get_record("survey", "id", $cm->instance)) {
-        error("Survey ID was incorrect");
+        print_error("Survey ID was incorrect");
     }
 
     add_to_log($course->id, "survey", "download", "download.php?id=$cm->id&amp;type=$type", "$survey->id", $cm->id);
@@ -99,7 +99,7 @@
 // Get and collate all the results in one big array
 
     if (! $aaa = get_records("survey_answers", "survey", "$survey->id", "time ASC")) {
-        error("There are no answers for this survey yet.");
+        print_error("There are no answers for this survey yet.");
     }
 
     foreach ($aaa as $a) {
             $col = 0;
             $row++;
             if (! $u = get_record("user", "id", $user)) {
-                error("Error finding student # $user");
+                print_error("Error finding student # $user");
             }
             if ($n = get_record("survey_analysis", "survey", $survey->id, "userid", $user)) {
                 $notes = $n->notes;
             $col = 0;
             $row++;
             if (! $u = get_record("user", "id", $user)) {
-                error("Error finding student # $user");
+                print_error("Error finding student # $user");
             }
             if ($n = get_record("survey_analysis", "survey", $survey->id, "userid", $user)) {
                 $notes = $n->notes;
 
     foreach ($results as $user => $rest) {
         if (! $u = get_record("user", "id", $user)) {
-            error("Error finding student # $user");
+            print_error("Error finding student # $user");
         }
         echo $survey->id."\t";
         echo strip_tags(format_string($survey->name,true))."\t";
index 62e10d58ccde925216df012897c478e1f5baea20..4d2e9c5edc7db729e3bb45b9b6d5c2bd2ed44da3 100644 (file)
     $qid   = optional_param('qid', 0, PARAM_INT);  // Group ID
 
     if (! $cm = get_coursemodule_from_id('survey', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
 
     if (!has_capability('mod/survey:readresponses', $context)) {
         if ($type != "student.png" or $sid != $USER->id ) {
-            error("Sorry, you aren't allowed to see this.");
+            print_error("Sorry, you aren't allowed to see this.");
         } else if ($groupmode and !groups_is_member($group)) {
-            error("Sorry, you aren't allowed to see this.");
+            print_error("Sorry, you aren't allowed to see this.");
         }
     }
 
     if (! $survey = get_record("survey", "id", $cm->instance)) {
-        error("Survey ID was incorrect");
+        print_error("Survey ID was incorrect");
     }
 
 /// Check to see if groups are being used in this survey
index 217bb13ae8aa0a2d2b1fc70a8dd54bf52bfe1aba..26327b212f0449c4af5304e6169cb891b01f8184 100644 (file)
@@ -6,7 +6,7 @@
     $id = required_param('id', PARAM_INT);    // Course Module ID
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index 2c0f4696fe1f35835a16a46f2d50a29cfd389017..573f1256bf4b99f73bfd19f1f97c3a04b4aa4e5d 100644 (file)
@@ -18,7 +18,7 @@ class mod_survey_mod_form extends moodleform_mod {
         $mform->addRule('name', null, 'required', null, 'client');
 
         if (!$options = get_records_menu("survey", "template", 0, "name", "id, name")) {
-            error('No survey templates found!');
+            print_error('No survey templates found!');
         }
 
         foreach ($options as $id => $name) {
index a585b73f546a836b1e47fbd28cae6da20e3c512c..ea1a154c56dd7f7c611b04b42e3e7abb8ddb2c97 100644 (file)
     $qid = implode (',', $qids);
 
     if (! $cm = get_coursemodule_from_id('survey', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
     require_capability('mod/survey:readresponses', $context);
 
     if (! $survey = get_record("survey", "id", $cm->instance)) {
-        error("Survey ID was incorrect");
+        print_error("Survey ID was incorrect");
     }
 
     if (! $template = get_record("survey", "id", $survey->template)) {
-        error("Template ID was incorrect");
+        print_error("Template ID was incorrect");
     }
 
     $showscales = ($template->name != 'ciqname');
 
       case "question":
         if (!$question = get_record("survey_questions", "id", $qid)) {
-            error("Question doesn't exist");
+            print_error("Question doesn't exist");
         }
         $question->text = get_string($question->text, "survey");
 
 
       case "student":
          if (!$user = get_record("user", "id", $student)) {
-             error("Student doesn't exist");
+             print_error("Student doesn't exist");
          }
 
          print_heading(get_string("analysisof", "survey", fullname($user)));
index 5998987c045b93d8aa71a4fa39b996786595807f..328ab4a2d63c54b335a6809f73f370300a68f0ad 100644 (file)
@@ -7,17 +7,17 @@
 // Make sure this is a legitimate posting
 
     if (!$formdata = data_submitted("$CFG->wwwroot/mod/survey/view.php")) {
-        error("You are not supposed to use this script like that.");
+        print_error("You are not supposed to use this script like that.");
     }
 
     $id = required_param('id', PARAM_INT);    // Course Module ID
 
     if (! $cm = get_coursemodule_from_id('survey', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
@@ -26,7 +26,7 @@
     require_capability('mod/survey:participate', $context);
     
     if (! $survey = get_record("survey", "id", $cm->instance)) {
-        error("Survey ID was incorrect");
+        print_error("Survey ID was incorrect");
     }
 
     add_to_log($course->id, "survey", "submit", "view.php?id=$cm->id", "$survey->id", "$cm->id");
@@ -83,7 +83,7 @@
         }
 
         if (! insert_record("survey_answers", $newdata)) {
-            error("Encountered a problem trying to store your results. Sorry.");
+            print_error("Encountered a problem trying to store your results. Sorry.");
         }
     }
 
index 230ee0061e3aa21c0f2fb5fb050736638de50cc3..bf1e346d10d04b2277c1f5a8e0ae94fc9447b436 100644 (file)
@@ -6,11 +6,11 @@
     $id = required_param('id', PARAM_INT);    // Course Module ID
 
     if (! $cm = get_coursemodule_from_id('survey', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
@@ -20,7 +20,7 @@
     require_capability('mod/survey:participate', $context);
 
     if (! $survey = get_record("survey", "id", $cm->instance)) {
-        error("Survey ID was incorrect");
+        print_error("Survey ID was incorrect");
     }
     $trimmedintro = trim($survey->intro);
     if (empty($trimmedintro)) {
@@ -29,7 +29,7 @@
     }
 
     if (! $template = get_record("survey", "id", $survey->template)) {
-        error("Template ID was incorrect");
+        print_error("Template ID was incorrect");
     }
 
     $showscales = ($template->name != 'ciqname');
 
 // Get all the major questions and their proper order
     if (! $questions = get_records_list("survey_questions", "id", $survey->questions)) {
-        error("Couldn't find any questions in this survey!!");
+        print_error("Couldn't find any questions in this survey!!");
     }
     $questionorder = explode( ",", $survey->questions);
 
index 77c207a3ab679048eede99c5facd9d16530e0048..fea6e1a2dcab245939f0d7d89cf2d1e8e178188c 100644 (file)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('wiki', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
 
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
 
         if (! $wiki = get_record("wiki", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
 
     } else {
         if (! $wiki = get_record("wiki", "id", $a)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $wiki->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
     }
 
 
     /// Is an Action given ?
     if(!$action) {
-      error(get_string("noadministrationaction","wiki"));
+      print_error("noadministrationaction","wiki");
     }
 
     /// Correct Action ?
     if(!in_array($action, array("setpageflags", "removepages", "strippages", "checklinks", "revertpages"))) {
-      error("Unknown action '$action'","wiki");
+      print_error("Unknown action '$action'","wiki");
     }
 
 
     /// May the User administrate it ?
     if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false || wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course) === false) {
-      error(get_string("notadministratewiki","wiki"));
+      print_error("notadministratewiki","wiki");
     }
 
     $canedit = wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course);
@@ -77,7 +77,7 @@
     if(in_array($action,array("removepages","strippages","revertpages"))) {
       if(!($wiki->wtype=="student" || ($wiki->wtype=="group" and $canedit) || wiki_is_teacher($wiki))) {
         add_to_log($course->id, "wiki", "hack", "", $wiki->name.": Tried to trick admin.php with action=$action.");
-        error("Hack attack detected !");
+        print_error("Hack attack detected !");
       }
     }
 
                 }
               }
             break;
-        default: error("No such Wiki-Admin action: $action");
+        default: print_error("No such Wiki-Admin action: $action");
           break;
       }
     }
            if(!$ret) {
              redirect($redirect, get_string("pagesremoved","wiki"), 1);
            } else {
-             error($ret);
+             print_error($ret);
            }
            exit;
         case "strippages":
            if(!$ret) {
              redirect($redirect, get_string("pagesstripped","wiki"), 1);
            } else {
-             error($ret);
+             print_error($ret);
            }
            exit;
         case "checklinks":
         case "setpageflags":
            # No confirmation needed
            break;
-        default: error("No such action '$action' with confirmation");
+        default: print_error("No such action '$action' with confirmation");
       }
     }
 
index 6b38174ae73fac537b1cb5f8e827d86301f1b5d1..4ba72c4ae81663cf62204b59426a3e22f686e2f8 100644 (file)
            // Binary Handling starts here
            #### MOODLE CHANGE TO BE COMPATIBLE WITH PHP 4.1
            #if(headers_sent($file,$line)) {
-           #  error("Headers already sent: $file:$line");
+           #  print_error("Headers already sent: $file:$line");
            if(headers_sent()) {
-             error("Headers already sent.");
+             print_error("Headers already sent.");
            }
            $pf($GLOBALS);
         }
index 0d05f959c9303dc5d4ec89aa73acc45e91a5429e..f2ef2b5c9212244f5dcf2571c1711c14a16dafb2 100644 (file)
@@ -42,12 +42,12 @@ function moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid) {
     global $CFG;
     $entry=wiki_get_entry($wiki, $course, $userid, $groupid);
     if(!$entry) {
-      error("Cannot get entry."); 
+      print_error("Cannot get entry."); 
     }
     
     $dir=make_upload_directory("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/".$meta["section"]);
     if(substr($id, 0, strlen(EWIKI_IDF_INTERNAL))!=EWIKI_IDF_INTERNAL) {
-      error("Binary entry does not start with ".EWIKI_IDF_INTERNAL.substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
+      print_error("Binary entry does not start with ".EWIKI_IDF_INTERNAL.substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
     }
     $id = substr($id,strlen(EWIKI_IDF_INTERNAL));
     $id = clean_filename($id);
@@ -61,14 +61,14 @@ function moodle_binary_store_file(&$filename, &$id, &$meta, $ext=".bin") {
     # READ-Only
     global $_FILES, $CFG, $course, $wiki, $groupid, $userid, $ewiki_title, $cm;
     if(!$wiki->ewikiacceptbinary) {
-      error("This wiki does not accept binaries");
+      print_error("This wiki does not accept binaries");
       return 0;
     }
     
     
     $entry=wiki_get_entry($wiki, $course, $userid, $groupid);
     if(!$entry->id) {
-      error("Cannot get entry.");
+      print_error("Cannot get entry.");
     }
     
     require_once($CFG->dirroot.'/lib/uploadlib.php');
@@ -81,7 +81,7 @@ function moodle_binary_store_file(&$filename, &$id, &$meta, $ext=".bin") {
         }
         return true;
     }
-    error($um->print_upload_log(true));
+    print_error($um->print_upload_log(true));
     return false;
    
 }
@@ -94,7 +94,7 @@ function moodle_binary_store_get_file($id, &$meta) {
 
     #-- check for file
     if(!$wiki->ewikiacceptbinary) {
-      error("This wiki does not accept binaries");
+      print_error("This wiki does not accept binaries");
       return 0;
     }
     
index 1d9fded5b06d694e7a4689fa4eca2973de86f6ce..1e857bd71956b8d967ebb4bb81a25ee7607ae8e5 100644 (file)
@@ -239,7 +239,7 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir
         $exportdir=$CFG->dataroot."/".$course->id."/".$exportdestinations;
       } else {
         add_to_log($course->id, "wiki", "hack", "", format_string($wiki->name,true).": Tried to export a wiki as non-teacher into $exportdestinations.");
-        error("You are not a teacher !");
+        print_error("You are not a teacher !");
       }
     } else {
         $exportbasedir=tempnam("/tmp","WIKIEXPORT");
@@ -249,7 +249,7 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir
         $exportdir=$exportbasedir."/".$wname;
         @mkdir($exportdir);
         if(!is_dir($exportdir)) {
-            error("Cannot create temporary directory $exportdir !");
+            print_error("Cannot create temporary directory $exportdir !");
         }
     }
     
@@ -346,12 +346,12 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir
       #-- add file
       // Let's make sure the file exists and is writable first.
       if (!$handle = fopen($exportdir."/".$fn, 'w')) {
-        error("Cannot open file ($exportdir/$fn)");
+        print_error("Cannot open file ($exportdir/$fn)");
       }
       
       // Write $content to our opened file.
       if (fwrite($handle, $content) === FALSE) {
-        error("Cannot write to file ($exportdir/$fn)");
+        print_error("Cannot write to file ($exportdir/$fn)");
       }
 
       fclose($handle);
@@ -387,12 +387,12 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir
         // Let's make sure the file exists and is writable first.
         $indexname="index".$html_ext;
         if (!$handle = fopen($exportdir."/".$indexname, 'w')) {
-          error("Cannot open file ($exportdir/$indexname)");
+          print_error("Cannot open file ($exportdir/$indexname)");
         }
         
         // Write $somecontent to our opened file.
         if (fwrite($handle, $str_formatted) === FALSE) {
-          error("Cannot write to file ($exportdir/$indexname)");
+          print_error("Cannot write to file ($exportdir/$indexname)");
         }
   
         fclose($handle);
@@ -418,10 +418,10 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir
       Header("X-Content-Type: application/zip");
       Header("Content-Location: $archivename");      
       if(!@readfile("$exportbasedir/$archivename")) {
-        error("Cannot read $exportbasedir/$archivename");
+        print_error("Cannot read $exportbasedir/$archivename");
       }
       if(!deldir($exportbasedir)) {
-        error("Cannot delete $exportbasedir");
+        print_error("Cannot delete $exportbasedir");
       }
       #exit();
       return false;
index 313891df4ad1ee0030dd30b9131e4cab3006a2b4..20927812ecd7e42c008c4992db5f860fadadb71b 100644 (file)
@@ -9,7 +9,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index 66a206656170242c33fe8ff8242b8b31448494d4..64e2716645776f18530462655e661e50e2607e6a 100644 (file)
@@ -29,7 +29,7 @@ function wiki_context($wiki) {
         $wiki = $wiki->id;
     }
     if (! $cm = get_coursemodule_from_instance('wiki', $wiki)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     return get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -409,7 +409,7 @@ function wiki_get_default_entry(&$wiki, &$course, $userid=0, $groupid=0) {
             // Whatever groups are in the course, pick one
             $coursegroups = groups_get_all_groups($course->id);
             if(!$coursegroups || count($coursegroups)==0) {
-                error("Can't access wiki in group mode when no groups are configured for the course");
+                print_error("Can't access wiki in group mode when no groups are configured for the course");
             }
             $unkeyed=array_values($coursegroups); // Make sure first item is index 0
             $groupid=$unkeyed[0]->id;
@@ -421,7 +421,7 @@ function wiki_get_default_entry(&$wiki, &$course, $userid=0, $groupid=0) {
         if (wiki_can_add_entry($wiki, $USER, $course, $userid, $groupid)) {
             wiki_add_entry($wiki, $course, $userid, $groupid);
             if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) {
-                error("Could not add wiki entry.");
+                print_error("Could not add wiki entry.");
             }
         }
     }
@@ -465,7 +465,7 @@ function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) {
                     // Whatever groups are in the course, pick one
                     $coursegroups = groups_get_all_groups($course->id);
                     if(!$coursegroups || count($coursegroups)==0) {
-                        error("Can't access wiki in group mode when no groups are configured for the course");
+                        print_error("Can't access wiki in group mode when no groups are configured for the course");
                     }
                     $unkeyed=array_values($coursegroups); // Make sure first item is index 0
                     $groupid=$unkeyed[0]->id;
@@ -477,7 +477,7 @@ function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) {
             if ($groupid and wiki_user_can_access_group_wiki($wiki, $groupid, $course)) {
                 $wentry = wiki_get_group_entry($wiki, $groupid);
             } else {
-                error("Cannot access any groups for this wiki");
+                print_error("Cannot access any groups for this wiki");
             }
         }
         /// If mode is 'nogroups', then groupid is zero.
@@ -1684,7 +1684,7 @@ function wiki_obtain_lock($wikiid,$pagename) {
         } else {
             // Not locked any more. Get rid of the old lock record.
             if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wikiid)) {
-                error('Unable to delete lock record');
+                print_error('Unable to delete lock record');
             }
         }
     }
@@ -1699,7 +1699,7 @@ function wiki_obtain_lock($wikiid,$pagename) {
         $newlock->wikiid=$wikiid;
         $newlock->pagename=$pagename;
         if(!$lockid=insert_record('wiki_locks',$newlock)) {
-            error('Unable to insert lock record');
+            print_error('Unable to insert lock record');
         }
     }
 
@@ -1734,7 +1734,7 @@ function wiki_release_lock($wikiid,$pagename) {
         $lockid=$_SESSION[SESSION_WIKI_LOCKS][$key];
         unset($_SESSION[SESSION_WIKI_LOCKS][$key]);
         if(!delete_records('wiki_locks','id',$lockid)) {
-            error("Unable to delete lock record.");
+            print_error("Unable to delete lock record.");
         }
     }
 }
index 0b83b9bed57780e13f0009fb31101a936b44902f..1aa088b5094510ca42775c231f370fee41d087b8 100644 (file)
@@ -15,36 +15,36 @@ $id=required_param('id',PARAM_INT);
 $page=required_param('page',PARAM_RAW);
 
 if (! $cm = get_coursemodule_from_id('wiki', $id)) {
-    error("Course Module ID was incorrect");
+    print_error("Course Module ID was incorrect");
 }
 if (! $course = get_record("course", "id", $cm->course)) {
-    error("Course is misconfigured");
+    print_error("Course is misconfigured");
 }
 if (! $wiki = get_record("wiki", "id", $cm->instance)) {
-    error("Course module is incorrect");
+    print_error("Course module is incorrect");
 }
 
 if(!confirm_sesskey()) {
-    error("Session key not set");
+    print_error("Session key not set");
 }
 if(!data_submitted()) {
-    error("Only POST requests accepted");
+    print_error("Only POST requests accepted");
 }
 
 require_course_login($course, true, $cm);
 
 $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
 if(!has_capability('mod/wiki:overridelock', $modcontext)) {
-    error("You do not have the capability to override editing locks");
+    print_error("You do not have the capability to override editing locks");
 }
 
 $actions = explode('/', $page,2);
 if(count($actions)!=2) {
-    error("Unsupported page value");
+    print_error("Unsupported page value");
 }
 $pagename=addslashes($actions[1]);
 if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wiki->id)) {
-    error('Unable to delete lock record');
+    print_error('Unable to delete lock record');
 }
 
 redirect("view.php?id=$id&page=".urlencode($page));
index f2439cc1a49a4000a82728ff7e53941c47fb0cff..b832e1771b6780915528e294c14fc4e5ba033266 100644 (file)
     
     if ($id) {
         if (! $cm = get_coursemodule_from_id('wiki', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
 
         if (! $course = get_record("course", "id", $cm->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
 
         if (! $wiki = get_record("wiki", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
 
     } else {
         if (! $wiki = get_record("wiki", "id", $wid)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
         if (! $course = get_record("course", "id", $wiki->course)) {
-            error("Course is misconfigured");
+            print_error("Course is misconfigured");
         }
         if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         $id = $cm->id;
         $_REQUEST["id"] = $id;
             list($ok,$lock)=wiki_obtain_lock($wiki_entry->id,$pagename);
             if(!$ok) {
                 $strsavenolock=get_string('savenolock','wiki');
-                error($strsavenolock,$CFG->wwwroot.'/mod/wiki/view.php?id='.$cm->id.'&page=view/'.urlencode($pagename));
+                print_error($strsavenolock, '', $CFG->wwwroot.'/mod/wiki/view.php?id='.$cm->id.'&page=view/'.urlencode($pagename));
             }
         }
         
index 3a1a8a5dd613ddd3ec843d11f64937b50bad6ee4..7275ed3639ef40d0e0608ebb8a3e99bc89501c29 100644 (file)
     $sid           = optional_param('sid', 0, PARAM_INT);
 
     if (! $submission = get_record('workshop_submissions', 'id', $sid)) {
-        error("Incorrect submission id");
+        print_error("Incorrect submission id");
     }
     if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
-        error("Submission is incorrect");
+        print_error("Submission is incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Workshop is misconfigured");
+        print_error("Workshop is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        error("No coursemodule found");
+        print_error("No coursemodule found");
     }
 
     require_login($course->id, false, $cm);
@@ -89,7 +89,7 @@
                 $assessment->generalcomment = '';
                 $assessment->teachercomment = '';
                 if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
-                    error("Could not insert workshop assessment!");
+                    print_error("Could not insert workshop assessment!");
                 }
                 // if it's the teacher and the workshop is error banded set all the elements to Yes
                 if (workshop_is_teacher($workshop) and ($workshop->gradingstrategy == 2)) {
                         $element->feedback = '';
                         $element->grade = 1;
                         if (!$element->id = insert_record("workshop_grades", $element)) {
-                            error("Could not insert workshop grade!");
+                            print_error("Could not insert workshop grade!");
                         }
                     }
                     // now set the adjustment
                     $element->elementno = $i;
                     $element->grade = 0;
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                 }
             }
index 7bb8e9743325ac3c3293a199236ebd48e1d3c905..db1c8d09cd067754bd895c169097965c9c939532 100644 (file)
     // get some useful stuff...
     if ($id) {
         if (! $cm = get_coursemodule_from_id('workshop', $id)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
         }
         if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-            error("Course module is incorrect");
+            print_error("Course module is incorrect");
         }
     } else if ($wid) {
         if (! $workshop = get_record("workshop", "id", $wid)) {
-            error("Workshop id is incorrect");
+            print_error("Workshop id is incorrect");
         }
         if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            error("No coursemodule found");
+            print_error("No coursemodule found");
         }
     } else {
-        error("No id given");
+        print_error("No id given");
     }
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     require_login($course->id, false, $cm);
         print_heading_with_help(get_string("addacomment", "workshop"), "addingacomment", "workshop");
         // get assessment record
         if (!$assessmentid = $aid) { // comes from link or hidden form variable
-            error("Assessment id not given");
+            print_error("Assessment id not given");
         }
         $assessment = get_record("workshop_assessments", "id", $assessmentid);
         if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            error("Submission not found");
+            print_error("Submission not found");
         }
         ?>
         <form id="commentform" action="assessments.php" method="post">
     elseif ($action == 'addstockcomment') {
 
         if (empty($aid) or ($elementno<0)) {
-            error("Workshop Assessment ID and/or Element Number missing");
+            print_error("Workshop Assessment ID and/or Element Number missing");
         }
 
         require_capability('mod/workshop:manage', $context);
 
         if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            error("workshop assessment is misconfigured");
+            print_error("workshop assessment is misconfigured");
         }
         $form = data_submitted('nomatch'); //Nomatch because we can come from assess.php
 
         }
 
         if (!$element->id = insert_record("workshop_stockcomments", $comment)) {
-            error("Could not insert comment into comment bank");
+            print_error("Could not insert comment into comment bank");
         }
 
         // now upate the assessment (just the elements, the assessment itself is not updated)
                     $element->elementno = $i;
                     $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                 }
                 $grade = 0; // set to satisfy save to db
                     $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                         }
                     }
                 // now work out the grade...
                     $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
                     $element->grade = $form->grade[$i];
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                     if (empty($form->grade[$i])){
                         $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
                 $element->elementno = $i;
                 $element->grade = $form->grade[$i];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade;
                 // do sanity check
                 $element->elementno = 0;
                 $element->grade = $form->grade[0];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 // now save the adjustment in element one
                 unset($element);
                 $element->elementno = 1;
                 $element->grade = $form->grade[1];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]);
                 break;
                     $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                 }
                 // now work out the grade...
     elseif ($action == 'confirmdelete' ) {
 
         if (empty($aid)) {
-            error("Confirm delete: assessment id missing");
+            print_error("Confirm delete: assessment id missing");
             }
 
         notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")),
     elseif ($action == 'delete' ) {
 
         if (empty($aid)) {
-            error("Delete: submission id missing");
+            print_error("Delete: submission id missing");
             }
 
         print_string("deleting", "workshop");
         $timenow = time();
         // assessment id comes from link or hidden form variable
         if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            error("Assessment : agree assessment failed");
+            print_error("Assessment : agree assessment failed");
             }
         //save time of agreement
         set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id);
         print_heading_with_help(get_string("editacomment", "workshop"), "editingacomment", "workshop");
         // get the comment record...
         if (!$comment = get_record("workshop_comments", "id", $cid)) {
-            error("Edit Comment: Comment not found");
+            print_error("Edit Comment: Comment not found");
             }
         if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) {
-            error("Edit Comment: Assessment not found");
+            print_error("Edit Comment: Assessment not found");
             }
         if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            error("Edit Comment: Submission not found");
+            print_error("Edit Comment: Submission not found");
             }
         ?>
         <form id="gradingform" action="assessments.php" method="post">
         print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop");
         // get assessment record
         if (!$assessmentid = $aid) {
-            error("Assessment id not given");
+            print_error("Assessment id not given");
         }
         $assessment = get_record("workshop_assessments", "id", $assessmentid);
         if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-            error("Submission not found");
+            print_error("Submission not found");
         }
         // get the teacher's assessment first
         if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) {
         $form = (object)$_POST;
 
         if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            error("Unable to insert comment");
+            print_error("Unable to insert comment");
             }
         // save the comment...
         $comment->workshopid = $workshop->id;
         $comment->timecreated   = $timenow;
         $comment->comments   = clean_param($form->comments, PARAM_CLEAN);
         if (!$comment->id = insert_record("workshop_comments", $comment)) {
-            error("Could not insert workshop comment!");
+            print_error("Could not insert workshop comment!");
             }
 
         add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$comment->id");
                         $element->workshopid = $workshop->id;
                         $element->elementno = $key;
                         if (!$element->id = insert_record("workshop_elements", $element)) {
-                            error("Could not insert workshop element!");
+                            print_error("Could not insert workshop element!");
                         }
                     }
                 }
                             $element->weight = $form->weight[$key];
                         }
                         if (!$element->id = insert_record("workshop_elements", $element)) {
-                            error("Could not insert workshop element!");
+                            print_error("Could not insert workshop element!");
                         }
                     }
                 }
                         $element->weight = $form->weight[$key];
                     }
                     if (!$element->id = insert_record("workshop_elements", $element)) {
-                        error("Could not insert workshop element!");
+                        print_error("Could not insert workshop element!");
                     }
                 }
                 break;
                     }
                     $element->maxscore = $j - 1;
                     if (!$element->id = insert_record("workshop_elements", $element)) {
-                        error("Could not insert workshop element!");
+                        print_error("Could not insert workshop element!");
                     }
                 }
                 // let's not fool around here, dump the junk!
                         $element->rubricno = $j;
                         $element->description   = $form->rubric[$i][$j];
                         if (!$element->id = insert_record("workshop_rubrics", $element)) {
-                            error("Could not insert workshop element!");
+                            print_error("Could not insert workshop element!");
                         }
                     }
                 }
     elseif ($action == 'removestockcomment') {
 
         if (empty($aid) or empty($stockcommentid)) {
-            error("Workshop Assessment id and/or Stock Comment id missing");
+            print_error("Workshop Assessment id and/or Stock Comment id missing");
         }
 
         require_capability('mod/workshop:manage', $context);
 
         if (!$assessment = get_record("workshop_assessments", "id", $aid)) {
-            error("workshop assessment is misconfigured");
+            print_error("workshop assessment is misconfigured");
         }
         $form = data_submitted('nomatch'); //Nomatch because we can come from assess.php
 
         // delete the comment from the stock comments table
         if (!delete_records("workshop_stockcomments", "id", $stockcommentid)) {
-            error("Could not remove comment from the comment bank");
+            print_error("Could not remove comment from the comment bank");
         }
 
         // now upate the assessment (just the elements, the assessment itself is not updated)
                     $element->elementno = $i;
                     $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                 }
                 $grade = 0; // set to satisfy save to db
                     $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                         }
                     }
                 // now work out the grade...
                     $element->feedback   = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
                     $element->grade = $form->grade[$i];
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                     if (empty($form->grade[$i])){
                         $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
                 $element->elementno = $i;
                 $element->grade = $form->grade[$i];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade;
                 // do sanity check
                 $element->elementno = 0;
                 $element->grade = $form->grade[0];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 // now save the adjustment in element one
                 unset($element);
                 $element->elementno = 1;
                 $element->grade = $form->grade[1];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]);
                 break;
                     $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                 }
                 // now work out the grade...
     elseif ($action == 'updateassessment') {
 
         if (empty($aid)) {
-            error("Workshop Assessment id missing");
+            print_error("Workshop Assessment id missing");
         }
 
         if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
-            error("workshop assessment is misconfigured");
+            print_error("workshop assessment is misconfigured");
         }
 
         // first get the assignment elements for maxscores and weights...
                     $element->elementno = $i;
                     $element->feedback = clean_param($form->{"feedback_$i"}, PARAM_CLEAN);
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                 }
                 $grade = 0; // set to satisfy save to db
                     $element->feedback   = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                         }
                     }
                 // now work out the grade...
                     $element->feedback   = $form->{"feedback_$i"};
                     $element->grade = clean_param($form->grade[$i], PARAM_CLEAN);
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                     if (empty($form->grade[$i])){
                         $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight];
                 $element->elementno = $i;
                 $element->grade = $form->grade[$i];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade;
                 // do sanity check
                 $element->elementno = 0;
                 $element->grade = $form->grade[0];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 // now save the adjustment in element one
                 unset($element);
                 $element->elementno = 1;
                 $element->grade = $form->grade[1];
                 if (!$element->id = insert_record("workshop_grades", $element)) {
-                    error("Could not insert workshop grade!");
+                    print_error("Could not insert workshop grade!");
                 }
                 $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]);
                 break;
                     $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN);
                     $element->grade = $thegrade;
                     if (!$element->id = insert_record("workshop_grades", $element)) {
-                        error("Could not insert workshop grade!");
+                        print_error("Could not insert workshop grade!");
                     }
                 }
                 // now work out the grade...
 
         // get the comment record...
         if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) {
-            error("Update to Comment failed");
+            print_error("Update to Comment failed");
         }
         if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) {
-            error("Update Comment: Assessment not found");
+            print_error("Update Comment: Assessment not found");
         }
         //save the comment for the assessment...
         if (isset($form->comments)) {
         $form = (object)$_POST;
 
         if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) {
-            error("Update Grading failed");
+            print_error("Update Grading failed");
         }
         //save the comment and grade for the assessment
         if (isset($form->teachercomment)) {
     elseif ($action == 'viewallassessments') {
 
         if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            error("View All Assessments: submission record not found");
+            print_error("View All Assessments: submission record not found");
         }
 
         if ($assessments = workshop_get_assessments($submission)) {
 
     /*************** no man's land **************************************/
     else {
-        error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error("Fatal Error: Unknown Action: ".$action."\n");
     }
     print_footer($course);
 
index 5bc2ad7572c47924e7f79332a67d0df02c0dc2e0..04ae72f12e78eec33e49bef6d6c377bb08cbfea1 100644 (file)
@@ -7,7 +7,7 @@
     $id = required_param('id',PARAM_INT);   // course
 
     if (! $course = get_record("course", "id", $id)) {
-        error("Course ID is incorrect");
+        print_error("Course ID is incorrect");
     }
 
     require_course_login($course);
index 4f52c53a326ff25bf6a0e480c1c9b7fde0a8d98e..86a90b19748a935984eae91318dd021069fb7b71 100644 (file)
@@ -35,7 +35,7 @@ function workshop_context($workshop) {
         $workshop = $workshop->id;
     }
     if (! $cm = get_coursemodule_from_instance('workshop', $workshop)) {
-        error('Course Module ID was incorrect');
+        print_error('Course Module ID was incorrect');
     }
 
     return get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -195,11 +195,11 @@ function workshop_cron () {
                 continue;
             }
             if (! $course = get_record("course", "id", $workshop->course)) {
-                error("Could not find course id $workshop->course");
+                print_error("Could not find course id $workshop->course");
                 continue;
             }
             if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-                error("Course Module ID was incorrect");
+                print_error("Course Module ID was incorrect");
                 continue;
             }
             if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
@@ -294,11 +294,11 @@ function workshop_cron () {
                 continue;
             }
             if (! $course = get_record("course", "id", $workshop->course)) {
-                error("Could not find course id $workshop->course");
+                print_error("Could not find course id $workshop->course");
                 continue;
             }
             if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-                error("Course Module ID was incorrect");
+                print_error("Course Module ID was incorrect");
                 continue;
             }
             if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
@@ -388,11 +388,11 @@ function workshop_cron () {
                 continue;
             }
             if (! $course = get_record("course", "id", $workshop->course)) {
-                error("Could not find course id $workshop->course");
+                print_error("Could not find course id $workshop->course");
                 continue;
             }
             if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-                error("Course Module ID was incorrect");
+                print_error("Course Module ID was incorrect");
                 continue;
             }
             if (! $submissionowner = get_record("user", "id", "$submission->userid")) {
index 58b7d91a45531a0a72f48379f5f573103b0bbd49..7ad7ff13b9b08d77101e96a153b9f959b3875100 100644 (file)
@@ -193,7 +193,7 @@ function workshop_copy_assessment($assessment, $submission, $withfeedback = fals
         $newassessment->teachercomment = addslashes($assessment->teachercomment);
     }
     if (!$newassessment->id = insert_record("workshop_assessments", $newassessment)) {
-        error("Copy Assessment: Could not insert workshop assessment!");
+        print_error("Copy Assessment: Could not insert workshop assessment!");
     }
     
     if ($grades = get_records("workshop_grades", "assessmentid", $assessment->id)) {
@@ -207,7 +207,7 @@ function workshop_copy_assessment($assessment, $submission, $withfeedback = fals
             }
             $grade->assessmentid = $newassessment->id;
             if (!$grade->id = insert_record("workshop_grades", $grade)) {
-                error("Copy Assessment: Could not insert workshop grade!");
+                print_error("Copy Assessment: Could not insert workshop grade!");
             }
         }
     }
@@ -313,10 +313,10 @@ function workshop_count_student_submissions_for_assessment($workshop, $user) {
     global $CFG;
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     
     $timenow = time();
@@ -822,10 +822,10 @@ function workshop_list_all_submissions($workshop, $user) {
     global $CFG;
     
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
                         get_string("comment", "workshop"));
@@ -931,7 +931,7 @@ function workshop_list_all_ungraded_assessments($workshop) {
     global $CFG;
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     
     $table->head = array (get_string("title", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop"));
@@ -971,10 +971,10 @@ function workshop_list_assessed_submissions($workshop, $user) {
     
     $timenow = time();
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     $table->head = array (get_string("title","workshop"), get_string("action","workshop"), 
                     get_string("comment","workshop"));
@@ -1061,10 +1061,10 @@ function workshop_list_peer_assessments($workshop, $user) {
     global $CFG;
     
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
                     get_string("comment", "workshop"));
@@ -1137,10 +1137,10 @@ function workshop_list_self_assessments($workshop, $user) {
     
     $timenow = time();
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
                        get_string("comment", "workshop"));
@@ -1184,10 +1184,10 @@ function workshop_list_student_submissions($workshop, $user) {
     global $CFG;
     
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
 
     $timenow = time();
@@ -1254,7 +1254,7 @@ function workshop_list_student_submissions($workshop, $user) {
                                 $assessment->grade = -1; // set impossible grade
                                 $assessment->timecreated = $yearfromnow;
                                 if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
-                                    error("List Student submissions: Could not insert workshop assessment!");
+                                    print_error("List Student submissions: Could not insert workshop assessment!");
                                 }
                                 $nassessed++;
                                 // is user up to quota?
@@ -1313,13 +1313,13 @@ function workshop_list_submissions_for_admin($workshop, $order) {
     global $CFG, $USER;
     
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (groupmode($course, $cm) == SEPARATEGROUPS) {
         $groupid = get_current_group($course->id);
@@ -1402,7 +1402,7 @@ function workshop_list_submissions_for_admin($workshop, $order) {
                 $title ='';
                 foreach ($assessments as $assessment) {
                     if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
-                        error("Workshop_list_submissions_for_admin: Submission $assessment->submissionid not found!");
+                        print_error("Workshop_list_submissions_for_admin: Submission $assessment->submissionid not found!");
                     }
                     $title .= $submission->title;
                     if ($workshop->agreeassessments and !$assessment->timeagreed and 
@@ -1497,7 +1497,7 @@ function workshop_list_submissions_for_admin($workshop, $order) {
     if ($submissions = workshop_get_student_submissions($workshop, $order)) {
         foreach ($submissions as $submission) {
             if (!$user = get_record("user", "id", $submission->userid)) {
-                error("workshop_list_submissions_for_admin: failure to get user record");
+                print_error("workshop_list_submissions_for_admin: failure to get user record");
             }
             // check group membership, if necessary
             if ($groupid) {
@@ -1559,10 +1559,10 @@ function workshop_list_teacher_assessments_by_user($workshop, $user) {
     
     $timenow = time();
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
 
     $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
@@ -1611,10 +1611,10 @@ function workshop_list_teacher_submissions($workshop, $user) {
     $reassessthreshold = 80;
     
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
     $table->align = array ("left", "left", "left");
@@ -1652,7 +1652,7 @@ function workshop_list_teacher_submissions($workshop, $user) {
                     $assessment->grade = -1; // set impossible grade
                     $assessment->timecreated = $yearfromnow;
                     if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
-                        error("Could not insert workshop assessment!");
+                        print_error("Could not insert workshop assessment!");
                     }
                     $nassessed++;
                     if ($nassessed >= $workshop->ntassessments) {
@@ -1713,10 +1713,10 @@ function workshop_list_unassessed_student_submissions($workshop, $user) {
     
     $timenow = time();
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
         }
 
     if (groupmode($course, $cm) == SEPARATEGROUPS) {
@@ -1783,7 +1783,7 @@ function workshop_list_unassessed_teacher_submissions($workshop, $user) {
     global $CFG;
     
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), 
@@ -1826,7 +1826,7 @@ function workshop_list_ungraded_assessments($workshop, $stype) {
     global $CFG;
     
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"),
@@ -1875,7 +1875,7 @@ function workshop_list_user_submissions($workshop, $user) {
     global $CFG;
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     $timenow = time();
@@ -1935,7 +1935,7 @@ function workshop_phase($workshop, $style='') {
     else {
         return  get_string('phase5'.$style, 'workshop');
     }    
-    error('Something is wrong with the workshop dates');
+    print_error('Something is wrong with the workshop dates');
 }
 
 
@@ -1947,10 +1947,10 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges
     global $CFG, $USER, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS;
     
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if ($assessment) {
         if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
@@ -2647,7 +2647,7 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges
 function workshop_print_assessments_by_user_for_admin($workshop, $user) {
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
@@ -2667,7 +2667,7 @@ function workshop_print_assessments_by_user_for_admin($workshop, $user) {
 function workshop_print_assessments_for_admin($workshop, $submission) {
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
 
     if ($assessments =workshop_get_assessments($submission)) {
@@ -2689,10 +2689,10 @@ function workshop_print_assignment_info($workshop) {
     global $CFG;
 
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     // print standard assignment heading
     print_heading(format_string($workshop->name), "center");
@@ -2750,7 +2750,7 @@ function workshop_print_key($workshop) {
     // print an explaination of the grades
     
     if (!$course = get_record("course", "id", $workshop->course)) {
-        error("Print key: course not found");
+        print_error("Print key: course not found");
     }
     echo "<div class=\"workshopkey\">\n";
     echo "<p><small>{} ".get_string("assessmentby", "workshop", $course->student).";&nbsp;&nbsp;\n";
@@ -2771,10 +2771,10 @@ function workshop_print_league_table($workshop) {
     // print an order table of (student) submissions showing teacher's and student's assessments
     
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Print league table: Course is misconfigured");
+        print_error("Print league table: Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
     }
     // set $groupid if workshop is in SEPARATEGROUPS mode
     if (groupmode($course, $cm) == SEPARATEGROUPS) {
@@ -2816,10 +2816,10 @@ function workshop_print_league_table($workshop) {
         $n = 1;
         while (list($submissionid, $grade) = each($grades)) {
             if (!$submission = get_record("workshop_submissions", "id", $submissionid)) {
-                error("Print league table: submission not found");
+                print_error("Print league table: submission not found");
             }
             if (!$user = get_record("user", "id", $submission->userid)) {
-                error("Print league table: user not found");
+                print_error("Print league table: user not found");
             }
             if ($workshop->anonymous and workshop_is_student($workshop)) {
                 $table->data[] = array(workshop_print_submission_title($workshop, $submission),
@@ -2849,7 +2849,7 @@ function workshop_print_submission($workshop, $submission) {
     global $CFG;
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
     }
     print_simple_box(format_text($submission->description), 'center');
     if ($workshop->nattachments) {
@@ -2885,7 +2885,7 @@ function workshop_print_submission_assessments($workshop, $submission, $type) {
     global $USER, $CFG;
     // Returns the teacher or peer grade and a hyperlinked list of grades for this submission
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     $str = '';
     // get the assessments in grade order, highest first
@@ -2959,7 +2959,7 @@ function workshop_print_submission_title($workshop, $submission) {
 // Arguments are objects
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
     }
     
     if (!$submission->timecreated) { // a "no submission"
@@ -2986,10 +2986,10 @@ function workshop_print_upload_form($workshop) {
     global $CFG;
 
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     $usehtmleditor = can_use_html_editor();
 
@@ -3026,7 +3026,7 @@ function workshop_print_user_assessments($workshop, $user, &$gradinggrade) {
     // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user
 
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
-            error("Course Module ID was incorrect");
+            print_error("Course Module ID was incorrect");
     }
     $gradinggrade = 0;
     $n = 0;
index 000165b4a13d124a0f28d616dfd65b20ae7b4115..505d74dc2c7048b36ca6b4b5df6bf7dc5bb11498 100644 (file)
 
     // get some useful stuff...
     if (! $cm = get_coursemodule_from_id('workshop', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
@@ -66,7 +66,7 @@
 
         require_capability('mod/workshop:manage', $context);
         if (empty($sid)) {
-            error("Admin Amend Title: submission id missing");
+            print_error("Admin Amend Title: submission id missing");
         }
 
         $submission = get_record("workshop_submissions", "id", $sid);
 
         require_capability('mod/workshop:manage', $context);
         if (empty($sid)) {
-            error("Admin clear late flag: submission id missing");
+            print_error("Admin clear late flag: submission id missing");
         }
 
         if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            error("Admin clear late flag: can not get submission record");
+            print_error("Admin clear late flag: can not get submission record");
         }
         if (set_field("workshop_submissions", "late", 0, "id", $sid)) {
             print_heading(get_string("clearlateflag", "workshop")." ".get_string("ok"));
     elseif ($action == 'confirmdelete' ) {
 
         if (empty($sid)) {
-            error("Confirm delete: submission id missing");
+            print_error("Confirm delete: submission id missing");
             }
         notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")),
              "submissions.php?action=delete&amp;id=$cm->id&amp;sid=$sid", "view.php?id=$cm->id#sid=$sid");
     elseif ($action == 'delete' ) {
 
         if (empty($sid)) {
-            error("Delete: submission id missing");
+            print_error("Delete: submission id missing");
         }
 
         if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            error("Admin delete: can not get submission record");
+            print_error("Admin delete: can not get submission record");
         }
 
         // students are only allowed to delete their own submission and only up to the deadline
         if (!(workshop_is_teacher($workshop) or
                (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
                    and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
-            error("You are not authorized to delete this submission");
+            print_error("You are not authorized to delete this submission");
         }
 
         print_string("deleting", "workshop");
 
         require_capability('mod/workshop:manage', $context);
         if (empty($sid)) {
-            error("Admin confirm late flag: submission id missing");
+            print_error("Admin confirm late flag: submission id missing");
         }
         if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            error("Admin confirm late flag: can not get submission record");
+            print_error("Admin confirm late flag: can not get submission record");
         }
 
         notice_yesno(get_string("clearlateflag","workshop")."?",
 
         require_capability('mod/workshop:manage', $context);
         if (empty($sid)) {
-            error("Admin Update Title: submission id missing");
+            print_error("Admin Update Title: submission id missing");
         }
 
         if (set_field("workshop_submissions", "title", $title, "id", $sid)) {
     elseif ($action == 'confirmremoveattachments' ) {
 
         if (empty($sid)) {
-            error("Admin confirm delete: submission id missing");
+            print_error("Admin confirm delete: submission id missing");
         }
         if (!$submission = get_record("workshop_submissions", "id", $sid)) {
-            error("Admin delete: can not get submission record");
+            print_error("Admin delete: can not get submission record");
         }
 
         notice_yesno(get_string("confirmremoveattachments","workshop"),
     elseif ($action == 'editsubmission' ) {
 
         if (empty($sid)) {
-            error("Edit submission: submission id missing");
+            print_error("Edit submission: submission id missing");
         }
         $usehtmleditor = can_use_html_editor();
 
         $submission = get_record("workshop_submissions", "id", $sid);
         print_heading(get_string("editsubmission", "workshop"));
         if ($submission->userid <> $USER->id) {
-            error("Edit submission: Userids do not match");
+            print_error("Edit submission: Userids do not match");
         }
         if (($submission->timecreated < ($timenow - $CFG->maxeditingtime)) and ($workshop->assessmentstart < $timenow)) {
-            error(get_string('notallowed', 'workshop'));
+            print_error('notallowed', 'workshop');
         }
         ?>
         <form id="editform" enctype="multipart/form-data" action="submissions.php" method="post">
         $form = data_submitted();
 
         if (empty($form->sid)) {
-            error("Update submission: submission id missing");
+            print_error("Update submission: submission id missing");
         }
 
         $submission = get_record("workshop_submissions", "id", $form->sid);
         if (!(workshop_is_teacher($workshop) or
                (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
                    and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
-            error("You are not authorized to delete these attachments");
+            print_error("You are not authorized to delete these attachments");
         }
 
         // amend title... just in case they were modified
     elseif ($action == 'showsubmission' ) {
 
         if (empty($sid)) {
-            error("Show submission: submission id missing");
+            print_error("Show submission: submission id missing");
         }
 
         $submission = get_record("workshop_submissions", "id", $sid);
     elseif ($action == 'updatesubmission') {
 
         if (empty($sid)) {
-            error("Update submission: submission id missing");
+            print_error("Update submission: submission id missing");
         }
         $submission = get_record("workshop_submissions", "id", $sid);
 
         if (!(workshop_is_teacher($workshop) or
                (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend)
                    and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) {
-            error("You are not authorized to update your submission");
+            print_error("You are not authorized to update your submission");
         }
 
         // check existence of title
 
     else {
 
-        error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error("Fatal Error: Unknown Action: ".$action."\n");
 
     }
 
index 5d040de7fe97232488c39dafd450c773c86b043a..62a572c34f2c49bf10158b769ea8b24e8d188509 100644 (file)
@@ -8,13 +8,13 @@
 
 
     if (! $cm = get_record("course_modules", "id", $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
@@ -63,7 +63,7 @@
         $newsubmission->late = 1;
     }
     if (!$newsubmission->id = insert_record("workshop_submissions", $newsubmission)) {
-        error("Workshop submission: Failure to create new submission record!");
+        print_error("Workshop submission: Failure to create new submission record!");
     }
     // see if this is a resubmission by looking at the previous submissions...
     if ($submissions and ($workshop->submissionstart > time())) { // ...but not teacher submissions
index 49266aa43380e623128e0313e3c47999d5e3b884..b6beb135da68d81bde7775f27f09177eb007a878 100644 (file)
 
     // get some useful stuff...
     if (! $cm = get_coursemodule_from_id('workshop', $id)) {
-        error("Course Module ID was incorrect");
+        print_error("Course Module ID was incorrect");
     }
     if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+        print_error("Course is misconfigured");
     }
     if (! $workshop = get_record("workshop", "id", $cm->instance)) {
-        error("Course module is incorrect");
+        print_error("Course module is incorrect");
     }
 
     require_login($course->id, false, $cm);
 
     /*************** no man's land **************************************/
     else {
-        error("Fatal Error: Unknown Action: ".$action."\n");
+        print_error("Fatal Error: Unknown Action: ".$action."\n");
     }
 
 
index 81648b2c044505312c19117646188b96e0b242de..93020f543901e5ee4cdfe02f3a808901f9b32706 100644 (file)
     $frameset      = optional_param('frameset', '', PARAM_ALPHA);
 
     if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
-        error("Assessment id is incorrect");
+        print_error("Assessment id is incorrect");
     }
     if (! $submission = get_record('workshop_submissions', 'id', $assessment->submissionid)) {
-        error("Incorrect submission id");
+        print_error("Incorrect submission id");
     }
     if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
-        error("Submission is incorrect");
+        print_error("Submission is incorrect");
     }
     if (! $course = get_record("course", "id", $workshop->course)) {
-        error("Workshop is misconfigured");
+        print_error("Workshop is misconfigured");
     }
     if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
-        error("No coursemodule found");
+        print_error("No coursemodule found");
     }
 
     if (!$redirect) {
index 58b5cf44a30fff3ddd7999cbead7d0ad0197012a..cab3524be3441a4c781810125719ef414e450728 100644 (file)
@@ -9,7 +9,7 @@
 
 /// locate course information
     if (!($course = get_record('course', 'id', $courseid))) {
-        error('Incorrect course id found');
+        print_error('Incorrect course id found');
     }
 
 /// require login to access notes
@@ -24,7 +24,7 @@
 
 /// locate user information
     if (!($user = get_record('user', 'id', $userid))) {
-        error('Incorrect user id found');
+        print_error('Incorrect user id found');
     }
 
 /// build-up form
index dc17409b3ccaf8fae2db5a4cdde28f262d62c7a4..4faceeb6235b950f235384bce676005eaf5557c6 100644 (file)
@@ -8,17 +8,17 @@ $noteid       = required_param('note', PARAM_INT);
 
 // locate note information
 if (!$note = note_load($noteid)) {
-    error('Incorrect note id specified');
+    print_error('Incorrect note id specified');
 }
 
 // locate course information
 if (!$course = get_record('course', 'id', $note->courseid)) {
-    error('Incorrect course id found');
+    print_error('Incorrect course id found');
 }
 
 // locate user information
     if (!$user = get_record('user', 'id', $note->userid)) {
-        error('Incorrect user id found');
+        print_error('Incorrect user id found');
     }
 
 // require login to access notes
@@ -29,7 +29,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id);
 
 // check capability
 if (!has_capability('moodle/notes:manage', $context)) {
-    error('You may not delete this note');
+    print_error('You may not delete this note');
 }
 
 if (data_submitted() && confirm_sesskey()) {
@@ -38,7 +38,7 @@ if (data_submitted() && confirm_sesskey()) {
     if (note_delete($noteid)) {
         add_to_log($note->courseid, 'notes', 'delete', 'index.php?course='.$note->courseid.'&amp;user='.$note->userid . '#note-' . $note->id , 'delete note');
     } else {
-        error('Error occured while deleting post', $returnurl);
+        print_error('Error occured while deleting post', '', $returnurl);
     }
     redirect($returnurl);
 } else {
@@ -60,4 +60,4 @@ if (data_submitted() && confirm_sesskey()) {
     note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD);
     print_footer();
 }
-?>
\ No newline at end of file
+?>
index bf6f36f3714be3722ca0b306864f813dee4c0c52..f6ffe05ecae755ef4bcaca3a472a6222906f9f62 100644 (file)
@@ -8,17 +8,17 @@
 
 /// locate note information
     if (!$note = note_load($noteid)) {
-        error('Incorrect note id specified');
+        print_error('Incorrect note id specified');
     }
 
 /// locate course information
     if (!$course = get_record('course', 'id', $note->courseid)) {
-        error('Incorrect course id found');
+        print_error('Incorrect course id found');
     }
 
 /// locate user information
     if (!$user = get_record('user', 'id', $note->userid)) {
-        error('Incorrect user id found');
+        print_error('Incorrect user id found');
     }
 
 /// require login to access notes
index 3c2832c21a24be6aa2fabd93d4b3ce042968618f..8b82b04e203e46ffede53bf92e3845c63f82f712 100644 (file)
 
 /// locate course information
     if (!$course = get_record('course', 'id', $courseid)) {
-        error('Incorrect course id specified');
+        print_error('Incorrect course id specified');
     }
 
 /// locate user information
     if ($userid) {
         if (!$user = get_record('user', 'id', $userid)) {
-            error('Incorrect user id specified');
+            print_error('Incorrect user id specified');
         }
         $filtertype = 'user';
         $filterselect = $user->id;
index 25e87b64206e71736b72cf4af97eba0e93d1316d..2fc0379b8af1495f1f6c30f2a268ebea0014057f 100644 (file)
@@ -48,7 +48,7 @@
     }
     if ($param->delete && ($questionstomove = count_records("question", "category", $param->delete))){
         if (!$category = get_record("question_categories", "id", $param->delete)) {  // security
-            error("No such category {$param->delete}!", $thispageurl->out());
+            print_error("No such category {$param->delete}!", '', $thispageurl->out());
         }
         $categorycontext = get_context_instance_by_id($category->contextid);
         $qcobject->moveform = new question_move_form($thispageurl,
index c4af0dbcf9203e946a4e775a92bfe7401ebe2b3b..879f353de74e03d95a7c86f04d2c2bce24b58dc7 100644 (file)
@@ -273,7 +273,7 @@ class question_category_object {
             $this->catform->set_data($category);
             $this->catform->display();
         } else {
-            error("Category $categoryid not found");
+            print_error("Category $categoryid not found");
         }
     }
 
@@ -324,11 +324,11 @@ class question_category_object {
         global $CFG;
         question_can_delete_cat($categoryid);
         if (!$category = get_record("question_categories", "id", $categoryid)) {  // security
-            error("No such category $cat!", $this->pageurl->out());
+            print_error("No such category $cat!", '', $this->pageurl->out());
         }
         /// Send the children categories to live with their grandparent
         if (!set_field("question_categories", "parent", $category->parent, "parent", $category->id)) {
-            error("Could not update a child category!", $this->pageurl->out());
+            print_error("Could not update a child category!", '', $this->pageurl->out());
         }
 
         /// Finally delete the category itself
@@ -353,7 +353,7 @@ class question_category_object {
 
     function move_questions($oldcat, $newcat){
         if (!set_field('question', 'category', $newcat, 'category', $oldcat)) {
-            error("Error while moving questions from category '$oldcat' to '$newcat'", $this->pageurl->out());
+            print_error("Error while moving questions from category '$oldcat' to '$newcat'", '', $this->pageurl->out());
         }
     }
 
@@ -363,7 +363,7 @@ class question_category_object {
      */
     function add_category($newparent, $newcategory, $newinfo) {
         if (empty($newcategory)) {
-            error(get_string('categorynamecantbeblank', 'quiz'));
+            print_error('categorynamecantbeblank', 'quiz');
         }
         list($parentid, $contextid) = explode(',', $newparent);
         //moodle_form makes sure select element output is legal no need for further cleaning
@@ -371,7 +371,7 @@ class question_category_object {
 
         if ($parentid) {
             if(!(get_field('question_categories', 'contextid', 'id', $parentid) == $contextid)) {
-                error("Could not insert the new question category '$newcategory' illegal contextid '$contextid'.");
+                print_error("Could not insert the new question category '$newcategory' illegal contextid '$contextid'.");
             }
         }
 
@@ -383,7 +383,7 @@ class question_category_object {
         $cat->sortorder = 999;
         $cat->stamp = make_unique_id_code();
         if (!insert_record("question_categories", $cat)) {
-            error("Could not insert the new question category '$newcategory'");
+            print_error("Could not insert the new question category '$newcategory'");
         } else {
             redirect($this->pageurl->out());//always redirect after successful action
         }
@@ -396,7 +396,7 @@ class question_category_object {
     function update_category($updateid, $newparent, $newname, $newinfo) {
         global $CFG, $QTYPES;
         if (empty($newname)) {
-            error(get_string('categorynamecantbeblank', 'quiz'));
+            print_error('categorynamecantbeblank', 'quiz');
         }
 
         list($parentid, $tocontextid) = explode(',', $newparent);
@@ -425,13 +425,13 @@ class question_category_object {
             if ($oldcat->contextid == $tocontextid){ // not moving contexts
                 $cat->parent = $parentid;
                 if (!update_record("question_categories", $cat)) {
-                    error("Could not update the category '$newname'", $this->pageurl->out());
+                    print_error("Could not update the category '$newname'", '', $this->pageurl->out());
                 } else {
                     redirect($this->pageurl->out());
                 }
             } else {
                 if (!update_record("question_categories", $cat)) {
-                    error("Could not update the category '$newname'", $this->pageurl->out());
+                    print_error("Could not update the category '$newname'", '', $this->pageurl->out());
                 } else {
                     redirect($CFG->wwwroot.'/question/contextmove.php?'.
                                 $this->pageurl->get_query_string(array('cattomove' => $updateid,
@@ -439,7 +439,7 @@ class question_category_object {
                 }
             }
         } else {
-            error("Cannot move the category '$newname'. It is the last in this context.", $this->pageurl->out());
+            print_error("Cannot move the category '$newname'. It is the last in this context.", '', $this->pageurl->out());
         }
     }
 
index 7ee5908835794fa665be7391f8dc968760a7d9fb..83e40122fd88d669ce1ba72c7df7f36533be1211 100644 (file)
@@ -26,7 +26,7 @@
     list($toparent, $contextto) = explode(',', $toparent);
     if (!empty($toparent)){//not top level category, make it a child of $toparent
         if (!$toparent = get_record('question_categories', 'id', $toparent)){
-            error('Invalid category id for parent!', $onerrorurl);
+            print_error('Invalid category id for parent!', '', $onerrorurl);
         }
         $contextto = $toparent->contextid;
     } else {
         $toparent->contextid = $contextto;
     }
     if (!$cattomove = get_record('question_categories', 'id', $cattomove)){
-        error('Invalid category id to move!', $onerrorurl);
+        print_error('Invalid category id to move!', '', $onerrorurl);
     }
     if ($cattomove->contextid == $contextto){
-        error("You shouldn't have got here if you're not moving a category to another context.", $onerrorurl);
+        print_error("You shouldn't have got here if you're not moving a category to another context.", '', $onerrorurl);
     }
     $cattomove->categorylist = question_categorylist($cattomove->id);
 
                     case QUESTION_FILEMOVELINKSONLY :
                         break;
                     default :
-                        error('Invalid action selected!', $onerrorurl);
+                        print_error('Invalid action selected!', '', $onerrorurl);
                 }
                 switch ($urlaction){
                     //now search and replace urls in questions.
         $cat->parent = $toparent->id;
         //set context of category we are moving and all children also!
         if (!execute_sql("UPDATE {$CFG->prefix}question_categories SET contextid = {$contextto->id} WHERE id IN ({$cattomove->categorylist})", false)){
-            error("Could not move the category '$newname' to ".$contexttostring, $onerrorurl);
+            print_error("Could not move the category '$newname' to ".$contexttostring, '', $onerrorurl);
         }
         //finally set the new parent id
         if (!update_record("question_categories", $cat)) {
-            error("Could not update the category '$updatename'", $onerrorurl);
+            print_error("Could not update the category '$updatename'", '', $onerrorurl);
         }
         $thispageurl->remove_params('cattomove', 'toparent', 'totop');
         redirect($CFG->wwwroot."/question/category.php?".$thispageurl->get_query_string(array('cat'=>"{$cattomove->id},{$contextto->id}")));
index 43f04ba1fdbf0e4828be9a1c794a5ac921c966c2..9bcd9dce2cc75bb49c5ea745f6c670a0d32ef742 100644 (file)
@@ -42,7 +42,7 @@ if ($cmid){
     }
     $thispageurl->param('courseid', $COURSE->id);
 } else {
-    error('Need to pass courseid or cmid to this script.');
+    print_error('Need to pass courseid or cmid to this script.');
 }
 $contexts = new question_edit_contexts($thiscontext);
 
@@ -70,7 +70,7 @@ foreach (array_keys($questions) as $id){
     $questions[$id]->context = get_context_instance_by_id($questions[$id]->contextid);
     $thisfilesid =  get_filesdir_from_context($questions[$id]->context);
     if ($fromcoursefilesid && $thisfilesid != $fromcoursefilesid){
-       error('You can\'t use this script to move questions that have files associated with them from different areas.');
+       print_error('You can\'t use this script to move questions that have files associated with them from different areas.');
     } else {
        $fromcoursefilesid =  $thisfilesid;
     }
@@ -136,7 +136,7 @@ if ($contextmoveform->is_cancelled()){
                 case QUESTION_FILEDONOTHING :
                     break;
                 default :
-                    error('Invalid action selected!', $returnurl);
+                    print_error('Invalid action selected!', '', $returnurl);
             }
             //now search and replace urls in questions.
             switch ($urlaction){
@@ -152,7 +152,7 @@ if ($contextmoveform->is_cancelled()){
                 case  QUESTION_FILEDONOTHING :
                     break;
                 default :
-                    error('Invalid action selected!', $returnurl);
+                    print_error('Invalid action selected!', '', $returnurl);
                     break;
             }
 
@@ -161,7 +161,7 @@ if ($contextmoveform->is_cancelled()){
     }
     //now move questions
     if (!execute_sql("UPDATE {$CFG->prefix}question SET category = {$tocat->id} WHERE id IN ({$ids})", false)){
-        error("Could not move the questions {$ids} to category ".$tocat->name, $returnurl);
+        print_error("Could not move the questions {$ids} to category ".$tocat->name, '', $returnurl);
     }
     redirect($returnurl);
 }
@@ -239,4 +239,4 @@ if (count($urls)){
 }
 $contextmoveform->display();
 print_footer($COURSE);
-?>
\ No newline at end of file
+?>
index 7e1b22077d739e68dfe0e46b240d86606bed74ba..5c0ab344371f7bf1bc7a064617e9c3815e51160c 100644 (file)
@@ -21,9 +21,9 @@ function get_module_from_cmid($cmid){
                                     {$CFG->prefix}modules md
                                WHERE cm.id = '$cmid' AND
                                      md.id = cm.module")){
-        error('cmunknown');
+        print_error('cmunknown');
     } elseif (!$modrec =get_record($cmrec->modname, 'id', $cmrec->instance)) {
-        error('cmunknown');
+        print_error('cmunknown');
     }
     $modrec->instance = $modrec->id;
     $modrec->cmid = $cmrec->id;
@@ -85,7 +85,7 @@ function question_can_delete_cat($todelete){
     $contextid = $record->contextid;
     $count = $record->count;
     if ($count < 2) {
-        error('You can\'t delete that category it is the default category for this context.');
+        print_error('You can\'t delete that category it is the default category for this context.');
     } else {
         require_capability('moodle/question:managecategory', get_context_instance_by_id($contextid));
     }
@@ -418,7 +418,7 @@ function question_showbank_actions($pageurl, $cm){
         $category = required_param('category', PARAM_SEQUENCE);
         list($tocategoryid, $contextid) = explode(',', $category);
         if (! $tocategory = get_record('question_categories', 'id', $tocategoryid, 'contextid', $contextid)) {
-            error('Could not find category record');
+            print_error('Could not find category record');
         }
         $tocontext = get_context_instance_by_id($contextid);
         require_capability('moodle/question:add', $tocontext);
@@ -449,7 +449,7 @@ function question_showbank_actions($pageurl, $cm){
                 foreach ($questionids as $questionid){
                     //move question
                     if (!set_field('question', 'category', $tocategory->id, 'id', $questionid)) {
-                        error('Could not update category field');
+                        print_error('Could not update category field');
                     }
                 }
                 redirect($returnurl);
@@ -481,7 +481,7 @@ function question_showbank_actions($pageurl, $cm){
                             record_exists('question_states', 'originalquestion', $questionid)) {
                             if (!set_field('question', 'hidden', 1, 'id', $questionid)) {
                                 question_require_capability_on($questionid, 'edit');
-                                error('Was not able to hide question');
+                                print_error('Was not able to hide question');
                             }
                         } else {
                             delete_question($questionid);
@@ -490,7 +490,7 @@ function question_showbank_actions($pageurl, $cm){
                 }
                 redirect($pageurl->out());
             } else {
-                error("Confirmation string was incorrect");
+                print_error("Confirmation string was incorrect");
             }
 
 
@@ -502,7 +502,7 @@ function question_showbank_actions($pageurl, $cm){
         $unhide = required_param('unhide', PARAM_INT);
         question_require_capability_on($unhide, 'edit');
         if(!set_field('question', 'hidden', 0, 'id', $unhide)) {
-            error("Failed to unhide the question.");
+            print_error("Failed to unhide the question.");
         }
         redirect($pageurl->out());
     }
@@ -680,7 +680,7 @@ function question_edit_setup($edittab, $requirecmid = false, $requirecourseid =
     if (!empty($pagevars['cat'])){
         $catparts = explode(',', $pagevars['cat']);
         if (!$catparts[0] || (FALSE !== array_search($catparts[1], $contextlistarr)) || !count_records_select("question_categories", "id = '".$catparts[0]."' AND contextid = $catparts[1]")) {
-            error(get_string('invalidcategory', 'quiz'));
+            print_error('invalidcategory', 'quiz');
         }
     } else {
         $category = $defaultcategory;
@@ -886,12 +886,12 @@ function require_login_in_context($contextorid = null){
     } else if ($context && ($context->contextlevel == CONTEXT_MODULE)) {
         if ($cm = get_record('course_modules','id',$context->instanceid)) {
             if (!$course = get_record('course', 'id', $cm->course)) {
-                error('Incorrect course.');
+                print_error('Incorrect course.');
             }
             require_course_login($course, true, $cm);
 
         } else {
-            error('Incorrect course module id.');
+            print_error('Incorrect course module id.');
         }
     } else if ($context && ($context->contextlevel == CONTEXT_SYSTEM)) {
         if (!empty($CFG->forcelogin)) {
index 77babbaecb26649bf10fc1fbc54e2bc72bd5aa56..c428fa41a13618519eb3c505cab315e9b816e1bc 100644 (file)
@@ -81,7 +81,7 @@
 
 
         if (! is_readable("format/$from_form->format/format.php")) {
-            error("Format not known ($from_form->format)");
+            print_error("Format not known ($from_form->format)");
         }
 
         // load parent class for import/export
         $qformat->setContexttofile(!empty($from_form->contexttofile));
 
         if (! $qformat->exportpreprocess()) {   // Do anything before that we need to
-            error($txt->exporterror, $thispageurl->out());
+            print_error($txt->exporterror, '', $thispageurl->out());
         }
 
         if (! $qformat->exportprocess()) {         // Process the export data
-            error($txt->exporterror, $thispageurl->out());
+            print_error($txt->exporterror, '', $thispageurl->out());
         }
 
         if (! $qformat->exportpostprocess()) {                    // In case anything needs to be done after
-            error($txt->exporterror, $thispageurl->out());
+            print_error($txt->exporterror, '', $thispageurl->out());
         }
         echo "<hr />";
 
index 841a317bf5c55a9e8446580314bc07c1b5d70cba..549b470be31f7783d768624036f439673b308e38 100644 (file)
@@ -20,9 +20,9 @@
 
     // relative path must start with '/', because of backup/restore!!!
     if (!$relativepath) {
-        error('No valid arguments supplied or incorrect server configuration');
+        print_error('No valid arguments supplied or incorrect server configuration');
     } else if ($relativepath{0} != '/') {
-        error('No valid arguments supplied, path does not start with slash!');
+        print_error('No valid arguments supplied, path does not start with slash!');
     }
 
     $pathname = $CFG->dataroot.'/questionattempt'.$relativepath;
@@ -32,7 +32,7 @@
 
     // check for the right number of directories in the path
     if (count($args) != 3) {
-        error('Invalid arguments supplied');
+        print_error('Invalid arguments supplied');
     }
 
     // security: require login
@@ -81,6 +81,6 @@
     function question_attempt_not_found() {
         global $CFG;
         header('HTTP/1.0 404 not found');
-        error(get_string('filenotfound', 'error'), $CFG->wwwroot); //this is not displayed on IIS??
+        print_error('filenotfound', 'error', $CFG->wwwroot); //this is not displayed on IIS??
     }
 ?>
index a199e9c877e67cb47806c998d5d47d30288daea0..2df8f3fc05420d39d646f7f4d3c67794257f2192 100644 (file)
@@ -294,7 +294,7 @@ class qformat_default {
             $question->timecreated = time();
 
             if (!$question->id = insert_record("question", $question)) {
-                error( get_string('cannotinsert','quiz') );
+                print_error('cannotinsert','quiz');
             }
 
             $this->questionids[] = $question->id;
@@ -384,7 +384,7 @@ class qformat_default {
                 $category->sortorder = 999;
                 $category->stamp = make_unique_id_code();
                 if (!($id = insert_record('question_categories', $category))) {
-                    error( "cannot create new category - $catname" );
+                    print_error( "cannot create new category - $catname" );
                 }
                 $category->id = $id;
                 $parent = $id;
@@ -618,7 +618,7 @@ class qformat_default {
 
         // create a directory for the exports (if not already existing)
         if (! $export_dir = make_upload_directory($this->question_get_export_dir())) {
-              error( get_string('cannotcreatepath','quiz',$export_dir) );
+              print_error('cannotcreatepath', 'quiz', $export_dir);
         }
         $path = $CFG->dataroot.'/'.$this->question_get_export_dir();
 
index efd791587071c5223a91169b6782479c0e9d4707..a326da0aad2704a1cd80d4aa3c1387b24a6b4cf5 100644 (file)
@@ -159,7 +159,7 @@ class qformat_blackboard_6 extends qformat_default {
         if ($this->check_and_create_import_dir($unique_code)) {
             if(is_readable($filename)) {
                 if (!copy($filename, "$temp_dir/bboard.zip")) {
-                    error("Could not copy backup file");
+                    print_error("Could not copy backup file");
                 }
                 if(unzip_file("$temp_dir/bboard.zip", '', false)) {
                     // assuming that the information is in res0001.dat
@@ -178,12 +178,12 @@ class qformat_blackboard_6 extends qformat_default {
                         }
                     }
                     else {
-                        error("Could not find question data file in zip");   
+                        print_error("Could not find question data file in zip");   
                     }
                 }
                 else {
                     print "filename: $filename<br />tempdir: $temp_dir <br />";
-                    error("Could not unzip file.");   
+                    print_error("Could not unzip file.");   
                 }
             }
             else {
@@ -191,7 +191,7 @@ class qformat_blackboard_6 extends qformat_default {
             }
         }
         else {
-            error("Could not create temporary directory");   
+            print_error("Could not create temporary directory");   
         }
     }
         
index f5676bb2e9f9182f47097038582dca4078dd8113..c75578f30ccf8673d90cbcf634ebfe345b7df669 100755 (executable)
@@ -43,7 +43,7 @@ class qformat_coursetestmanager extends qformat_default {
         if ((PHP_OS == "Linux") and !isset($hostname)) {
             // copy the file to a semi-permanent location
             if (! $basedir = make_upload_directory("$COURSE->id")) {
-                error("The site administrator needs to fix the file permissions for the data directory");
+                print_error("The site administrator needs to fix the file permissions for the data directory");
             }
             if (!isset($hostname_access_error)) {
                 $bname=basename($filename);
@@ -101,7 +101,7 @@ class qformat_coursetestmanager extends qformat_default {
             if (PHP_OS == "WINNT") {
             // copy the file to a semi-permanent location
                 if (! $basedir = make_upload_directory("$COURSE->id")) {
-                    error("The site administrator needs to fix the file permissions for the data directory");
+                    print_error("The site administrator needs to fix the file permissions for the data directory");
                 }
                 $bname=basename($filename);
                 $cleanfilename = clean_filename($bname);
@@ -124,7 +124,7 @@ class qformat_coursetestmanager extends qformat_default {
             }
             // print the intermediary form
             if (!$categories = question_category_options($COURSE->id, true)) {
-                error("No categories!");
+                print_error("No categories!");
             }
             print_heading_with_help($strimportquestions, "import", "quiz");
             print_simple_box_start("center");
@@ -264,7 +264,7 @@ class qformat_coursetestmanager extends qformat_default {
             $question->createdby = $USER->id;
             $question->timecreated = time();
             if (!$question->id = insert_record("question", $question)) {
-                error("Could not insert new question!");
+                print_error("Could not insert new question!");
             }
             $this->questionids[] = $question->id;
             // Now to save all the answers and type-specific options
index 42b49ad1734bd610da429ffaf2a354007b800ed9..03765607380bbf9b5bd134ef836d2e3b94a9e61f 100644 (file)
@@ -110,7 +110,7 @@ class qformat_qti2 extends qformat_default {
     function importpreprocess() {
         global $CFG;
 
-        error("Sorry, importing this format is not yet implemented!"
+        print_error("Sorry, importing this format is not yet implemented!", ''
             "$CFG->wwwroot/mod/quiz/import.php?category=$category->id");
     }
 
@@ -241,7 +241,7 @@ function handle_questions_media(&$questions, $path, $courseid) {
 
         // create a directory for the exports (if not already existing)
         if (!$export_dir = make_upload_directory($this->question_get_export_dir().'/'.$this->filename)) {
-              error( get_string('cannotcreatepath','quiz',$export_dir) );
+              print_error('cannotcreatepath', 'quiz', '', $export_dir);
         }
         $path = $CFG->dataroot.'/'.$this->question_get_export_dir().'/'.$this->filename;
 
@@ -274,13 +274,13 @@ function handle_questions_media(&$questions, $path, $courseid) {
         $expout = $smarty->fetch('imsmanifest.tpl');
         $filepath = $path.'/imsmanifest.xml';
         if (empty($expout)) {
-            error("Unkown error - empty imsmanifest.xml");
+            print_error("Unkown error - empty imsmanifest.xml");
         }
         if (!$fh=fopen($filepath,"w")) {
-            error("Cannot open for writing: $filepath");
+            print_error("Cannot open for writing: $filepath");
         }
         if (!fwrite($fh, $expout)) {
-            error("Cannot write exported questions to $filepath");
+            print_error("Cannot write exported questions to $filepath");
         }
         fclose($fh);
 
@@ -295,10 +295,10 @@ function handle_questions_media(&$questions, $path, $courseid) {
             
             $filepath = $path.'/'.$this->get_assesment_item_id($question) . ".xml";
             if (!$fh=fopen($filepath,"w")) {
-                error("Cannot open for writing: $filepath");
+                print_error("Cannot open for writing: $filepath");
             }
             if (!fwrite($fh, $expout)) {
-                error("Cannot write exported questions to $filepath");
+                print_error("Cannot write exported questions to $filepath");
             }
             fclose($fh);
             
@@ -332,13 +332,13 @@ function handle_questions_media(&$questions, $path, $courseid) {
         $this->xml_entitize($result);
         $this->xml_entitize($submiturl);
         if (! $this->exportpreprocess(0, $course)) {   // Do anything before that we need to
-            error("Error occurred during pre-processing!", $redirect);
+            print_error("Error occurred during pre-processing!", '', $redirect);
         }
         if (! $this->exportprocess_quiz($quiz, $questions, $result, $submiturl, $course)) {         // Process the export data
-            error("Error occurred during processing!", $redirect);
+            print_error("Error occurred during processing!", '', $redirect);
         }
         if (! $this->exportpostprocess()) {                    // In case anything needs to be done after
-            error("Error occurred during post-processing!", $redirect);
+            print_error("Error occurred during post-processing!", '', $redirect);
         }
 
     }
@@ -675,7 +675,7 @@ function xml_entitize(&$collection) {
         $path = $CFG->dataroot."/smarty_c";
         if (!is_dir($path)) {
             if (!mkdir($path, $CFG->directorypermissions)) {
-              error("Cannot create path: $path");
+              print_error("Cannot create path: $path");
             }
         }
         $smarty = new Smarty;
index 6557c9688f86250e1a81201e5cd3b904a8e6a342..85cf161c963a422444b4e6cea2c5f8872515e594 100644 (file)
@@ -106,21 +106,21 @@ function qformat_webct_convert_formula($formula) {
             for ($i = 1 ; $deep ; ++$i) {
                 if (!ereg('^(.*[^[:alnum:]_])?([[:alnum:]_]*([)(])([^)(]*[)(]){'.$i.'})$',
                         $splits[0], $regs)) {
-                    error("Parenthesis before ** is not properly started in $splits[0]**");
+                    print_error("Parenthesis before ** is not properly started in $splits[0]**");
                 }
                 if ('(' == $regs[3]) {
                     --$deep;
                 } else if (')' == $regs[3]) {
                     ++$deep;
                 } else {
-                    error("Impossible character $regs[3] detected as parenthesis character");
+                    print_error("Impossible character $regs[3] detected as parenthesis character");
                 }
             }
             $base = $regs[2];
             $splits[0] = $regs[1];
 
         } else {
-            error("Bad base before **: $splits[0]**");
+            print_error("Bad base before **: $splits[0]**");
         }
 
         // Find $exp (similar to above but a little easier)
@@ -136,14 +136,14 @@ function qformat_webct_convert_formula($formula) {
             for ($i = 1 ; $deep ; ++$i) {
                 if (!ereg('^([+-]?[[:alnum:]_]*([)(][^)(]*){'.$i.'}([)(]))(.*)',
                         $splits[1], $regs)) {
-                    error("Parenthesis after ** is not properly closed in **$splits[1]");
+                    print_error("Parenthesis after ** is not properly closed in **$splits[1]");
                 }
                 if (')' == $regs[3]) {
                     --$deep;
                 } else if ('(' == $regs[3]) {
                     ++$deep;
                 } else {
-                    error("Impossible character $regs[3] detected as parenthesis character");
+                    print_error("Impossible character $regs[3] detected as parenthesis character");
                 }
             }
             $exp = $regs[1];
index 36d70334cedd2df7037ee3a10b235c06f3e34e9f..e2e77039e54c17d50dda9a8d40b444b47fa00d5b 100755 (executable)
@@ -996,7 +996,7 @@ class qformat_xml extends qformat_default {
         default:
             // try support by optional plugin
             if (!$data = $this->try_exporting_using_qtypes( $question->qtype, $question )) { 
-                error( "Unsupported question type $question->qtype" );
+                print_error( "Unsupported question type $question->qtype" );
             }
             $expout .= $data;
         }
index ee11b55dee37e7ff714a11fcc3e6a03c501aa347..4d6faeec023035f4d0d16dabdca38344bc6bc4b9 100644 (file)
             if (file_exists($importfile)) {
                 $fileisgood = true;
             } else {
-                error(get_string('uploadproblem', 'moodle', $form->choosefile));
+                print_error('uploadproblem', 'moodle', $form->choosefile);
             }
         } else {
             // must be upload file
             if (!$importfile = $import_form->get_importfile_name()) {
-                error(get_string('uploadproblem', 'moodle'));
+                print_error('uploadproblem', 'moodle');
             }else {
                 $fileisgood = true;
             }
         if ($fileisgood) {
 
             if (! is_readable("format/$form->format/format.php")) {
-                error(get_string('formatnotfound','quiz', $form->format));
+                print_error('formatnotfound','quiz', $form->format);
             }
 
             require_once("format.php");  // Parent class
 
             // Do anything before that we need to
             if (! $qformat->importpreprocess()) {
-                error($txt->importerror, $thispageurl->out());
+                print_error($txt->importerror, '', $thispageurl->out());
             }
 
             // Process the uploaded file
             if (! $qformat->importprocess()) {
-                error($txt->importerror, $thispageurl->out());
+                print_error($txt->importerror, '', $thispageurl->out());
             }
 
             // In case anything needs to be done after
             if (! $qformat->importpostprocess()) {
-                error($txt->importerror, $thispageurl->out());
+                print_error($txt->importerror, '', $thispageurl->out());
             }
 
             echo "<hr />";
index 2246b13fec1369a2576c2b0b9ae312353e351808..06c04779bf11c6e702eb3e916570ce6cbd756bde 100644 (file)
@@ -60,7 +60,7 @@
     }
     // Load the question information
     if (!$questions = get_records('question', 'id', $id)) {
-        error('Could not load question');
+        print_error('Could not load question');
     }
     if (empty($quizid)) {
         $quiz = new cmoptions;
@@ -69,7 +69,7 @@
         require_login($courseid, false);
         $quiz->course = $courseid;
     } else if (!$quiz = get_record('quiz', 'id', $quizid)) {
-        error("Quiz id $quizid does not exist");
+        print_error("Quiz id $quizid does not exist");
     } else {
         require_login($quiz->course, false, get_coursemodule_from_instance('quiz', $quizid, $quiz->course));
     }
     $quiz->questions = $id;
 
     if (!$category = get_record("question_categories", "id", $questions[$id]->category)) {
-        error("This question doesn't belong to a valid category!");
+        print_error("This question doesn't belong to a valid category!");
     }
 
     if (!question_has_capability_on($questions[$id], 'use', $questions[$id]->category)){
-        error("You can't preview these questions!");
+        print_error("You can't preview these questions!");
     }
     if (isset($COURSE)){
         $quiz->course = $COURSE->id;
@@ -98,7 +98,7 @@
 
     // Load the question type specific information
     if (!get_question_options($questions)) {
-        error(get_string('newattemptfail', 'quiz'));
+        print_error('newattemptfail', 'quiz');
     }
 
     // Create a dummy quiz attempt
         // Create an empty session for the question
         if (!$newstates =
          get_question_states($questions, $quiz, $attempt)) {
-            error(get_string('newattemptfail', 'quiz'));
+            print_error('newattemptfail', 'quiz');
         }
         $SESSION->quizpreview->states = array($newstates);
         $states =& $SESSION->quizpreview->states;
index ccede2d6ffe5265b755339650f58bcd2e81d4c67..39fbb7c25dde0a66246f3f6f430db0d70badf946 100644 (file)
@@ -41,7 +41,7 @@ if ($cmid){
     $module = null;
     $cm = null;
 } else {
-    error('Need to pass courseid or cmid to this script.');
+    print_error('Need to pass courseid or cmid to this script.');
 }
 $contexts = new question_edit_contexts($thiscontext);
 
index 1600ccfe71ba66059e722c5d1cf29a83e560b2a4..8ed49822dec75c90f6d58e558fde6faa0351bba0 100644 (file)
             //It depends of the question type !!
             //We get the question first
             if (!$question = get_record("question","id",$state->question)) {
-                error("Can't find the record for question $state->question for which I am trying to restore a state");
+                print_error("Can't find the record for question $state->question for which I am trying to restore a state");
             }
             //Depending on the qtype, we make different recodes
             if ($state->answer) {
index 3f6868c5356e57b09d08bb9fbc3c9e680ab58d49..1cd757d29f17dfe32e2b1c4086cdc1159860709e 100644 (file)
@@ -12,7 +12,7 @@
         $currenttab = '';
     }
     if (!isset($COURSE)) {
-        error('No course specified');
+        print_error('No course specified');
     }
 
     $tabs = array();
index f87c9493e5d9f4f6673ec73a191f06ff0d0f9ec8..a587a684b1071897671f9b48ef45f31f50ae524e 100644 (file)
@@ -247,7 +247,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
             if (  $todo=='create'){
                 if (!$datasetdef->id = insert_record(
                     'question_dataset_definitions', $datasetdef)) {
-                    error("Unable to create dataset $defid");
+                    print_error("Unable to create dataset $defid");
                 } 
            }  
            // Create relation to the dataset:
@@ -256,7 +256,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
            $questiondataset->datasetdefinition = $datasetdef->id;
             if (!insert_record('question_datasets',
                                $questiondataset)) {
-                error("Unable to create relation to dataset $dataset->name $todo");
+                print_error("Unable to create relation to dataset $dataset->name $todo");
             }
             if ($todo=='create'){ // add the items
                 foreach ($dataset->datasetitem as $dataitem ){
@@ -265,7 +265,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
                     $datasetitem->itemnumber = $dataitem->itemnumber ;
                     $datasetitem->value = $dataitem->value ;
                     if (!insert_record('question_dataset_items', $datasetitem)) {
-                        error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
+                        print_error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
                     }
                 }     
             }                                
@@ -322,7 +322,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
                     foreach ($calculatedmessages as $msg) {
                         $errorstring .= $msg . '<br />';
                     }
-                    error($errorstring);
+                    print_error($errorstring);
                 }
 
                 break;
@@ -623,11 +623,11 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
                 // Reuse any previously used record
                 $addeditem->id = $fromform->itemid[$i];
                 if (!update_record('question_dataset_items', $addeditem)) {
-                    error("Error: Unable to update dataset item");
+                    print_error("Error: Unable to update dataset item");
                 }
             } else {
                 if (!insert_record('question_dataset_items', $addeditem)) {
-                    error("Error: Unable to insert dataset item");
+                    print_error("Error: Unable to insert dataset item");
                 }
             }
 
@@ -674,7 +674,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
                         }
                         //pp  echo "<pre>"; print_r( $datasetitem );
                         if (!insert_record('question_dataset_items', $datasetitem)) {
-                            error("Error: Unable to insert new dataset item");
+                            print_error("Error: Unable to insert new dataset item");
                         }                        
                     }
                 }//for number added
@@ -698,7 +698,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
                     $datasetdef->itemcount= $newmaxnumber ;        
                     if (!update_record('question_dataset_definitions',
                                        $datasetdef)) {
-                         error("Error: Unable to update itemcount");
+                         print_error("Error: Unable to update itemcount");
                     }
                 }
             }
@@ -720,7 +720,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
             return sprintf("%.".$regs[4]."f",$nbr);
  
         } else {
-            error("The distribution $regs[1] caused problems");
+            print_error("The distribution $regs[1] caused problems");
         }
         return '';
     }
index 54edd15fc0d98e0fb8814febc35b9e4620cee68d..323ff3633115037041cbc5c50c0908fd16579904 100644 (file)
@@ -36,7 +36,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                                  {$CFG->prefix}question_datasets b
                             WHERE b.question = $question->id
                             AND   a.id = b.datasetdefinition")) {
-            error("Couldn't get the specified dataset for a calculated " .
+            print_error("Couldn't get the specified dataset for a calculated " .
                   "question! (question: {$question->id}");
         }
 
@@ -131,7 +131,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                 require("$CFG->dirroot/question/type/datasetdependent/datasetitems.php");
                 break;
             default:
-                error('Incorrect or no wizard page specified!');
+                print_error('Incorrect or no wizard page specified!');
                 break;
         }
     }
@@ -160,7 +160,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                 $mform =& new question_dataset_dependent_items_form("$submiturl?wizardnow=datasetitems", $question, $regenerate);
                 break;
             default:
-                error('Incorrect or no wizard page specified!');
+                print_error('Incorrect or no wizard page specified!');
                 break;
         }
 
@@ -313,7 +313,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                 $this->save_dataset_items($question, $form);
                 break;
             default:
-                error('Incorrect or no wizard page specified!');
+                print_error('Incorrect or no wizard page specified!');
                 break;
         }
         return $question;
@@ -388,7 +388,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
 
             if (!$datasetdef->id = insert_record(
                     'question_dataset_definitions', $datasetdef)) {
-                error("Unable to create dataset $defid");
+                print_error("Unable to create dataset $defid");
             }
 
             if (0 != $datasetdef->category) {
@@ -419,7 +419,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
             $questiondataset->datasetdefinition = $datasetdef->id;
             if (!insert_record('question_datasets',
                                $questiondataset)) {
-                error("Unable to create relation to dataset $name");
+                print_error("Unable to create relation to dataset $name");
             }
             unset($datasetdefinitions[$defid]);
         }
@@ -468,7 +468,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                    $datasetdef->itemcount =0;
                    if (!$datasetdef->id = insert_record(
                         'question_dataset_definitions', $datasetdef)) {
-                        error("Unable to create dataset $defid");
+                        print_error("Unable to create dataset $defid");
                    }
                    //copy the dataitems
                    $olditems = get_records_sql( // Use number as key!!
@@ -480,7 +480,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                         foreach($olditems as $item ){
                             $item->definition = $datasetdef->id;
                         if (!insert_record('question_dataset_items', $item)) {
-                            error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
+                            print_error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
                         }
                         $itemcount++;
                         }
@@ -496,7 +496,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                 $questiondataset->datasetdefinition = $datasetdef->id;
                 if (!insert_record('question_datasets',
                                    $questiondataset)) {
-                    error("Unable to create relation to dataset $name");
+                    print_error("Unable to create relation to dataset $name");
                 }
                 unset($datasetdefinitions[$defid]);
                 continue;
@@ -504,7 +504,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
             // really new one code similar to save_dataset_definitions()
             if (!$datasetdef->id = insert_record(
                     'question_dataset_definitions', $datasetdef)) {
-                error("Unable to create dataset $defid");
+                print_error("Unable to create dataset $defid");
             }
 
             if (0 != $datasetdef->category) {
@@ -535,7 +535,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
             $questiondataset->datasetdefinition = $datasetdef->id;
             if (!insert_record('question_datasets',
                                $questiondataset)) {
-                error("Unable to create relation to dataset $name");
+                print_error("Unable to create relation to dataset $name");
             }
             unset($datasetdefinitions[$defid]);
         }
@@ -608,7 +608,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
 
                 break;
             default:
-                error('Incorrect or no wizard page specified!');
+                print_error('Incorrect or no wizard page specified!');
                 break;
         }
         return $question;
@@ -633,7 +633,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
                         AND q.datasetdefinition = d.id
                         AND d.id = i.definition
                         AND i.itemnumber = $datasetitem")) {
-            error("Couldn't get the specified dataset for a dataset dependent " .
+            print_error("Couldn't get the specified dataset for a dataset dependent " .
                   "question! (question: {$question->id}, " .
                   "datasetitem: {$datasetitem})");
         }
@@ -642,7 +642,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
     }
 
     function create_virtual_qtype() {
-        error("No virtual question type for question type ".$this->name());
+        print_error("No virtual question type for question type ".$this->name());
     }
 
     function get_virtual_qtype() {
@@ -757,7 +757,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
 
     function create_virtual_nameprefix($nameprefix, $datasetinput) {
         if (!ereg('([0-9]+)' . $this->name() . '$', $nameprefix, $regs)) {
-            error("Wrongly formatted nameprefix $nameprefix");
+            print_error("Wrongly formatted nameprefix $nameprefix");
         }
         $virtualqtype = $this->get_virtual_qtype();
         return $nameprefix . $regs[1] . $virtualqtype->name();
index 8fb0894ec07c39d8c173ad86377c6b87bf62d223..1a2434b55371db203a525bbe75c6101a1c468280 100644 (file)
@@ -50,7 +50,7 @@ class description_qtype extends default_questiontype {
         } else if (!empty($cmoptions->course)) {
             $cmorcourseid = '&amp;courseid='.$cmoptions->course;
         } else {
-            error('Need to provide courseid or cmid to print_question.');
+            print_error('Need to provide courseid or cmid to print_question.');
         }
 
         // For editing teachers print a link to an editing popup window
index 8e90af878f5cb339959173f32b3fbb1a4b161e7d..6ab57da88feeff8d49f07ecaf01713f971d55e04 100644 (file)
@@ -674,7 +674,7 @@ class question_match_qtype extends default_questiontype {
                 $subquestion->questiontext = question_replace_file_links_in_html($subquestion->questiontext, $fromcourseid, $tocourseid, $url, $destination, $subquestionchanged);
                 if ($subquestionchanged){//need to update rec in db
                     if (!update_record('question_match_sub', addslashes_recursive($subquestion))) {
-                        error('Couldn\'t update \'question_match_sub\' record '.$subquestion->id);
+                        print_error('Couldn\'t update \'question_match_sub\' record '.$subquestion->id);
                     }
 
                 }
index 055cfd9f7ff67316cbcddc27d87100a067f29ee9..38bb9fc5f1e25d0aae341dfdbcb697f5d3f8fb96 100644 (file)
@@ -99,7 +99,7 @@ class question_edit_multianswer_form extends question_edit_form {
                             $parsableanswerdef .= 'NUMERICAL:';
                             break;
                         default:
-                            error("questiontype $wrapped->qtype not recognized");
+                            print_error("questiontype $wrapped->qtype not recognized");
                     }
                     $separator= '';
                     foreach ($wrapped->options->answers as $subanswer) {
index cc320d5d7d2a349c2717a7532ede3c0f0f6e3d29..a57c9376e3aa838fc0700ca57283e6940014d431 100644 (file)
@@ -87,7 +87,7 @@ class embedded_cloze_qtype extends default_questiontype {
                              delete_records('question_numerical', 'question', $oldwrappedid);
                             break;
                         default:
-                            error("questiontype $wrapped->qtype not recognized");
+                            print_error("questiontype $wrapped->qtype not recognized");
                     }
                 }
             }
@@ -378,7 +378,7 @@ class embedded_cloze_qtype extends default_questiontype {
                     echo $feedbackimg;
                     break;
                 default:
-                    error("Unable to recognize questiontype ($wrapped->qtype) of
+                    print_error("Unable to recognize questiontype ($wrapped->qtype) of
                            question part $positionkey.");
                     break;
            }
@@ -602,7 +602,7 @@ class embedded_cloze_qtype extends default_questiontype {
             $answer = $exploded[1];
             // $sequence is an ordered array of the question ids.
             if (!$sequence = get_field('question_multianswer', 'sequence', 'question', $state->question)) {
-                error("The cloze question $state->question is missing its options");
+                print_error("The cloze question $state->question is missing its options");
             }
             $sequence = explode(',', $sequence);
             // The id of the current question.
@@ -729,7 +729,7 @@ function qtype_multianswer_extract_question($text) {
             $wrapped->partiallycorrectfeedback = '';
             $wrapped->incorrectfeedback = '';
         } else {
-            error("Cannot identify qtype $answerregs[2]");
+            print_error("Cannot identify qtype $answerregs[2]");
             return false;
         }
 
index 0c1207d1d56f54ace20b2dfcf0843c4b46fdc143..5e0459c50ef7c1e9a3d621a5feeb8de7c36bb5d9 100644 (file)
@@ -656,7 +656,7 @@ class question_multichoice_qtype extends default_questiontype {
         $newoptions->incorrectfeedback = question_replace_file_links_in_html($question->options->incorrectfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
         if ($optionschanged){
             if (!update_record('question_multichoice', addslashes_recursive($newoptions))) {
-                error('Couldn\'t update \'question_multichoice\' record '.$newoptions->id);
+                print_error('Couldn\'t update \'question_multichoice\' record '.$newoptions->id);
             }
         }
         $answerchanged = false;
@@ -664,7 +664,7 @@ class question_multichoice_qtype extends default_questiontype {
             $answer->answer = question_replace_file_links_in_html($answer->answer, $fromcourseid, $tocourseid, $url, $destination, $answerchanged);
             if ($answerchanged){
                 if (!update_record('question_answers', addslashes_recursive($answer))){
-                    error('Couldn\'t update \'question_answers\' record '.$answer->id);
+                    print_error('Couldn\'t update \'question_answers\' record '.$answer->id);
                 }
             }
         }
index d0c2d20f510cdd4671514f8a2c2a77a15183fb39..0c08fdc409221bd414f5298dc9eda5dcc4a5e025 100644 (file)
@@ -344,7 +344,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
                 $min = $answer->answer / $quotient;
                 break;
             default:
-                error("Unknown tolerance type $answer->tolerancetype");
+                print_error("Unknown tolerance type $answer->tolerancetype");
         }
 
         $answer->min = $min;
index e6654ffb5d3932f2a156bf7acd5977caa54a2953..1a8ba309c2c655c5a3e98627e852c3705c411463 100644 (file)
@@ -282,7 +282,7 @@ class default_questiontype {
             $question->modifiedby = $USER->id;
             $question->timemodified = time();
             if (!update_record('question', $question)) {
-                error('Could not update question!');
+                print_error('Could not update question!');
             }
         } else {         // Question is a new one
             if (isset($form->categorymoveto)){
@@ -302,7 +302,7 @@ class default_questiontype {
             $question->timecreated = time();
             $question->timemodified = time();
             if (!$question->id = insert_record('question', $question)) {
-                error('Could not insert new question!');
+                print_error('Could not insert new question!');
             }
         }
 
@@ -316,7 +316,7 @@ class default_questiontype {
         $result = $this->save_question_options($form);
 
         if (!empty($result->error)) {
-            error($result->error);
+            print_error($result->error);
         }
 
         if (!empty($result->notice)) {
@@ -332,7 +332,7 @@ class default_questiontype {
 
         // Give the question a unique version stamp determined by question_hash()
         if (!set_field('question', 'version', question_hash($question), 'id', $question->id)) {
-            error('Could not update question version field');
+            print_error('Could not update question version field');
         }
 
         return $question;
@@ -824,7 +824,7 @@ class default_questiontype {
             $context = get_context_instance(CONTEXT_COURSE, $cmoptions->course);
             $cmorcourseid = '&amp;courseid='.$cmoptions->course;
         } else {
-            error('Need to provide courseid or cmid to print_question.');
+            print_error('Need to provide courseid or cmid to print_question.');
         }
 
         // For editing teachers print a link to an editing popup window
index 17f80e22a53db98f5ed519f34e5cb96ea1b0a992..20c85465798a545a0938e7c9a3fa3bdfa9a16215 100644 (file)
@@ -54,11 +54,11 @@ class random_qtype extends default_questiontype {
         $form->name = '';
         $question = parent::save_question($question, $form, $course);
         if (!$category = get_record('question_categories', 'id', $question->category)) {
-            error('Could retrieve question category');
+            print_error('Could retrieve question category');
         }
         $question->name = $this->question_name($category);
         if (!set_field('question', 'name', $question->name, 'id', $question->id)) {
-            error('Could not update random question name');
+            print_error('Could not update random question name');
         }
         return $question;
     }
index f09e3cc9ebe8dbb84e26abc23dd838777e8a247c..8b111808f534bdf1759463042f2cae13e7918a3a 100644 (file)
@@ -26,11 +26,11 @@ $site = get_site();
 print_header("$strsearch", "$site->fullname" , $navigation, "", "", true, "&nbsp;", navmenu($site));
   
 if (empty($CFG->enableglobalsearch)) {
-    error('Global searching is not enabled.');
+    print_error('Global searching is not enabled.');
 }
 
 if (!isadmin()) {
-    error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+    print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
 } //if
 
 mtrace('<pre>Server Time: '.date('r',time()));
@@ -103,4 +103,4 @@ mtrace("\nFinished checking activity modules.");
 mtrace("<br/><a href='../index.php'>Back to query page</a> or <a href='../indexersplash.php'>Start indexing</a>.");
 mtrace('</pre>');
 print_footer();
-?>
\ No newline at end of file
+?>
index 8fee2b462eaa0788e0ed592418948b9b54f6296c..3da6fc63324d25775816fb360b405c4064984184 100644 (file)
@@ -9,7 +9,7 @@ require_js(array('yui_dom-event', 'yui_connection', 'yui_animation', 'yui_autoco
 require_login();
 
 if (empty($CFG->usetags)) {
-    error(get_string('tagsaredisabled', 'tag'));
+    print_error('tagsaredisabled', 'tag');
 }
 
 $tag_id = optional_param('id', 0, PARAM_INT);
@@ -89,7 +89,7 @@ if ($tagnew = $tagform->get_data()) {
 
         // rename tag if needed
         if (!tag_rename($tag->id, $tagnew->rawname)) {
-            error('Error updating tag record');
+            print_error('Error updating tag record');
         }
     
         //updated related tags
index b683b889d70c8cbda5e5bde92a7f42e36a62b92d..7259e0e654f56e1cf5673593b7f863249ddc0c4d 100644 (file)
@@ -10,7 +10,7 @@ $tag = optional_param('tag', '', PARAM_TAG);
 require_login();
 
 if (empty($CFG->usetags)) {
-    error('Tags are disabled!');
+    print_error('Tags are disabled!');
 }
 
 if (isguestuser()) {
@@ -51,7 +51,7 @@ switch ($action) {
         break;
 
     default:
-        error('No action was specified');
+        print_error('No action was specified');
         break;
 }
 
index 3b78f645ff29a35a44f4db45a1c184749230bd1d..63125fbc867c7caa55d876573b958d07214afaa9 100644 (file)
@@ -10,7 +10,7 @@ if (empty($THEME->chameleonenabled)) {
 
 $id = optional_param('id', SITEID, PARAM_INT);
 if (!$course = get_record('course', 'id', $id)) {
-    error('Incorrect course id');
+    print_error('Incorrect course id');
 }
 
 course_setup($course); // we should not require login here
index 8ef5e4cecbdfbca90ccbec91b02d75f539d117d1..371e66b77c2b2109f00bc5c5be41f0bf61078138 100644 (file)
@@ -23,7 +23,7 @@
 
     if ($choose and confirm_sesskey()) {
         if (!is_dir($CFG->themedir .'/'. $choose)) {
-            error("This theme is not installed!");
+            print_error("This theme is not installed!");
         }
         if (set_config("theme", $choose)) {
             theme_setup($choose);
@@ -47,7 +47,7 @@
             admin_externalpage_print_footer();
             exit;
         } else {
-            error("Could not set the theme!");
+            print_error("Could not set the theme!");
         }
     }
 
index 196b9454a35a5024ad2d3637b43cf6bf4d62f2aa..64995f370162642e78230cfe878c22813c260903 100644 (file)
@@ -9,7 +9,7 @@
     }
 
     if (! $site = get_site()) {
-        error("Site doesn't exist!");
+        print_error("Site doesn't exist!");
     }
 
     require_login();
index fbf6861231f518f6e841772cc6f810ba0237e118..56fafed8485c2b82119ab4e3b33b91d0e3a70fc9 100644 (file)
@@ -7,7 +7,7 @@ $users = optional_param('userid', array(), PARAM_INT); // array of user id
 $contents = optional_param('contents', array(), PARAM_RAW); // array of user notes
 $states = optional_param('states', array(), PARAM_ALPHA); // array of notes states
 if (! $course = get_record('course', 'id', $id)) {
-    error("Course ID is incorrect");
+    print_error("Course ID is incorrect");
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
@@ -18,7 +18,7 @@ require_capability('moodle/notes:manage', $context);
 
 if (!empty($users) && confirm_sesskey()) {
     if (count($users) != count($contents) || count($users) != count($states)) {
-        error('Parameters malformation', $CFG->wwwroot.'/user/index.php?id='.$id);
+        print_error('Parameters malformation', '', $CFG->wwwroot.'/user/index.php?id='.$id);
     }
 
     $note = new object();
index 9dd872ba2b7431dd1eaadc32c7c167cacdde4c26..d237145aff78f9dbfca477163e4cb772793ae1e7 100644 (file)
@@ -12,7 +12,7 @@
     $course = optional_param('course', SITEID, PARAM_INT);   // course id (defaults to Site)
 
     if (!$course = get_record('course', 'id', $course)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
 
     if ($course->id != SITEID) {
@@ -31,7 +31,7 @@
 
     // The user profile we are editing
     if (!$user = get_record('user', 'id', $userid)) {
-        error('User ID was incorrect');
+        print_error('User ID was incorrect');
     }
 
     // Guest can not be edited
@@ -62,7 +62,7 @@
     if ($user->id == $USER->id) {
         //editing own profile - require_login() MUST NOT be used here, it would result in infinite loop!
         if (!has_capability('moodle/user:editownprofile', $systemcontext)) {
-            error('Can not edit own profile, sorry.');
+            print_error('Can not edit own profile, sorry.');
         }
 
     } else {
         $usernew->timemodified = time();
 
         if (!update_record('user', $usernew)) {
-            error('Error updating user record');
+            print_error('Error updating user record');
         }
 
         // pass a true $userold here
         if (! $authplugin->user_update($user, $userform->get_data(false))) {
             // auth update failed, rollback for moodle
             update_record('user', addslashes_object($user));
-            error('Failed to update user data on external auth: '.$user->auth.
+            print_error('Failed to update user data on external auth: '.$user->auth.
                     '. See the server logs for more details.');
         }
 
index 9382a3f1da5bd50fd3fcd1fe65d8acd052be31ee..3be1401a805d234f96c2ceaffaef42126c1a3978 100644 (file)
@@ -13,7 +13,7 @@
     $course = optional_param('course', SITEID, PARAM_INT);   // course id (defaults to Site)
 
     if (!$course = get_record('course', 'id', $course)) {
-        error('Course ID was incorrect');
+        print_error('Course ID was incorrect');
     }
     require_login($course->id);
 
@@ -35,7 +35,7 @@
         // editing existing user
         require_capability('moodle/user:update', $systemcontext);
         if (!$user = get_record('user', 'id', $id)) {
-            error('User ID was incorrect');
+            print_error('User ID was incorrect');
         }
     }
 
             $usernew->confirmed  = 1;
             $usernew->password = hash_internal_user_password($usernew->newpassword);
             if (!$usernew->id = insert_record('user', $usernew)) {
-                error('Error creating user record');
+                print_error('Error creating user record');
             }
         } else {
             if (!update_record('user', $usernew)) {
-                error('Error updating user record');
+                print_error('Error updating user record');
             }
             // pass a true $userold here
             if (! $authplugin->user_update($user, $userform->get_data(false))) {
                 // auth update failed, rollback for moodle
                 update_record('user', addslashes_object($user));
-                error('Failed to update user data on external auth: '.$user->auth.
+                print_error('Failed to update user data on external auth: '.$user->auth.
                         '. See the server logs for more details.');
             }
 
             if (!empty($usernew->newpassword)) {
                 if ($authplugin->can_change_password()) {
                     if (!$authplugin->user_update_password($usernew, $usernew->newpassword)){
-                        error('Failed to update password on external auth: ' . $usernew->auth .
+                        print_error('Failed to update password on external auth: ' . $usernew->auth .
                                 '. See the server logs for more details.');
                     }
                 }
index 33926c2bd0603df05909d1f98d602e1fbc531e56..1054766ac3e5e843e0c982c41631b0679ff39894 100644 (file)
@@ -5,7 +5,7 @@ $id    = required_param('id', PARAM_INT);              // course id
 $users = optional_param('userid', array(), PARAM_INT); // array of user id
 
 if (! $course = get_record('course', 'id', $id)) {
-    error("Course ID is incorrect");
+    print_error("Course ID is incorrect");
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
@@ -17,7 +17,7 @@ $today = time();
 $today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
 if ((count($users) > 0) and ($form = data_submitted()) and confirm_sesskey()) {
     if (count($form->userid) != count($form->extendperiod) || count($form->userid) != count($form->extendbase)) {
-        error('Parameters malformation', $CFG->wwwroot.'/user/index.php?id='.$id);
+        print_error('Parameters malformation', '', $CFG->wwwroot.'/user/index.php?id='.$id);
     }
 
     foreach ($form->userid as $k => $v) {
index e4f3445e3bef3c9a20d8083903b48c4b9482e2b8..08a65dda4dc7d02a630d15a7e3c621346c4b0a6a 100644 (file)
@@ -224,7 +224,7 @@ class user_filter_type {
      * @return string the filtering condition or null if the filter is disabled
      */
     function get_sql_filter($data) {
-        error('Abstract method get_sql_filter() called - must be implemented');
+        print_error('Abstract method get_sql_filter() called - must be implemented');
     }
 
     /**
@@ -233,7 +233,7 @@ class user_filter_type {
      * @return mixed array filter data or false when filter not set
      */
     function check_data($formdata) {
-        error('Abstract method check_data() called - must be implemented');
+        print_error('Abstract method check_data() called - must be implemented');
     }
 
     /**
@@ -241,7 +241,7 @@ class user_filter_type {
      * @param object $mform a MoodleForm object to setup
      */
     function setupForm(&$mform) {
-        error('Abstract method setupForm() called - must be implemented');
+        print_error('Abstract method setupForm() called - must be implemented');
     }
 
     /**
@@ -250,6 +250,6 @@ class user_filter_type {
      * @return string active filter label
      */
     function get_label($data) {
-        error('Abstract method get_label() called - must be implemented');
+        print_error('Abstract method get_label() called - must be implemented');
     }
 }
index 7c74af82f6e8035cb097e11b65054eed61e6b493..faaa4d90b75d5b69cbe82da646b61f9534b42abc 100644 (file)
@@ -8,7 +8,7 @@ $content = optional_param('content', '', PARAM_RAW); // note content
 $state = optional_param('state', '', PARAM_ALPHA); // note publish state
 
 if (! $course = get_record('course', 'id', $id)) {
-    error("Course ID is incorrect");
+    print_error("Course ID is incorrect");
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
index aa9f2a7ae07a64a349cfe3dd25824597a8a51ddc..76a28133990786197ce3d9222539d13ed95209be 100755 (executable)
@@ -5,7 +5,7 @@ $id    = required_param('id', PARAM_INT);              // course id
 $users = optional_param('userid', array(), PARAM_INT); // array of user id
 
 if (! $course = get_record('course', 'id', $id)) {
-    error("Course ID is incorrect");
+    print_error("Course ID is incorrect");
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
index 9739c804967b28e381227b8d2af752c0bef36b3c..257b1c6fb418fffd8305ddb05160c8d35bafb4c6 100644 (file)
 
     if ($contextid) {
         if (! $context = get_context_instance_by_id($contextid)) {
-            error("Context ID is incorrect");
+            print_error("Context ID is incorrect");
         }
         if (! $course = get_record('course', 'id', $context->instanceid)) {
-            error("Course ID is incorrect");
+            print_error("Course ID is incorrect");
         }
     } else {
         if (! $course = get_record('course', 'id', $courseid)) {
-            error("Course ID is incorrect");
+            print_error("Course ID is incorrect");
         }
         if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) {
-            error("Context ID is incorrect");
+            print_error("Context ID is incorrect");
         }
     }
     // not needed anymore
 
     if ($roleid) {
         if (!$currentrole = get_record('role','id',$roleid)) {
-            error('That role does not exist');
+            print_error('That role does not exist');
         }
         $a->number = $totalcount;
         // MDL-12217, use course specific rolename
index 059598e32ef96034e6038adb9792822b85b33e83..3ab50d83fbb87427fbfe2fe81298fb02b0b6988f 100644 (file)
@@ -13,7 +13,7 @@
     $deluser = optional_param('deluser',0,PARAM_INT);
 
     if (!$course = get_record('course','id',$id)) {
-        error("Invalid course id");
+        print_error("Invalid course id");
     }
 
     require_login();
index e200d928968adc3b76233b4ba200404d989367a4..f9b24a9beb7e303713557530931f8f2d3c735d06 100644 (file)
@@ -14,7 +14,7 @@
     if ($agree and confirm_sesskey()) {    // User has agreed
         if (!isguestuser()) {              // Don't remember guests
             if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) {
-                error('Could not save your agreement');
+                print_error('Could not save your agreement');
             }
         }
         $USER->policyagreed = 1;
index 1b889c620807bd4e0158b936bda750e38390d7c5..2852db2a9c6369508612b16551514928e58d22c4 100644 (file)
@@ -154,11 +154,11 @@ class profile_define_base {
         if (empty($data->id)) {
             unset($data->id);
             if (!$data->id = insert_record('user_info_field', $data)) {
-                error('Error creating new field');
+                print_error('Error creating new field');
             }
         } else {
             if (!update_record('user_info_field', $data)) {
-                error('Error updating field');
+                print_error('Error updating field');
             }
         }
     }
@@ -223,11 +223,11 @@ function profile_reorder_categories() {
 function profile_delete_category($id) {
     /// Retrieve the category
     if (!$category = get_record('user_info_category', 'id', $id)) {
-        error('Incorrect category id');
+        print_error('Incorrect category id');
     }
 
     if (!$categories = get_records_select('user_info_category', '', 'sortorder ASC')) {
-        error('Error no categories!?!?');
+        print_error('Error no categories!?!?');
     }
 
     unset($categories[$category->id]);
@@ -262,7 +262,7 @@ function profile_delete_category($id) {
 
     /// Finally we get to delete the category
     if (!delete_records('user_info_category', 'id', $category->id)) {
-        error('Error while deliting category');
+        print_error('Error while deliting category');
     }
     profile_reorder_categories();
     return true;
@@ -273,7 +273,7 @@ function profile_delete_field($id) {
 
     /// Remove any user data associated with this field
     if (!delete_records('user_info_data', 'fieldid', $id)) {
-        error('Error deleting custom field data');
+        print_error('Error deleting custom field data');
     }
 
     /// Try to remove the record from the database
@@ -414,11 +414,11 @@ function profile_edit_category($id, $redirect) {
                 unset($data->id);
                 $data->sortorder = count_records('user_info_category') + 1;
                 if (!insert_record('user_info_category', $data, false)) {
-                    error('There was a problem adding the record to the database');
+                    print_error('There was a problem adding the record to the database');
                 }
             } else {
                 if (!update_record('user_info_category', $data)) {
-                    error('There was a problem updating the record in the database');
+                    print_error('There was a problem updating the record in the database');
                 }
             }
             profile_reorder_categories();
index d406ad3a438991d2ae0ff49fa69b68fd46f7225e..c45074e936fb75860ccb2117150282d4e6ece309 100644 (file)
@@ -43,7 +43,7 @@ class profile_field_base {
      * @param  form  instance of the moodleform class
      */
     function edit_field_add(&$mform) {
-        error('This abstract method must be overriden');
+        print_error('This abstract method must be overriden');
     }
 
     
@@ -96,7 +96,7 @@ class profile_field_base {
         if ($dataid = get_field('user_info_data', 'id', 'userid', $data->userid, 'fieldid', $data->fieldid)) {
             $data->id = $dataid;
             if (!update_record('user_info_data', $data)) {
-                error('Error updating custom profile field!');
+                print_error('Error updating custom profile field!');
             }
         } else {
             insert_record('user_info_data', $data);
index a329943fd00b01ec2fe546eeae0e8dc62fcdce26..545b7e2bd301199a4744b26458c9a97014c8d22b 100644 (file)
@@ -14,7 +14,7 @@
     $filterselect = clean_param($filterselect, PARAM_INT);
 
     if (empty($currenttab) or empty($user) or empty($course)) {
-        //error('You cannot call this script in that way');
+        //print_error('You cannot call this script in that way');
     }
 
     if (($filtertype == 'site' && $filterselect) || ($filtertype=='user' && $filterselect)) {
index bbd03126be75a0c3708be4179e4010d387233fc7..2b535032a8886fe8b9b246b54674ff08c05e81a7 100644 (file)
     }
 
     if (! $user = get_record("user", "id", $id) ) {
-        error("No such user in this course");
+        print_error("No such user in this course");
     }
 
     if (! $course = get_record("course", "id", $course) ) {
-        error("No such course id");
+        print_error("No such course id");
     }
 
 /// Make sure the current user is allowed to see this user
             if (!$gtrue) {
                 $navigation = build_navigation($navlinks);
                 print_header("$strpersonalprofile: ", "$strpersonalprofile: ", $navigation, "", "", true, "&nbsp;", navmenu($course));
-                error(get_string("groupnotamember"), "../course/view.php?id=$course->id");
+                print_error("groupnotamember", '', "../course/view.php?id=$course->id");
             }
         }
     }
index bb5f349815073a2aac0b17fe69f8c3a5151d75b7..a88ae2e34a6b9a774bd4fd7a4c911c1cb26af1ed 100644 (file)
@@ -14,7 +14,7 @@
     require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
 
     if (!$users = get_records("user", "picture", "1", "lastaccess DESC", "id,firstname,lastname")) {
-        error("no users!");
+        print_error("no users!");
     }
 
     $title = get_string("users");
index 161499d8452febd306da0a65e80d905261af2fa3..c0fe0a7babf9059a135e351ef3eb36ff9db179d9 100644 (file)
@@ -10,7 +10,7 @@
     require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
 
     if (!$users = get_records("user", "picture", "1", "lastaccess DESC", "id,firstname,lastname")) {
-        error("no users!");
+        print_error("no users!");
     }
 
     $title = get_string("users");