From f39c16e0f45e1465fbab5f47cb8e4ea1bdd0e447 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Wed, 14 May 2008 08:05:45 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- grade/import/csv/index.php | 4 ++-- grade/import/key.php | 10 +++++----- grade/import/xml/fetch.php | 2 +- grade/import/xml/import.php | 4 ++-- lang/en_utf8/error.php | 6 ++++++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index e4f1edaa47..35e0b62dc8 100755 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -160,7 +160,7 @@ if ($formdata = $mform->get_data()) { $filename = $CFG->dataroot.'/temp/gradeimport/cvs/'.$USER->id.'/'.$importcode; if (!file_exists($filename)) { - print_error('error processing upload file'); + print_error('cannotuploadfile'); } if ($fp = fopen($filename, "r")) { @@ -195,7 +195,7 @@ if ($formdata = $mform->get_data()) { } else { // collision unlink($filename); // needs to be uploaded again, sorry - print_error('mapping collision detected, 2 fields maps to the same grade item '.$j); + print_error('cannotmapfield', '', '', $j); } } } diff --git a/grade/import/key.php b/grade/import/key.php index c4426db2d7..ef35bd0279 100644 --- a/grade/import/key.php +++ b/grade/import/key.php @@ -34,22 +34,22 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); if ($id) { if (!$key = get_record('user_private_key', 'id', $id)) { - print_error('Group ID was incorrect'); + print_error('invalidgroupid'); } if (empty($courseid)) { $courseid = $key->instance; } else if ($courseid != $key->instance) { - print_error('Course ID was incorrect'); + print_error('invalidcourseid'); } if (!$course = get_record('course', 'id', $courseid)) { - print_error('Course ID was incorrect'); + print_error('invalidcourseid'); } } else { if (!$course = get_record('course', 'id', $courseid)) { - print_error('Course ID was incorrect'); + print_error('invalidcourseid'); } $key = new object(); } @@ -62,7 +62,7 @@ require_capability('moodle/grade:import', $context); // extra security check if (!empty($key->userid) and $USER->id != $key->userid) { - print_error('You are not owner of this key'); + print_error('notownerofkey'); } $returnurl = $CFG->wwwroot.'/grade/import/keymanager.php?id='.$course->id; diff --git a/grade/import/xml/fetch.php b/grade/import/xml/fetch.php index a0c1715bad..c115d3c6f6 100644 --- a/grade/import/xml/fetch.php +++ b/grade/import/xml/fetch.php @@ -34,7 +34,7 @@ if (!$course = get_record('course', 'id', $id)) { require_user_key_login('grade/import', $id); // we want different keys for each course if (empty($CFG->gradepublishing)) { - print_error('Grade publishing disabled'); + print_error('gradepubdisable'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/grade/import/xml/import.php b/grade/import/xml/import.php index f479aa8ca1..2f6125b4a4 100644 --- a/grade/import/xml/import.php +++ b/grade/import/xml/import.php @@ -53,7 +53,7 @@ if (function_exists('apache_child_terminate')) { $text = download_file_content($url); if ($text === false) { - print_error('Can not read file'); + print_error('cannotreadfile'); } $error = ''; @@ -67,7 +67,7 @@ if ($importcode !== false) { echo 'ok'; die; } else { - print_error('Grade import error'); //TODO: localize + print_error('cannotimportgrade'); //TODO: localize } } else { diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 1fd6c1d85c..e311c72f6b 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -45,13 +45,16 @@ $string['cannotfindinfo'] = 'Cannot find info for: \"$a\"'; $string['cannotfindhelp'] = 'Cannot find \"$a\" language help files'; $string['cannotfindlang'] = 'Cannot find \"$a\" language pack!'; $string['cannotfindsite'] = 'Cannot find site-level course'; +$string['cannotimportgrade'] = 'Grade import error'; $string['cannotgradeuser'] = 'Can not grade this user'; +$string['cannotmapfield'] = 'mapping collision detected, 2 fields maps to the same grade item $a'; $string['cannotmarktopic'] = 'Could not mark that topic for this course'; $string['cannotmoverolewithid'] = 'Cannot move role with ID $a'; $string['cannotmetacourse'] = 'Cannot not add the selected course to this meta course!'; $string['cannotoverridebaserole'] = 'Can not override base role capabilities'; $string['cannotopencsv'] = 'Cannot open csv file'; $string['cannotreadtmpfile'] = 'Error reading temporary file'; +$string['cannotreadfile'] = 'Can not read file'; $string['cannotremovefrommeta'] = 'Could not remove the selected course from this meta course!'; $string['cannotrestore'] = 'An error has occurred and the restore could not be completed!'; $string['cannotsavefile'] = 'Cannot save the file \"$a\".'; @@ -74,6 +77,7 @@ $stirng['cannotupdaterss'] = 'Cannot update rss'; $string['cannotupdatesummary'] = 'Could not update the summary!'; $string['cannotupdatesubcate'] = 'Could not update a child category!'; $string['cannotupdatesubcourse'] = 'Could not update a child course!'; +$string['cannotuploadfile'] = 'error processing upload file'; $string['cannotuseadmin'] = 'You need to be an admin user to use this page.'; $string['cannotuseadminadminorteacher'] = 'You need to be a teacher or admin user to use this page.'; $string['cannotrestoreadminorcreator'] = 'You need to be a creator or admin user to restore into new course!'; @@ -112,6 +116,7 @@ $string['filemismatch'] = 'Non-core filename mismatch. The file \"$a[0]\" should $string['filternotinstalled'] = 'Filter $a is not currently installed'; $string['filternotactive'] = 'Filter $a is not currently active'; $string['forumblockingtoomanyposts'] = 'You have exceeded the posting threshold set for this forum.'; +$string['gradepubdisable'] = 'Grade publishing disabled'; $string['groupalready'] = 'User already belongs to group $a'; $string['groupexistforcourse'] = 'Group \"$a\" already exists for this course'; $string['groupnotaddederror'] = 'Group \"$a\" not added'; @@ -214,6 +219,7 @@ $string['nofolder'] = 'Requested directory does not exist.'; $string['nostatstodisplay'] = 'There is no available data to display, sorry.'; $string['notavailable'] = 'That is not currently available'; $string['notmemberofgroup'] = 'You are not a member of this course group'; +$string['notownerofkey'] = 'You are not owner of this key'; $string['onlyadmins'] = 'Only administrators can do that.'; $string['onlyeditingteachers'] = 'Only editing teachers can do that.'; $string['onlyeditown'] = 'You can only edit your own information'; -- 2.39.5