diff --git a/blog/index.php b/blog/index.php
index 302759c..8d28dbc 100644
--- a/blog/index.php
+++ b/blog/index.php
@@ -118,7 +118,7 @@ if ((empty($courseid) ? true : $courseid == SITEID) && empty($userid)) {
 
 if (!empty($courseid)) {
     if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
     $courseid = $course->id;
diff --git a/course/completion.php b/course/completion.php
index 27150c4..e6ffef8 100644
--- a/course/completion.php
+++ b/course/completion.php
@@ -50,7 +50,7 @@ if ($id) { // editing course
     }
 
     if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        print_error('invalidcourseid', 'error', '', $id);
+        print_error('invalidcourseid');
     }
     require_login($course->id);
     require_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id));
diff --git a/enrol/authorize/index.php b/enrol/authorize/index.php
index 8772dd2..5bdee18 100644
--- a/enrol/authorize/index.php
+++ b/enrol/authorize/index.php
@@ -53,7 +53,7 @@
 
 /// Get course
     if (!($course = $DB->get_record('course', array('id'=>$courseid)))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid', '', '', $courseid);
     }
 
 /// Only SITE users can access to this page
diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php
index e05f5bb..058b1b0 100644
--- a/enrol/authorize/locallib.php
+++ b/enrol/authorize/locallib.php
@@ -268,7 +268,7 @@ function authorize_print_order($orderid)
     }
 
     if (!$course = $DB->get_record('course', array('id'=>$order->courseid))) {
-        print_error('invalidcourseid', 'error', "$CFG->wwwroot/enrol/authorize/index.php", $order->courseid);
+        print_error('invalidcourseid', '', "$CFG->wwwroot/enrol/authorize/index.php");
     }
 
     if (!$user = $DB->get_record('user', array('id'=>$order->userid))) {
diff --git a/grade/edit/outcome/edit.php b/grade/edit/outcome/edit.php
index 9f556e0..1f4d9b7 100644
--- a/grade/edit/outcome/edit.php
+++ b/grade/edit/outcome/edit.php
@@ -55,7 +55,7 @@ if ($id) {
     if ($outcome_rec->courseid) {
         $outcome_rec->standard = 0;
         if (!$course = $DB->get_record('course', array('id' => $outcome_rec->courseid))) {
-            print_error('invalidcourseid', 'error', '', $courseid);
+            print_error('invalidcourseid');
         }
         require_login($course);
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -64,7 +64,7 @@ if ($id) {
     } else {
         if ($courseid) {
             if (!$course = $DB->get_record('course', array('id' => $courseid))) {
-                print_error('invalidcourseid', 'error', '', $courseid);
+                print_error('invalidcourseid');
             }
         }
         $outcome_rec->standard = 1;
diff --git a/grade/edit/outcome/index.php b/grade/edit/outcome/index.php
index 95a865c..45915b2 100644
--- a/grade/edit/outcome/index.php
+++ b/grade/edit/outcome/index.php
@@ -79,7 +79,7 @@ switch ($action) {
         if (empty($outcome->courseid)) {
             require_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM));
         } else if ($outcome->courseid != $courseid) {
-            print_error('invalidcourseid', 'error', '', $courseid);
+            print_error('invalidcourseid');
         }
 
         if (!$outcome->can_delete()) {
diff --git a/grade/edit/scale/edit.php b/grade/edit/scale/edit.php
index fdfe59b..6063906 100644
--- a/grade/edit/scale/edit.php
+++ b/grade/edit/scale/edit.php
@@ -40,7 +40,7 @@ if ($id) {
     if ($scale_rec->courseid) {
         $scale_rec->standard = 0;
         if (!$course = $DB->get_record('course', array('id' => $scale_rec->courseid))) {
-            print_error('invalidcourseid', 'error', '', $courseid);
+            print_error('invalidcourseid');
         }
         require_login($course);
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -49,7 +49,7 @@ if ($id) {
     } else {
         if ($courseid) {
             if (!$course = $DB->get_record('course', array('id' => $courseid))) {
-                print_error('invalidcourseid', 'error', '', $courseid);
+                print_error('invalidcourseid');
             }
         }
         $scale_rec->standard = 1;
diff --git a/grade/edit/scale/index.php b/grade/edit/scale/index.php
index f32b64d..8b5d640 100644
--- a/grade/edit/scale/index.php
+++ b/grade/edit/scale/index.php
@@ -64,7 +64,7 @@ switch ($action) {
         if (empty($scale->courseid)) {
             require_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM));
         } else if ($scale->courseid != $courseid) {
-            print_error('invalidcourseid', 'error', '', $courseid);
+            print_error('invalidcourseid');
         }
 
         if (!$scale->can_delete()) {
diff --git a/grade/export/key.php b/grade/export/key.php
index 9d3512e..cd089d1 100644
--- a/grade/export/key.php
+++ b/grade/export/key.php
@@ -42,16 +42,16 @@ if ($id) {
         $courseid = $key->instance;
 
     } else if ($courseid != $key->instance) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
     if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
 } else {
     if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
     $key = new stdClass();
 }
diff --git a/grade/import/key.php b/grade/import/key.php
index 214eb1a..187859d 100644
--- a/grade/import/key.php
+++ b/grade/import/key.php
@@ -42,16 +42,16 @@ if ($id) {
         $courseid = $key->instance;
 
     } else if ($courseid != $key->instance) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
     if (!$course = $DB->get_record('course', array('id' => $courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
 } else {
     if (!$course = $DB->get_record('course', array('id' => $courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
     $key = new stdClass();
 }
diff --git a/group/autogroup.php b/group/autogroup.php
index e82fcf3..42fc1dc 100644
--- a/group/autogroup.php
+++ b/group/autogroup.php
@@ -20,7 +20,7 @@ $courseid = required_param('courseid', PARAM_INT);
 $PAGE->set_url('/group/autogroup.php', array('courseid' => $courseid));
 
 if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-    print_error('invalidcourseid', 'error', '', $courseid);
+    print_error('invalidcourseid');
 }
 
 // Make sure that the user has permissions to manage groups.
diff --git a/group/delete.php b/group/delete.php
index c62c230..3d5af15 100644
--- a/group/delete.php
+++ b/group/delete.php
@@ -20,7 +20,7 @@ $PAGE->set_url('/group/delete.php', array('courseid'=>$courseid,'groups'=>$group
 
 // Make sure course is OK and user has access to manage groups
 if (!$course = $DB->get_record('course', array('id' => $courseid))) {
-    print_error('invalidcourseid', 'error', '', $courseid);
+    print_error('invalidcourseid');
 }
 require_login($course);
 $context = get_context_instance(CONTEXT_COURSE, $course->id);
diff --git a/group/group.php b/group/group.php
index 484eaff..e35c228 100644
--- a/group/group.php
+++ b/group/group.php
@@ -33,16 +33,16 @@ if ($id) {
         $courseid = $group->courseid;
 
     } else if ($courseid != $group->courseid) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
     if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
 } else {
     if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
     $group = new stdClass();
     $group->courseid = $course->id;
diff --git a/group/grouping.php b/group/grouping.php
index bb9d45d..7d80e65 100644
--- a/group/grouping.php
+++ b/group/grouping.php
@@ -28,19 +28,19 @@ if ($id) {
     if (empty($courseid)) {
         $courseid = $grouping->courseid;
     } else if ($courseid != $grouping->courseid) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     } else {
         $url->param('courseid', $courseid);
     }
 
     if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 
 } else {
     $url->param('courseid', $courseid);
     if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
     $grouping = new stdClass();
     $grouping->courseid = $course->id;
diff --git a/lib/grouplib.php b/lib/grouplib.php
index e9f631d..708d242 100644
--- a/lib/grouplib.php
+++ b/lib/grouplib.php
@@ -378,7 +378,7 @@ function groups_get_activity_groupmode($cm, $course=null) {
         $course = $COURSE;
     } else {
         if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
-            print_error('invalidcourseid', 'error', '', $cm->course);
+            print_error('invalidcourseid');
         }
     }
 
@@ -755,4 +755,4 @@ function _group_verify_activegroup($courseid, $groupmode, $groupingid, array $al
             $SESSION->activegroup[$courseid][$groupmode][$groupingid] = 0;
         }
     }
-}
+}
\ No newline at end of file
diff --git a/login/change_password.php b/login/change_password.php
index 036a8a4..2608079 100644
--- a/login/change_password.php
+++ b/login/change_password.php
@@ -55,7 +55,7 @@ $strparticipants = get_string('participants');
 $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 
 if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 // require proper login; guest user can not change password
diff --git a/message/edit.php b/message/edit.php
index bde1420..a231b25 100644
--- a/message/edit.php
+++ b/message/edit.php
@@ -37,7 +37,7 @@ $url->param('course', $course);
 $PAGE->set_url($url);
 
 if (!$course = $DB->get_record('course', array('id' => $course))) {
-    print_error('invalidcourseid', 'error', '', $course);
+    print_error('invalidcourseid');
 }
 
 if ($course->id != SITEID) {
diff --git a/mod/assignment/index.php b/mod/assignment/index.php
index 665ff6a..71eb023 100644
--- a/mod/assignment/index.php
+++ b/mod/assignment/index.php
@@ -7,7 +7,7 @@ require_once($CFG->libdir.'/gradelib.php');
 $id = required_param('id', PARAM_INT);   // course
 
 if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $course);
+    print_error('invalidcourseid');
 }
 
 require_course_login($course);
diff --git a/mod/chat/gui_basic/index.php b/mod/chat/gui_basic/index.php
index 02d5d06..5654214 100644
--- a/mod/chat/gui_basic/index.php
+++ b/mod/chat/gui_basic/index.php
@@ -33,7 +33,7 @@ if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
 }
 
 if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
-    print_error('invalidcourseid', 'error', '', $chat->course);
+    print_error('invalidcourseid');
 }
 
 if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
diff --git a/mod/chat/gui_header_js/chatinput.php b/mod/chat/gui_header_js/chatinput.php
index 0ede88b..a228a92 100644
--- a/mod/chat/gui_header_js/chatinput.php
+++ b/mod/chat/gui_header_js/chatinput.php
@@ -16,7 +16,7 @@ if (!$chat = $DB->get_record('chat', array('id'=>$chatid))) {
 }
 
 if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
-    print_error('invalidcourseid', 'error', '', $chat->course);
+    print_error('invalidcourseid');
 }
 
 if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php
index 7a5af99..43d0f0b 100644
--- a/mod/chat/gui_header_js/index.php
+++ b/mod/chat/gui_header_js/index.php
@@ -17,7 +17,7 @@ if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
 }
 
 if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
-    print_error('invalidcourseid', 'error', '', $chat->course);
+    print_error('invalidcourseid');
 }
 
 if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
diff --git a/mod/chat/gui_header_js/insert.php b/mod/chat/gui_header_js/insert.php
index ed37858..6b842d2 100644
--- a/mod/chat/gui_header_js/insert.php
+++ b/mod/chat/gui_header_js/insert.php
@@ -17,7 +17,7 @@ if (!$chat = $DB->get_record('chat', array('id'=>$chatuser->chatid))) {
 }
 
 if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
-    print_error('invalidcourseid', 'error', '', $chat->course);
+    print_error('invalidcourseid');
 }
 
 if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
@@ -73,4 +73,4 @@ if ($chatuser->version == 'header_js') {
     $PAGE->requires->js_init_call('M.mod_chat_header.init_insert_nojsupdated', array($forcerefreshasap), true, $module);
 }
 
-redirect('../empty.php');
+redirect('../empty.php');
\ No newline at end of file
diff --git a/mod/chat/gui_header_js/jsupdate.php b/mod/chat/gui_header_js/jsupdate.php
index 64716d4..cbff840 100644
--- a/mod/chat/gui_header_js/jsupdate.php
+++ b/mod/chat/gui_header_js/jsupdate.php
@@ -25,7 +25,7 @@ if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
 
 //Get the minimal course
 if (!$course = $DB->get_record('course', array('id'=>$chatuser->course))) {
-    print_error('invalidcourseid', 'error', '', $chat->course);
+    print_error('invalidcourseid');
 }
 
 //Get the user theme and enough info to be used in chat_format_message() which passes it along to
diff --git a/mod/chat/gui_header_js/jsupdated.php b/mod/chat/gui_header_js/jsupdated.php
index 1cad7d8..9a98185 100644
--- a/mod/chat/gui_header_js/jsupdated.php
+++ b/mod/chat/gui_header_js/jsupdated.php
@@ -50,7 +50,7 @@ if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
 
 //Get the minimal course
 if (!$course = $DB->get_record('course', array('id'=>$chatuser->course))) {
-    print_error('invalidcourseid', 'error', '', $chat->course);
+    print_error('invalidcourseid');
 }
 
 //Get the user theme and enough info to be used in chat_format_message() which passes it along to
diff --git a/mod/chat/gui_header_js/users.php b/mod/chat/gui_header_js/users.php
index 753b540..246417c 100644
--- a/mod/chat/gui_header_js/users.php
+++ b/mod/chat/gui_header_js/users.php
@@ -16,7 +16,7 @@ if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
 
 //Get the minimal course
 if (!$course = $DB->get_record('course', array('id'=>$chatuser->course))) {
-    print_error('invalidcourseid', 'error', '', $chat->course);
+    print_error('invalidcourseid');
 }
 
 //Get the user theme and enough info to be used in chat_format_message() which passes it along to
@@ -89,7 +89,7 @@ foreach ($chatusers as $chatuser) {
     $min = $min < 10 ? '0'.$min : $min;
     $sec = $sec < 10 ? '0'.$sec : $sec;
     $idle = $min.':'.$sec;
-
+    
 
     $row = array();
     $row[0] = $OUTPUT->user_picture($chatuser, array('courseid'=>$courseid, 'popup'=>true));
diff --git a/mod/chat/gui_sockets/index.php b/mod/chat/gui_sockets/index.php
index 907e489..4a5de8b 100644
--- a/mod/chat/gui_sockets/index.php
+++ b/mod/chat/gui_sockets/index.php
@@ -17,7 +17,7 @@ if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
 }
 
 if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
-    print_error('invalidcourseid', 'error', '', $courseid);
+    print_error('invalidcourseid');
 }
 
 if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
