$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");
}
}
}
$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) {
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
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
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);
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);
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!");
}
}
}
if (!confirm_sesskey()) {
- error('This script was called wrongly');
+ print_error('This script was called wrongly');
}
/// OK, here goes ...
// check session key
if (!confirm_sesskey()) {
- error( get_string('confirmsesskeybad', 'error' ) );
+ print_error('confirmsesskeybad', 'error');
}
$configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
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 {
$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 {
$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 {
$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.");
}
$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);
$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&currentfile=$currentfile");
+ print_error("Could not save the file '$saveinto/$currentfile'!", '', "lang.php?mode=compare&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&currentfile=$currentfile&sesskey=$USER->sesskey");
+ print_error("Could not save the file '$currentfile'!", '', "lang.php?mode=helpfiles&currentfile=$currentfile&sesskey=$USER->sesskey");
}
}
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");
}
}
}
// 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();
// 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.
//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
//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';
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)) {
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')) {
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.
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;
}
$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);
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&hostid='.$mnet_peer->id);
+ print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id);
exit;
} else {
$oldkey = $mnet_peer->public_key;
foreach ($mnet_peer->error as $err) {
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
}
- error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id);
+ //error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id);
+ print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $errmsg);
exit;
}
}
// 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&hostid='.$mnet_peer->id);
+ print_error("hostexists", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $mnet_peer->id);
}
}
if ($bool) {
redirect('peers.php?step=update&hostid='.$mnet_peer->id, get_string('changessaved'));
} else {
- error('Invalid action parameter.', 'index.php');
+ print_error('Invalid action parameter.', '', 'index.php');
}
}
}
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
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) {
if (!$tables = $db->Metatables() ) { // No tables yet at all.
- error("no tables");
+ print_error("no tables");
}
print_simple_box_start('center');
}
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) {
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();
}
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");
}
}
}
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);
$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);
}
$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);
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);
$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()) {
$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()) {
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');
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
}
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
$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');
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');
}
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
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
break;
}
} else {
- error($xmldb_action->getError());
+ print_error($xmldb_action->getError());
}
} else {
error ("Error: cannot instantiate class (actions/$action/$actionclass)");
/// 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
/// 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
* @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.");
}
/**
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
$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']);
$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');
}
}
// 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
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);
// 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');
}
}
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
$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;
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
$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);
}
if (!is_enabled_auth('mnet')) {
- error('mnet is disabled');
+ print_error('mnet is disabled');
}
// grab the GET params
$token = required_param('token', PARAM_BASE64);
/// Define variables used in page
if (!$site = get_site()) {
- error("No site found!");
+ print_error("No site found!");
}
if (empty($CFG->langmenu)) {
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
//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
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.');
}
?>
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;
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
}
}
} 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;
}
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);
// 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
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)) {
//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
}
return true;
}
-?>
\ No newline at end of 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_precheck($id,$file,$errorstr);
if (!$status) {
- error("An error occured");
+ print_error("An error occured");
}
?>
} 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);
/**
* @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
*/
//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");
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
//Check necessary functions exists. Thanks to gregb@crowncollege.edu
// 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);
}
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
$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');
$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 = '';
$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
$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');
}
} 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';
$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;
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;
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);
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);
}
case 'edit':
if (!$existing) {
- error('Incorrect blog post id');
+ print_error('Incorrect blog post id');
}
$post->id = $existing->id;
$post->subject = $existing->subject;
}
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');
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);
}
}
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);
}
}
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);
}
}
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
// needed also for user tabs later
if (!$course = get_record('course', 'id', $courseid)) {
- error('Wrong course id');
+ print_error('Wrong course id');
}
$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) {
if (empty($CFG->bloglevel)) {
- error('Blogging is disabled!');
+ print_error('Blogging is disabled!');
}
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
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)) {
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;
break;
default:
- error('Incorrect blog filter type specified');
+ print_error('Incorrect blog filter type specified');
break;
}
}
if (empty($CFG->bloglevel)) {
- error('Blogging is disabled!');
+ print_error('Blogging is disabled!');
}
require_capability('moodle/blog:view', $context);
$pagesize = required_param('pagesize', PARAM_INT);
if ($pagesize < 1) {
- error('invalid page size');
+ print_error('invalid page size');
}
set_user_preference('blogpagesize', $pagesize);
$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);
// 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');
// 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
}
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)) {
} 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");
}
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");
$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.
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
$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
$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!");
}
}
}
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';
} 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 destination category");
+ print_error("Error finding the destination category");
}
// TODO function to move the category
}
$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);
$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");
}
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
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");
}
}
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");
}
}
$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);
$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);
$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.
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);
$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");
if ( !(isset($required[$h]) or
isset($optionalDefaults[$h]) or
isset($optional[$h])) ) {
- error(get_string('invalidfieldname', 'error', $h), 'index.php?id='.$id.'&sesskey='.$USER->sesskey);
+ print_error('invalidfieldname', 'error', 'index.php?id='.$id.'&sesskey='.$USER->sesskey, $h);
}
if ( isset($required[$h]) ) {
$required[$h] = 2;
// check for required fields
foreach ($required as $key => $value) {
if ($value < 2) {
- error(get_string('fieldrequired', 'error', $key), 'uploaduser.php?id='.$id.'&sesskey='.$USER->sesskey);
+ print_error('fieldrequired', 'error', 'uploaduser.php?id='.$id.'&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);
}
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);
$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()) {
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()) {
$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);
$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");
}
}
$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));
}
asort($modnames, SORT_LOCALE_STRING);
} else {
- error("No modules are installed!");
+ print_error("No modules are installed!");
}
if ($rawmods = get_course_mods($courseid)) {
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'));
*/
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)) {
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 {
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;
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) {
}
if (! $course = get_record('course', 'id', $id)) {
- error("Course ID was incorrect");
+ print_error("Course ID was incorrect");
}
/// User must be logged in
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');
{$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;
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
$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
$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);
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);
}
$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);
$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");
}
}
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'));
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));
}
$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);
$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);
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>';
$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");
}
}
$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);
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");
}
}
$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';
.' 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) {
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);
require_login();
if (isguest()) {
- error("No guests here!");
+ print_error("No guests here!");
}
if (empty($CFG->enablecourserequests)) {
$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);
$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);
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;
}
}
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);
// 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);
}
}
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);
} 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
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&user=$user->id&confirm=yes&sesskey=".sesskey(),
$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);
// 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&user=$user->id&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
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');
}
}
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");
break;
}
if (!empty($authorizeerror)) {
- error($authorizeerror);
+ print_error($authorizeerror);
}
}
$frmenrol->display();
$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;
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.
if ($perpage > 100) { $perpage = 100; }
$perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
$perpagemenu = popup_form($baseurl.'&status='.$status.'&course='.$courseid.'&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."&status=$status&course=$courseid&perpage=$perpage");
+ $table->no_sorting('action');
$table->sortable(true, 'id', SORT_DESC);
$table->pageable(true);
$table->setup();
$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);
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);
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)) {
}
$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)) {
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");
}
$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);
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);
switch ($order->status) {
case AN_STATUS_AUTH:
- if (authorize_expired($order)) {
+ if (AuthorizeNet::expired($order)) {
if ($canmanage) {
$ret->actions = array(ORDER_DELETE);
}
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);
return $ret;
case AN_STATUS_CREDIT:
- if (authorize_settled($order)) {
+ if (AuthorizeNet::settled($order)) {
$ret->status = 'settled';
}
else {
/// 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
}
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'");
}
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);
// 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;
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;
}
/// 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;
/// 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;
// 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) {
// 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??
}
?>
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\">";
$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)) {
if (is_executable($custom_commandpath)) {
return $custom_commandpath;
} else {
- error($error_message2.$error_message1);
+ print_error($error_message2.$error_message1);
}
}
case "FreeBSD": return "$CFG->dirroot/filter/tex/mimetex.freebsd";
}
- error($error_message1);
+ print_error($error_message1);
}
$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)) {
$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) {
$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);
$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));
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);
} else {
if ($courseid) {
if (!$course = get_record('course', 'id', $courseid)) {
- error('Incorrect course id');
+ print_error('Incorrect course id');
}
}
$outcome_rec->standard = 1;
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()) {
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);
} else {
if ($courseid) {
if (!$course = get_record('course', 'id', $courseid)) {
- error('Incorrect course id');
+ print_error('Incorrect course id');
}
}
$scale_rec->standard = 1;
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()) {
// 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'];
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();
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();
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();
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();
$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
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();
// 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");
}
}
// 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
}
}
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');
}
}
} else {
if (!$element = $gtree->locate_element($eid)) {
- error('Incorrect element id!', $returnurl);
+ print_error('Incorrect element id!', '', $returnurl);
}
$object = $element['object'];
}
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();
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();
}
// 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;
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);
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);
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);
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);
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;
}
$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")) {
} 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);
}
}
}
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();
}
// 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;
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);
$text = download_file_content($url);
if ($text === false) {
- error('Can not read file');
+ print_error('Can not read file');
}
$error = '';
echo 'ok';
die;
} else {
- error('Grade import error'); //TODO: localize
+ print_error('Grade import error'); //TODO: localize
}
} else {
}
} else {
- error($error);
+ print_error($error);
}
?>
}
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
}
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)) {
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);
} else {
if (!get_complete_user_data('id', $userid)) {
- error("Incorrect userid");
+ print_error("Incorrect userid");
}
}
$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)) {
$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.
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);
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;
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.'&group='.$id;
}
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;
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');
}
}
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;
}
}
}
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;
}
if (!$group = get_record('groups', 'id', $groupid)) {
- error('Incorrect group id');
+ print_error('Incorrect group id');
}
if (!$course = get_record('course', 'id', $group->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.
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();
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)) {
} 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)) {
} 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;
/// 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
$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)) {
/// 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)) {
// 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();
*/
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();
// 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++;
}
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);
}
}
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;
}
}
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 {
/// 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);
// 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');
}
} 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 .' !');
}
}
global $CFG, $db, $interactive;
if (!$mods = get_list_of_plugins('mod') ) {
- error('No modules installed!');
+ print_error('No modules installed!');
}
$updated_modules = false;
// 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');
/// 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);
} 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
/// 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
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!');
}
}
$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) {
redirect("$CFG->wwwroot/user/editadvanced.php?id=$user->id"); // Edit thyself
}
} else {
- error('Can not create admin!');
+ print_error('Can not create admin!');
}
}
/**
* 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.
*/
$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;
}
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':
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;
$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;
* @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.');
}
/**
*/
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');
}
/**
*/
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');
}
/**
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
}
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)) {
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) {
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]))) {
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?
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?
$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
/// 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, ' ', ' ');
- }\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;
} 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!');
}
}
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
/// 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 ' .
/// 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) {
//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();
$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) {
} 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, ' ', ' ');
}
$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
/// 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 ' .
/// 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
// 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);
} 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
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, ' ', ' ');
}
- }\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
} 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();
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!');
}
}
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);
+ }
+ }
}
}
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
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');
}
}
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;
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;
}
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.');
}
}
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.');
}
}
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.');
}
}
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";
// 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);
}
}
-?>
\ No newline at end of file
+?>
}
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);
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);
$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);
// 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 {
$files[$elname] = $this->_upload_manager->files[$elname]['tmp_name'];
}
} else {
- error('Incorrect upload attempt!');
+ print_error('Incorrect upload attempt!');
}
}
* 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.');
}
/**
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)) {
}
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
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();
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
*/
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) {
* @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));
}
/**
* @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));
}
/**
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 {
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();
global $CFG;
if (!$mods = get_list_of_plugins('mod') ) {
- error('No modules installed!');
+ print_error('No modules installed!');
}
foreach ($mods as $mod) {
}
if (!$mods = get_list_of_plugins('mod') ) {
- error('No modules installed!');
+ print_error('No modules installed!');
}
foreach ($mods as $mod) {
$course = $COURSE;
} else {
if (!$course = get_record('course', 'id', $cm->course)) {
- error('Incorrect course id in cm');
+ print_error('Incorrect course id in cm');
}
}
}
}
} 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) {
} 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);
}
default: // throw error, switched parameters in optional_param or another serious problem
- error("Unknown parameter type: $type");
+ print_error("Unknown parameter type: $type");
}
}
$COURSE = clone($course);
} else {
if (!$COURSE = get_record('course', 'id', $courseorid)) {
- error('Invalid course ID');
+ print_error('Invalid course ID');
}
}
}
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
$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
}
if (!insert_record('user_private_key', $key)) {
- error('Can not insert new key');
+ print_error('Can not insert new key');
}
return $key->value;
// 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
$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');
}
}
} else {
- error('No modules are installed!');
+ print_error('No modules are installed!');
}
/// Give local code a chance to delete its references to this course.
$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();
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;
}
// 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);
}
}
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);
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;
}
}
}
+/**
+ * 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().
*
$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;
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
$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));
$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.
$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!');
}
}
$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;
}
// 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
$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));
}
}
}
$courseid = SITEID;
break;
default :
- error('Unsupported contextlevel in category record!');
+ print_error('Unsupported contextlevel in category record!');
}
return $courseid;
}
return true;
}
- error('Incorrect eventadata submitted: '.$eventdata);
+ print_error('Incorrect eventadata submitted: '.$eventdata);
}
// test handler class with static method
return true;
}
- error('Incorrect eventadata submitted: '.$eventdata);
+ print_error('Incorrect eventadata submitted: '.$eventdata);
}
}
require_login();
if (empty($CFG->aspellpath)) {
- error('Spellchecker not configured');
+ print_error('Spellchecker not configured');
}
header('Content-type: text/html; charset=utf-8');
}
$parts = parse_url($url);
if ($parts === FALSE){
- error('invalidurl');
+ print_error('invalidurl');
}
if (isset($parts['query'])){
parse_str(str_replace('&', '&', $parts['query']), $this->params);
$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;
"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;
}
/// 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');
'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)) {
'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(
$titles[] = get_string('helptext');
break;
default :
- error('Unknown help topic '.$item);
+ print_error('Unknown help topic '.$item);
}
}
$i++;
$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
// 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()) {
} 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
$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))) {
// 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/");
$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
// 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();
} else {
print_header($strforgotten, $strforgotten, $navigation);
- error(get_string('forgotteninvalidurl'));
+ print_error('forgotteninvalidurl');
}
die; //never reached
// 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');
}
}
}
/// Define variables used in page
if (!$site = get_site()) {
- error("No site found!");
+ print_error("No site found!");
}
if (empty($CFG->langmenu)) {
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
}
if (empty($CFG->messaging)) {
- error("Messaging is disabled on this site");
+ print_error("Messaging is disabled on this site");
}
/// Script parameters
/// 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
}
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
}
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
}
if (empty($CFG->messaging)) {
- error("Messaging is disabled on this site");
+ print_error("Messaging is disabled on this site");
}
/// Script parameters
}
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))) {
/// 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!!
}
if (empty($CFG->messaging)) {
- error("Messaging is disabled on this site");
+ print_error("Messaging is disabled on this site");
}
/// Script parameters
/// 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
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");
}
}
$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);
$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);
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);
} 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
/// 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
$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)) {
}
$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);
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);
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");
}
}
$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
$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
$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
$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
$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);
/// 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
case 'editnotes':
$this->upload_notes();
default:
- error('Error: Unknow upload action ('.$action.').');
+ print_error('Error: Unknow upload action ('.$action.').');
}
}
$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);
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");
}
}
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");
}
}
$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);
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);
$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);
$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
$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);
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 {
$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";
$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();
$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;
$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 = '';
$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 = '';
$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 = '';
$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) {
$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 ;-)
/// 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();
$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
$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))) {
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 {
$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";
$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);
$message->timestamp = time();
if (!insert_record('chat_messages', $message)) {
- error('Could not insert a chat message!');
+ print_error('Could not insert a chat message!');
}
}
}
$message->timestamp = time();
if (!insert_record('chat_messages', $message)) {
- error('Could not insert a chat message!');
+ print_error('Could not insert a chat message!');
}
}
}
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);
$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);
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');
}
}
$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);
$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 {
$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!");
}
}
}
$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);
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");
$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');
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;
if (insert_record('data_comments',$newcomment)) {
redirect('view.php?rid='.$record->id.'&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.'&page='.$page);
} else {
- error('Error while saving comment.');
+ print_error('Error while saving comment.');
}
break;
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');
}
}
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);
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;
}
$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!');
}
}
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;
}
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);
}
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();
$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);
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');
}
}
}
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');
}
}
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);
/* Check all is well */
if (!is_directory_a_preset($tempfolder)) {
- error("Not all files generated!");
+ print_error("Not all files generated!");
}
$filelist = array(
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 */
function import_options() {
if (!confirm_sesskey()) {
- error("Sesskey Invalid");
+ print_error("Sesskey Invalid");
}
$strblank = get_string('blank', 'data');
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>';
$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;
}
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);
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
$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);
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 */
/***************** 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);
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);
/***************** Importing *****************/
case 'importpreset' :
if (!data_submitted() or !confirm_sesskey()) {
- error("Invalid request");
+ print_error("Invalid request");
}
$pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname);
/* 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);
case 'finishimport':
if (!data_submitted() or !confirm_sesskey()) {
- error("Invalid request");
+ print_error("Invalid request");
}
$pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname);
/* 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">';
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;
/***************** Exporting *****************/
case 'save1':
if (!data_submitted() or !confirm_sesskey()) {
- error("Invalid request");
+ print_error("Invalid request");
}
$strcontinue = get_string('continue');
case 'save2':
if (!data_submitted() or !confirm_sesskey()) {
- error("Invalid request");
+ print_error("Invalid request");
}
$strcontinue = get_string('continue');
case 'save3':
if (!data_submitted() or !confirm_sesskey()) {
- error("Invalid request");
+ print_error("Invalid request");
}
$name = optional_param('name', $data->name, PARAM_FILE);
$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;
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);
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 */
$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) {
} 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'])) {
$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) {
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%\">";
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);
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');
}
}
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;
}
// 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&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);
$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);
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")) {
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)) {
// 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",
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")) {
$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)) {
}
$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!");
}
}
}
global $CFG;
if (! $course = get_record("course", "id", $exercise->course)) {
- error("Course is misconfigured");
+ print_error("Course is misconfigured");
}
$timenow = time();
$n = 0;
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);
$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
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]");
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]");
$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");
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");
$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;
}
} 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");
$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"),
$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));
}
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));
// 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) {
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));
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
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();
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();
<?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");
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)) {
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)) {
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());
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>";
// 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;
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),
// 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 = '';
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>
// 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...
$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;
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\">";
// 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");
}
// 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);
$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)) {
// 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.
// 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);
$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)) {
}
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);
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)) {
// 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.'&moved=-1&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') {
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!");
}
}
$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');
}
}
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;
$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);
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);
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
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) {
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);
$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);
}
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);
}
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);
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);
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');
}
}
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);
}
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)) {
$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));
$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');
}
}
}
// 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);
$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))) {
// 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"]);
// }
}
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);
}
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);
$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);
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;
$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);
}
$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);
}
}
} else {
- error("This page was not accessed correctly");
+ print_error("This page was not accessed correctly");
}
?>
$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) {
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%\">";
}
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);
$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))) {
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
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"]);
}
}
$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;
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"]);
}
}
$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)) {
$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)) {
}
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);
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
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);
$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);
$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&eid=$eid", "$eid",$cm->id);
}
$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) {
glossary_comment_edit();
die;
default:
- error('Incorrect action specified');
+ print_error('Incorrect action specified');
}
/**
$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();
$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&eid=$entry->id", "$newcomment->id", $cm->id);
}
$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) {
$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();
$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&eid=$entry->id", "$updatedcomment->id",$cm->id);
}
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);
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);
$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.
$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 {
$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&mode=entry&hook=$e");
+ print_error('erredittimeexpired', 'glossary', "view.php?id=$cm->id&mode=entry&hook=$e");
}
} else { // new entry
require_capability('mod/glossary:write', $context);
"view.php?id=$cm->id&mode=entry&hook=$todb->id",
$todb->id, $cm->id);
} else {
- error("Could not update your glossary");
+ print_error("Could not update your glossary");
}
} else {
add_to_log($course->id, "glossary", "add entry",
"view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id,$cm->id);
} else {
- error("Could not insert this new entry");
+ print_error("Could not insert this new entry");
}
}
$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;
}
$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");
}
}
$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 {
$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);
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');
$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>';
$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);
$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",
$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);
//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)) {
//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)) {
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
$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 ) {
$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) {
}
if ($entry->glossaryid != $glossary->id) {
- error("This is not valid entry!");
+ print_error("This is not valid entry!");
}
if ($glossary->assesstimestart and $glossary->assesstimefinish) {
$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);
}
$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);
}
redirect($returnurl, get_string("ratingssaved", "glossary"));
} else {
- error("This page was not accessed correctly");
+ print_error("This page was not accessed correctly");
}
?>
$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) {
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%\">";
$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'));
} else if ($concept) {
$entries = glossary_get_entries_search($concept, $courseid);
} else {
- error('No valid entry specified');
+ print_error('No valid entry specified');
}
if ($entries) {
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);
// 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
$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
$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);
}
}
}
}
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
//
$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);
$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++;
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;
}
$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
}
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",
// 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
// 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;
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;
}
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;
}
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;
}
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);
}
}
// 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
// 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());
}
}
}
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') {
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");
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);
// try and open the template file
if (!file_exists($filepath) || !is_readable($filepath)) {
$msg = 'Could not open the '.$this->parent->template_dir.' template file "'.$filepath.'"';
- 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);
}
} else {
$msg = 'Template block expand method not found: "'.$method.'"';
- error($msg, $this->parent->course_homeurl);
+ print_error($msg, '', $this->parent->course_homeurl);
}
}
}
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();
$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);
$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 {
$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);
}
$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);
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">';
$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.
$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");
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");
}
}
$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);
$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);
$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) {
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");
}
}
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"
$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");
// 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"
$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');
// 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"
$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
$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
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";
}
$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;
$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) {
$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);
$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');
$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
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 {
$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 {
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";
}
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
$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
// (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");
$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");
}
}
}
// 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
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);
}
}
$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');
}
}
}
$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 {
$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
$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");
}
}
}
$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);
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&link=1");
} else {
- error('Something is wrong with the form data');
+ print_error('Something is wrong with the form data');
}
break;
}
$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");
}
} 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>";
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>";
// 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) {
// 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");
}
}
foreach ($branchtable->answers as $answer) {
$answer->pageid = $id;
if(!insert_record('lesson_answers', $answer)) {
- error("insert answer $id");
+ print_error("insert answer $id");
}
}
// 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");
}
}
// 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;
$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);
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);
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);
// 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
// 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
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
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
$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
$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";
$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
//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");
}
}
}
/// 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 = '';
// 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");
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);
$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);
// 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
$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
// 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();
$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;
// 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
$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);
$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);
} else {
/// Build on last attempt.
if (empty($lastattempt)) {
- error(get_string('cannotfindprevattempt', 'quiz'));
+ print_error('cannotfindprevattempt', 'quiz');
}
$attempt = $lastattempt;
}
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);
$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');
}
/////////////////////////////////////
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);
// 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??
}
?>
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");
}
}
$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
$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
" 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();
" 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();
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);
// 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.
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)
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);
" 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) {
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);
$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.
/// 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.
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);
*/
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 = '';
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");
}
}
$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);
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");
$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.");
}
}
}
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);
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);
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'));
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);
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;
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);
$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')) {
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);
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);
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);
// 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>';
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);
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');
}
}
}
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');
}
}
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);
$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&type=$type", "$survey->id", $cm->id);
// 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";
$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
$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);
$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) {
$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)));
// 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);
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");
}
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.");
}
}
$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);
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)) {
}
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);
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);
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");
}
}
// 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);
}
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);
# 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');
}
return true;
}
- error($um->print_upload_log(true));
+ print_error($um->print_upload_log(true));
return false;
}
#-- check for file
if(!$wiki->ewikiacceptbinary) {
- error("This wiki does not accept binaries");
+ print_error("This wiki does not accept binaries");
return 0;
}
$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");
$exportdir=$exportbasedir."/".$wname;
@mkdir($exportdir);
if(!is_dir($exportdir)) {
- error("Cannot create temporary directory $exportdir !");
+ print_error("Cannot create temporary directory $exportdir !");
}
}
#-- 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);
// 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);
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;
$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);
$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);
// 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;
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.");
}
}
}
// 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;
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.
} 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');
}
}
}
$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');
}
}
$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.");
}
}
}
$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));
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));
}
}
$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);
$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!");
}
}
}
// 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);
$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);
$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);
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")) {
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")) {
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")) {
$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)) {
}
$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!");
}
}
}
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();
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"));
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"));
$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"));
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"));
$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"));
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();
$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?
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);
$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
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) {
$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"));
$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");
$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) {
$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) {
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"),
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"),
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();
else {
return get_string('phase5'.$style, 'workshop');
}
- error('Something is wrong with the workshop dates');
+ print_error('Something is wrong with the workshop dates');
}
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)) {
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)) {
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)) {
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");
// 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)."; \n";
// 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) {
$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),
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) {
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
// 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"
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();
// 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;
// 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);
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&id=$cm->id&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");
}
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);
$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
// 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");
}
$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) {
/// 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
/// locate user information
if (!($user = get_record('user', 'id', $userid))) {
- error('Incorrect user id found');
+ print_error('Incorrect user id found');
}
/// build-up form
// 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
// 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()) {
if (note_delete($noteid)) {
add_to_log($note->courseid, 'notes', 'delete', 'index.php?course='.$note->courseid.'&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 {
note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD);
print_footer();
}
-?>
\ No newline at end of file
+?>
/// 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
/// 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;
}
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,
$this->catform->set_data($category);
$this->catform->display();
} else {
- error("Category $categoryid not found");
+ print_error("Category $categoryid not found");
}
}
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
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());
}
}
*/
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
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'.");
}
}
$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
}
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);
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,
}
}
} 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());
}
}
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}")));
}
$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);
$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;
}
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){
case QUESTION_FILEDONOTHING :
break;
default :
- error('Invalid action selected!', $returnurl);
+ print_error('Invalid action selected!', '', $returnurl);
break;
}
}
//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);
}
}
$contextmoveform->display();
print_footer($COURSE);
-?>
\ No newline at end of file
+?>
{$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;
$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));
}
$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);
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);
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);
}
redirect($pageurl->out());
} else {
- error("Confirmation string was incorrect");
+ print_error("Confirmation string was incorrect");
}
$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());
}
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;
} 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)) {
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 />";
// 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;
// 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
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??
}
?>
$question->timecreated = time();
if (!$question->id = insert_record("question", $question)) {
- error( get_string('cannotinsert','quiz') );
+ print_error('cannotinsert','quiz');
}
$this->questionids[] = $question->id;
$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;
// 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();
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
}
}
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 {
}
}
else {
- error("Could not create temporary directory");
+ print_error("Could not create temporary directory");
}
}
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);
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);
}
// 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");
$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
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");
}
// 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;
$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);
$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);
$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);
}
}
$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;
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)
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];
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;
}
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 />";
}
// 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;
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;
// 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;
$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);
//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) {
$currenttab = '';
}
if (!isset($COURSE)) {
- error('No course specified');
+ print_error('No course specified');
}
$tabs = array();
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:
$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 ){
$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");
}
}
}
foreach ($calculatedmessages as $msg) {
$errorstring .= $msg . '<br />';
}
- error($errorstring);
+ print_error($errorstring);
}
break;
// 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");
}
}
}
//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
$datasetdef->itemcount= $newmaxnumber ;
if (!update_record('question_dataset_definitions',
$datasetdef)) {
- error("Error: Unable to update itemcount");
+ print_error("Error: Unable to update itemcount");
}
}
}
return sprintf("%.".$regs[4]."f",$nbr);
} else {
- error("The distribution $regs[1] caused problems");
+ print_error("The distribution $regs[1] caused problems");
}
return '';
}
{$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}");
}
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;
}
}
$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;
}
$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;
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) {
$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]);
}
$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!!
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++;
}
$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;
// 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) {
$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]);
}
break;
default:
- error('Incorrect or no wizard page specified!');
+ print_error('Incorrect or no wizard page specified!');
break;
}
return $question;
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})");
}
}
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() {
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();
} else if (!empty($cmoptions->course)) {
$cmorcourseid = '&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
$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);
}
}
$parsableanswerdef .= 'NUMERICAL:';
break;
default:
- error("questiontype $wrapped->qtype not recognized");
+ print_error("questiontype $wrapped->qtype not recognized");
}
$separator= '';
foreach ($wrapped->options->answers as $subanswer) {
delete_records('question_numerical', 'question', $oldwrappedid);
break;
default:
- error("questiontype $wrapped->qtype not recognized");
+ print_error("questiontype $wrapped->qtype not recognized");
}
}
}
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;
}
$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.
$wrapped->partiallycorrectfeedback = '';
$wrapped->incorrectfeedback = '';
} else {
- error("Cannot identify qtype $answerregs[2]");
+ print_error("Cannot identify qtype $answerregs[2]");
return false;
}
$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;
$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);
}
}
}
$min = $answer->answer / $quotient;
break;
default:
- error("Unknown tolerance type $answer->tolerancetype");
+ print_error("Unknown tolerance type $answer->tolerancetype");
}
$answer->min = $min;
$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)){
$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!');
}
}
$result = $this->save_question_options($form);
if (!empty($result->error)) {
- error($result->error);
+ print_error($result->error);
}
if (!empty($result->notice)) {
// 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;
$context = get_context_instance(CONTEXT_COURSE, $cmoptions->course);
$cmorcourseid = '&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
$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;
}
print_header("$strsearch", "$site->fullname" , $navigation, "", "", true, " ", 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()));
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
+?>
require_login();
if (empty($CFG->usetags)) {
- error(get_string('tagsaredisabled', 'tag'));
+ print_error('tagsaredisabled', 'tag');
}
$tag_id = optional_param('id', 0, PARAM_INT);
// 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
require_login();
if (empty($CFG->usetags)) {
- error('Tags are disabled!');
+ print_error('Tags are disabled!');
}
if (isguestuser()) {
break;
default:
- error('No action was specified');
+ print_error('No action was specified');
break;
}
$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
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);
admin_externalpage_print_footer();
exit;
} else {
- error("Could not set the theme!");
+ print_error("Could not set the theme!");
}
}
}
if (! $site = get_site()) {
- error("Site doesn't exist!");
+ print_error("Site doesn't exist!");
}
require_login();
$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);
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();
$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) {
// 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
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.');
}
$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);
// 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.');
}
}
$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);
$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) {
* @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');
}
/**
* @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');
}
/**
* @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');
}
/**
* @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');
}
}
$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);
$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);
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
$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();
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;
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');
}
}
}
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]);
/// 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;
/// 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
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();
* @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');
}
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);
$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)) {
}
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, " ", navmenu($course));
- error(get_string("groupnotamember"), "../course/view.php?id=$course->id");
+ print_error("groupnotamember", '', "../course/view.php?id=$course->id");
}
}
}
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");
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");