diff --git a/mod/chat/index.php b/mod/chat/index.php
index 2309ea2..fbc6d37 100644
--- a/mod/chat/index.php
+++ b/mod/chat/index.php
@@ -8,7 +8,7 @@ $id = required_param('id', PARAM_INT);   // course
 $PAGE->set_url('/mod/chat/index.php', array('id'=>$id));
 
 if (! $course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 require_course_login($course);
diff --git a/mod/choice/index.php b/mod/choice/index.php
index 484a85f..e63b876 100644
--- a/mod/choice/index.php
+++ b/mod/choice/index.php
@@ -8,7 +8,7 @@
     $PAGE->set_url('/mod/choice/index.php', array('id'=>$id));
 
     if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        print_error('invalidcourseid', 'error', '', $id);
+        print_error('invalidcourseid');
     }
 
     require_course_login($course);
diff --git a/mod/data/index.php b/mod/data/index.php
index 77c80ed..ba0c179 100644
--- a/mod/data/index.php
+++ b/mod/data/index.php
@@ -31,7 +31,7 @@ $id = required_param('id', PARAM_INT);   // course
 $PAGE->set_url('/mod/data/index.php', array('id'=>$id));
 
 if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 require_course_login($course);
diff --git a/mod/feedback/analysis.php b/mod/feedback/analysis.php
index 2c1961c..da86ecf 100644
--- a/mod/feedback/analysis.php
+++ b/mod/feedback/analysis.php
@@ -64,7 +64,7 @@ if ($courseid AND $courseid != SITEID) {
         require_course_login($course2); //this overwrites the object $course :-(
         $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
     } else {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 }
 
diff --git a/mod/feedback/complete.php b/mod/feedback/complete.php
index 98c005b..e6fe6cd 100644
--- a/mod/feedback/complete.php
+++ b/mod/feedback/complete.php
@@ -132,7 +132,7 @@ if ($courseid AND $courseid != SITEID) {
         require_course_login($course2); //this overwrites the object $course :-(
         $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
     } else {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 }
 
diff --git a/mod/feedback/index.php b/mod/feedback/index.php
index abe1579..860a196 100644
--- a/mod/feedback/index.php
+++ b/mod/feedback/index.php
@@ -32,7 +32,7 @@ $url = new moodle_url('/mod/feedback/index.php', array('id'=>$id));
 $PAGE->set_url($url);
 
 if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
diff --git a/mod/feedback/view.php b/mod/feedback/view.php
index 7ab09f5..34cfd7f 100644
--- a/mod/feedback/view.php
+++ b/mod/feedback/view.php
@@ -94,7 +94,7 @@ if ($courseid AND $courseid != SITEID) {
         require_course_login($course2); //this overwrites the object $course :-(
         $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
     } else {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 }
 
diff --git a/mod/forum/index.php b/mod/forum/index.php
index 18f673f..c15b40b 100644
--- a/mod/forum/index.php
+++ b/mod/forum/index.php
@@ -38,7 +38,7 @@ $PAGE->set_url($url);
 
 if ($id) {
     if (! $course = $DB->get_record('course', array('id' => $id))) {
-        print_error('invalidcourseid', 'error', '', $id);
+        print_error('invalidcourseid');
     }
 } else {
     $course = get_site();
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index ac08fa9..7e0b818 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -4972,7 +4972,7 @@ function forum_user_can_post($forum, $discussion, $user=NULL, $cm=NULL, $course=
     if (!$course) {
         debugging('missing course', DEBUG_DEVELOPER);
         if (!$course = $DB->get_record('course', array('id' => $forum->course))) {
-            print_error('invalidcourseid', 'error', '', $forum->course);
+            print_error('invalidcourseid');
         }
     }
 
diff --git a/mod/forum/markposts.php b/mod/forum/markposts.php
index 450f9b9..a47f049 100644
--- a/mod/forum/markposts.php
+++ b/mod/forum/markposts.php
@@ -45,7 +45,7 @@ if (! $forum = $DB->get_record("forum", array("id" => $f))) {
 }
 
 if (! $course = $DB->get_record("course", array("id" => $forum->course))) {
-    print_error('invalidcourseid', 'error', '', $forum->course);
+    print_error('invalidcourseid');
 }
 
 if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
diff --git a/mod/forum/post.php b/mod/forum/post.php
index a5e217a..f3fd922 100644
--- a/mod/forum/post.php
+++ b/mod/forum/post.php
@@ -74,7 +74,7 @@ if (!isloggedin() or isguestuser()) {
         }
     }
     if (! $course = $DB->get_record('course', array('id' => $forum->course))) {
-        print_error('invalidcourseid', 'error', '', $forum->course);
+        print_error('invalidcourseid');
     }
 
     if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { // For the logs
@@ -101,7 +101,7 @@ if (!empty($forum)) {      // User is starting a new discussion in a forum
         print_error('invalidforumid', 'forum');
     }
     if (! $course = $DB->get_record("course", array("id" => $forum->course))) {
-        print_error('invalidcourseid', 'error', '', $forum->course);
+        print_error('invalidcourseid');
     }
     if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
         print_error("invalidcoursemodule");
@@ -166,7 +166,7 @@ if (!empty($forum)) {      // User is starting a new discussion in a forum
         print_error('invalidforumid', 'forum');
     }
     if (! $course = $DB->get_record("course", array("id" => $discussion->course))) {
-        print_error('invalidcourseid', 'error', '', $discussion->course);
+        print_error('invalidcourseid');
     }
     if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
         print_error('invalidcoursemodule');
@@ -247,7 +247,7 @@ if (!empty($forum)) {      // User is starting a new discussion in a forum
         print_error('invalidforumid', 'forum');
     }
     if (! $course = $DB->get_record("course", array("id" => $discussion->course))) {
-        print_error('invalidcourseid', 'error', '', $discussion->course);
+        print_error('invalidcourseid');
     }
     if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
         print_error('invalidcoursemodule');
@@ -295,7 +295,7 @@ if (!empty($forum)) {      // User is starting a new discussion in a forum
         print_error('invalidcoursemodule');
     }
     if (!$course = $DB->get_record('course', array('id' => $forum->course))) {
-        print_error('invalidcourseid', 'error', '', $forum->course);
+        print_error('invalidcourseid');
     }
 
     require_login($course, false, $cm);
diff --git a/mod/forum/search.php b/mod/forum/search.php
index 80ffe97..9913fac 100644
--- a/mod/forum/search.php
+++ b/mod/forum/search.php
@@ -107,7 +107,7 @@ if ($search) {
 }
 
 if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 require_course_login($course);
diff --git a/mod/glossary/index.php b/mod/glossary/index.php
index f8cf5a6..4eef6df 100644
--- a/mod/glossary/index.php
+++ b/mod/glossary/index.php
@@ -13,7 +13,7 @@ $id = required_param('id', PARAM_INT);   // course
 $PAGE->set_url('/mod/glossary/index.php', array('id'=>$id));
 
 if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 require_course_login($course);
diff --git a/mod/glossary/view.php b/mod/glossary/view.php
index 1f8143b..fe16b5e 100644
--- a/mod/glossary/view.php
+++ b/mod/glossary/view.php
@@ -37,7 +37,7 @@ if (!empty($id)) {
         print_error('invalidid', 'glossary');
     }
     if (! $course = $DB->get_record("course", array("id"=>$glossary->course))) {
-        print_error('invalidcourseid', 'error', '', $glossary->course);
+        print_error('invalidcourseid');
     }
     if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id)) {
         print_error('invalidcoursemodule');
diff --git a/mod/lesson/index.php b/mod/lesson/index.php
index a11906d..048f3ff 100644
--- a/mod/lesson/index.php
+++ b/mod/lesson/index.php
@@ -33,7 +33,7 @@ $id = required_param('id', PARAM_INT);   // course
 $PAGE->set_url('/mod/lesson/index.php', array('id'=>$id));
 
 if (!$course = $DB->get_record("course", array("id" => $id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 require_login($course);
@@ -119,4 +119,4 @@ foreach ($lessons as $lesson) {
     }
 }
 echo html_writer::table($table);
-echo $OUTPUT->footer();
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/mod/quiz/addrandom.php b/mod/quiz/addrandom.php
index e465a0c..c7f832c 100644
--- a/mod/quiz/addrandom.php
+++ b/mod/quiz/addrandom.php
@@ -42,7 +42,7 @@ $scrollpos = optional_param('scrollpos', 0, PARAM_INT);
 
 // Get the course object and related bits.
 if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
-    print_error('invalidcourseid', 'error', '', $quiz->course);
+    print_error('invalidcourseid');
 }
 //you need mod/quiz:manage in addition to question capabilities to access this page.
 require_capability('mod/quiz:manage', $contexts->lowest());
diff --git a/mod/quiz/index.php b/mod/quiz/index.php
index aa96b10..926fa2e 100644
--- a/mod/quiz/index.php
+++ b/mod/quiz/index.php
@@ -30,7 +30,7 @@ require_once("locallib.php");
 $id = required_param('id', PARAM_INT);
 $PAGE->set_url('/mod/quiz/index.php', array('id'=>$id));
 if (!$course = $DB->get_record('course', array('id' => $id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 $coursecontext = get_context_instance(CONTEXT_COURSE, $id);
 require_login($course->id);
diff --git a/mod/quiz/report.php b/mod/quiz/report.php
index 37b8ce3..4ebb4c2 100644
--- a/mod/quiz/report.php
+++ b/mod/quiz/report.php
@@ -49,7 +49,7 @@ if ($id) {
         print_error('invalidquizid', 'quiz');
     }
     if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
-        print_error('invalidcourseid', 'error', '', $quiz->course);
+        print_error('invalidcourseid');
     }
     if (!$cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
         print_error('invalidcoursemodule');
diff --git a/mod/quiz/view.php b/mod/quiz/view.php
index 050150c..f21f3d9 100644
--- a/mod/quiz/view.php
+++ b/mod/quiz/view.php
@@ -45,7 +45,7 @@ if ($id) {
         print_error('invalidquizid', 'quiz');
     }
     if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
-        print_error('invalidcourseid', 'error', '', $quiz->course);
+        print_error('invalidcourseid');
     }
     if (!$cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
         print_error('invalidcoursemodule');
diff --git a/mod/scorm/index.php b/mod/scorm/index.php
index 4e02046..eea68a2 100644
--- a/mod/scorm/index.php
+++ b/mod/scorm/index.php
@@ -23,7 +23,7 @@ $PAGE->set_url('/mod/scorm/index.php', array('id'=>$id));
 
 if (!empty($id)) {
     if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        print_error('invalidcourseid', 'error', '', $id);
+        print_error('invalidcourseid');
     }
 } else {
     print_error('missingparameter');
@@ -113,4 +113,4 @@ echo "<br />";
 
 echo html_writer::table($table);
 
-echo $OUTPUT->footer();
+echo $OUTPUT->footer();
\ No newline at end of file
diff --git a/mod/survey/index.php b/mod/survey/index.php
index 2e2bb0d..6154acf 100644
--- a/mod/survey/index.php
+++ b/mod/survey/index.php
@@ -8,7 +8,7 @@
     $PAGE->set_url('/mod/survey/index.php', array('id'=>$id));
 
     if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        print_error('invalidcourseid', 'error', '', $id);
+        print_error('invalidcourseid');
     }
 
     require_course_login($course);
diff --git a/mod/wiki/index.php b/mod/wiki/index.php
index 0a4ac4f..7f13ee2 100644
--- a/mod/wiki/index.php
+++ b/mod/wiki/index.php
@@ -38,7 +38,7 @@ $id = required_param('id', PARAM_INT); // course
 $PAGE->set_url('/mod/wiki/index.php', array('id' => $id));
 
 if (!$course = $DB->get_record('course', array('id' => $id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 require_login($course->id, true);
diff --git a/mod/wiki/search.php b/mod/wiki/search.php
index f62b868..518195f 100644
--- a/mod/wiki/search.php
+++ b/mod/wiki/search.php
@@ -32,7 +32,7 @@ $searchcontent = optional_param('searchwikicontent', 0, PARAM_INT);
 $cmid = optional_param('cmid', 0, PARAM_INT);
 
 if (!$course = $DB->get_record('course', array('id' => $courseid))) {
-    print_error('invalidcourseid', 'error', '', $courseid);
+    print_error('invalidcourseid');
 }
 if (!$cm = get_coursemodule_from_id('wiki', $cmid)) {
     print_error('invalidcoursemodule');
diff --git a/notes/delete.php b/notes/delete.php
index 5d2dcf9..f69f103 100644
--- a/notes/delete.php
+++ b/notes/delete.php
@@ -15,7 +15,7 @@ if (!$note = note_load($noteid)) {
 
 // locate course information
 if (!$course = $DB->get_record('course', array('id'=>$note->courseid))) {
-    print_error('invalidcourseid', 'error', '', $note->courseid);
+    print_error('invalidcourseid');
 }
 
 // locate user information
diff --git a/notes/edit.php b/notes/edit.php
index b6ce171..47aeb2a 100644
--- a/notes/edit.php
+++ b/notes/edit.php
@@ -38,7 +38,7 @@ $PAGE->set_url($url);
 
 /// locate course information
 if (!$course = $DB->get_record('course', array('id'=>$note->courseid))) {
-    print_error('invalidcourseid', 'error', '', $note->courseid);
+    print_error('invalidcourseid');
 }
 
 /// locate user information
diff --git a/question/editlib.php b/question/editlib.php
index 8c41a26..14368c3 100644
--- a/question/editlib.php
+++ b/question/editlib.php
@@ -1719,7 +1719,7 @@ function require_login_in_context($contextorid = null){
     } else if ($context && ($context->contextlevel == CONTEXT_MODULE)) {
         if ($cm = $DB->get_record('course_modules',array('id' =>$context->instanceid))) {
             if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
-                print_error('invalidcourseid', 'error', '', $cm->course);
+                print_error('invalidcourseid');
             }
             require_course_login($course, true, $cm);
 
diff --git a/report/progress/index.php b/report/progress/index.php
index 7ddf0da..bee7249 100644
--- a/report/progress/index.php
+++ b/report/progress/index.php
@@ -32,7 +32,7 @@ define('COMPLETION_REPORT_PAGE', 25);
 $id = required_param('course',PARAM_INT);
 $course = $DB->get_record('course',array('id'=>$id));
 if (!$course) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 $context = context_course::instance($course->id);
 
diff --git a/report/stats/index.php b/report/stats/index.php
index 57871b9..8238cde 100644
--- a/report/stats/index.php
+++ b/report/stats/index.php
@@ -48,7 +48,7 @@ if ($mode == STATS_MODE_RANKED) {
 }
 
 if (!$course = $DB->get_record("course", array("id"=>$courseid))) {
-    print_error("invalidcourseid", 'error', '', $courseid);
+    print_error("invalidcourseid");
 }
 
 if (!empty($userid)) {
diff --git a/repository/filepicker.php b/repository/filepicker.php
index 6043a6c..68aee10 100644
--- a/repository/filepicker.php
+++ b/repository/filepicker.php
@@ -71,7 +71,7 @@ $user_context = get_context_instance(CONTEXT_USER, $USER->id);
 
 $PAGE->set_context($user_context);
 if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
-    print_error('invalidcourseid', 'error', '', $courseid);
+    print_error('invalidcourseid');
 }
 $PAGE->set_course($course);
 
diff --git a/repository/manage_instances.php b/repository/manage_instances.php
index 0410d98..5b5d1c8 100644
--- a/repository/manage_instances.php
+++ b/repository/manage_instances.php
@@ -75,7 +75,7 @@ if ($context->contextlevel == CONTEXT_COURSE) {
     $pagename = get_string("repositorycourse",'repository');
 
     if ( !$course = $DB->get_record('course', array('id'=>$context->instanceid))) {
-        print_error('invalidcourseid', 'error', '', $context->instanceid);
+        print_error('invalidcourseid');
     }
     require_login($course, false);
     // If the user is allowed to edit this course, he's allowed to edit list of repository instances
@@ -134,7 +134,7 @@ echo $OUTPUT->header();
 
 if ($context->contextlevel == CONTEXT_USER) {
     if ( !$course = $DB->get_record('course', array('id'=>$usercourseid))) {
-        print_error('invalidcourseid', 'error', '', $courseid);
+        print_error('invalidcourseid');
     }
 }
 
diff --git a/user/addnote.php b/user/addnote.php
index db36fee..5a0d0a8 100644
--- a/user/addnote.php
+++ b/user/addnote.php
@@ -34,7 +34,7 @@ $states = optional_param_array('states', array(), PARAM_ALPHA); // array of note
 $PAGE->set_url('/user/addnote.php', array('id'=>$id));
 
 if (! $course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
diff --git a/user/edit.php b/user/edit.php
index c93cb40..6fa1608 100644
--- a/user/edit.php
+++ b/user/edit.php
@@ -39,7 +39,7 @@ $cancelemailchange = optional_param('cancelemailchange', 0, PARAM_INT);   // cou
 $PAGE->set_url('/user/edit.php', array('course'=>$course, 'id'=>$userid));
 
 if (!$course = $DB->get_record('course', array('id'=>$course))) {
-    print_error('invalidcourseid', 'error', '', $course);
+    print_error('invalidcourseid');
 }
 
 if ($course->id != SITEID) {
diff --git a/user/groupaddnote.php b/user/groupaddnote.php
index 996cdab..90f1b3d 100644
--- a/user/groupaddnote.php
+++ b/user/groupaddnote.php
@@ -41,7 +41,7 @@ if ($state !== '') {
 $PAGE->set_url($url);
 
 if (! $course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 $context = get_context_instance(CONTEXT_COURSE, $id);
diff --git a/user/messageselect.php b/user/messageselect.php
index f9b11c1..d54d26d 100644
--- a/user/messageselect.php
+++ b/user/messageselect.php
@@ -61,7 +61,7 @@ $PAGE->set_url($url);
 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
 
 if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error', '', $id);
+    print_error('invalidcourseid');
 }
 
 require_login();
diff --git a/user/portfolio.php b/user/portfolio.php
index 51c4b7d..c91e04e 100644
--- a/user/portfolio.php
+++ b/user/portfolio.php
@@ -42,7 +42,7 @@ if ($config !== 0) {
     $url->param('config', $config);
 }
 if (! $course = $DB->get_record("course", array("id"=>$courseid))) {
-    print_error('invalidcourseid', 'error', '', $courseid);
+    print_error('invalidcourseid');
 }
 
 $user = $USER;
diff --git a/user/portfoliologs.php b/user/portfoliologs.php
index 2a68dae..1690b1f 100644
--- a/user/portfoliologs.php
+++ b/user/portfoliologs.php
@@ -37,7 +37,7 @@ $page     = optional_param('page', 0, PARAM_INT);
 $perpage  = optional_param('perpage', 10, PARAM_INT);
 
 if (! $course = $DB->get_record("course", array("id"=>$courseid))) {
-    print_error('invalidcourseid', 'error', '', $courseid);
+    print_error('invalidcourseid');
 }
 
 require_login($course, false);
