Skip to content

Commit

Permalink
"MDL-14129, fix print_error call"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed May 21, 2008
1 parent 4cacea3 commit 0be2c85
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion question/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
if ($param->delete && ($questionstomove = count_records("question", "category", $param->delete))){
if (!$category = get_record("question_categories", "id", $param->delete)) { // security
print_error("No such category {$param->delete}!", '', $thispageurl->out());
print_error('nocate', 'question', $thispageurl->out(), $param->delete);
}
$categorycontext = get_context_instance_by_id($category->contextid);
$qcobject->moveform = new question_move_form($thispageurl,
Expand Down
12 changes: 6 additions & 6 deletions question/contextmove.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
list($toparent, $contextto) = explode(',', $toparent);
if (!empty($toparent)){//not top level category, make it a child of $toparent
if (!$toparent = get_record('question_categories', 'id', $toparent)){
print_error('Invalid category id for parent!', '', $onerrorurl);
print_error('invalidcategoryidforparent', 'question', $onerrorurl);
}
$contextto = $toparent->contextid;
} else {
Expand All @@ -35,10 +35,10 @@
$toparent->contextid = $contextto;
}
if (!$cattomove = get_record('question_categories', 'id', $cattomove)){
print_error('Invalid category id to move!', '', $onerrorurl);
print_error('invalidcategoryidtomove', 'question', $onerrorurl);
}
if ($cattomove->contextid == $contextto){
print_error("You shouldn't have got here if you're not moving a category to another context.", '', $onerrorurl);
print_error('contexterror', '', $onerrorurl);
}
$cattomove->categorylist = question_categorylist($cattomove->id);

Expand Down Expand Up @@ -130,7 +130,7 @@
case QUESTION_FILEMOVELINKSONLY :
break;
default :
print_error('Invalid action selected!', '', $onerrorurl);
print_error('invalidaction', '', $onerrorurl);
}
switch ($urlaction){
//now search and replace urls in questions.
Expand Down Expand Up @@ -176,11 +176,11 @@
$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)){
print_error("Could not move the category '$newname' to ".$contexttostring, '', $onerrorurl);
print_error('cannotmovefromto', 'question', $onerrorurl, array($newname, $contexttostring));
}
//finally set the new parent id
if (!update_record("question_categories", $cat)) {
print_error("Could not update the category '$updatename'", '', $onerrorurl);
print_error('cannotupdatecate', 'question', $onerrorurl, $updatename);
}
$thispageurl->remove_params('cattomove', 'toparent', 'totop');
redirect($CFG->wwwroot."/question/category.php?".$thispageurl->get_query_string(array('cat'=>"{$cattomove->id},{$contextto->id}")));
Expand Down
8 changes: 4 additions & 4 deletions question/contextmoveq.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
$thispageurl->param('courseid', $COURSE->id);
} else {
print_error('Need to pass courseid or cmid to this script.');
print_error('missingcourseorcmid', 'question');
}
$contexts = new question_edit_contexts($thiscontext);

Expand Down Expand Up @@ -70,7 +70,7 @@
$questions[$id]->context = get_context_instance_by_id($questions[$id]->contextid);
$thisfilesid = get_filesdir_from_context($questions[$id]->context);
if ($fromcoursefilesid && $thisfilesid != $fromcoursefilesid){
print_error('You can\'t use this script to move questions that have files associated with them from different areas.');
print_error('cannotmovequestion', 'question');
} else {
$fromcoursefilesid = $thisfilesid;
}
Expand Down Expand Up @@ -136,7 +136,7 @@
case QUESTION_FILEDONOTHING :
break;
default :
print_error('Invalid action selected!', '', $returnurl);
print_error('invalidaction', '', $returnurl);
}
//now search and replace urls in questions.
switch ($urlaction){
Expand All @@ -152,7 +152,7 @@
case QUESTION_FILEDONOTHING :
break;
default :
print_error('Invalid action selected!', '', $returnurl);
print_error('invalidaction', '', $returnurl);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions question/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,12 @@ function require_login_in_context($contextorid = null){
} else if ($context && ($context->contextlevel == CONTEXT_MODULE)) {
if ($cm = get_record('course_modules','id',$context->instanceid)) {
if (!$course = get_record('course', 'id', $cm->course)) {
print_error('Incorrect course.');
print_error('invalidcourseid');
}
require_course_login($course, true, $cm);

} else {
print_error('Incorrect course module id.');
print_error('invalidcoursemodule');
}
} else if ($context && ($context->contextlevel == CONTEXT_SYSTEM)) {
if (!empty($CFG->forcelogin)) {
Expand Down
2 changes: 1 addition & 1 deletion question/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@


if (! is_readable("format/$from_form->format/format.php")) {
print_error("Format not known ($from_form->format)");
print_error('unknowformat', '', '', $from_form->format);
}

// load parent class for import/export
Expand Down
10 changes: 5 additions & 5 deletions question/format/blackboard_6/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function readdata($filename) {
if ($this->check_and_create_import_dir($unique_code)) {
if(is_readable($filename)) {
if (!copy($filename, "$temp_dir/bboard.zip")) {
print_error("Could not copy backup file");
print_error('cannotcopybackup', 'question');
}
if(unzip_file("$temp_dir/bboard.zip", '', false)) {
// assuming that the information is in res0001.dat
Expand All @@ -178,20 +178,20 @@ function readdata($filename) {
}
}
else {
print_error("Could not find question data file in zip");
print_error('cannotfindquestionfile', 'questioni');
}
}
else {
print "filename: $filename<br />tempdir: $temp_dir <br />";
print_error("Could not unzip file.");
print_error('cannotunzip', 'question');
}
}
else {
error ("Could not read uploaded file");
print_error('cannotreaduploadfile');
}
}
else {
print_error("Could not create temporary directory");
print_error('cannotcreatetempdir');
}
}

Expand Down
8 changes: 4 additions & 4 deletions question/format/coursetestmanager/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function importprocess($filename) {
if ((PHP_OS == "Linux") and !isset($hostname)) {
// copy the file to a semi-permanent location
if (! $basedir = make_upload_directory("$COURSE->id")) {
print_error("The site administrator needs to fix the file permissions for the data directory");
print_error('cannotcreateuploaddir');
}
if (!isset($hostname_access_error)) {
$bname=basename($filename);
Expand Down Expand Up @@ -101,7 +101,7 @@ function importprocess($filename) {
if (PHP_OS == "WINNT") {
// copy the file to a semi-permanent location
if (! $basedir = make_upload_directory("$COURSE->id")) {
print_error("The site administrator needs to fix the file permissions for the data directory");
print_error('cannotcreateuploaddir');
}
$bname=basename($filename);
$cleanfilename = clean_filename($bname);
Expand All @@ -124,7 +124,7 @@ function importprocess($filename) {
}
// print the intermediary form
if (!$categories = question_category_options($COURSE->id, true)) {
print_error("No categories!");
print_error('nocate', 'debug');
}
print_heading_with_help($strimportquestions, "import", "quiz");
print_simple_box_start("center");
Expand Down Expand Up @@ -264,7 +264,7 @@ function importprocess($filename) {
$question->createdby = $USER->id;
$question->timecreated = time();
if (!$question->id = insert_record("question", $question)) {
print_error("Could not insert new question!");
print_error('cannotinsertquestion', 'question');
}
$this->questionids[] = $question->id;
// Now to save all the answers and type-specific options
Expand Down
20 changes: 10 additions & 10 deletions question/format/qti2/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function indent_xhtml($source, $indenter = ' ') {
function importpreprocess() {
global $CFG;

print_error("Sorry, importing this format is not yet implemented!", '',
print_error('cannotimportformat', '',
"$CFG->wwwroot/mod/quiz/import.php?category=$category->id");
}

Expand Down Expand Up @@ -274,13 +274,13 @@ function exportprocess() {
$expout = $smarty->fetch('imsmanifest.tpl');
$filepath = $path.'/imsmanifest.xml';
if (empty($expout)) {
print_error("Unkown error - empty imsmanifest.xml");
print_error('emptyxml', 'question');
}
if (!$fh=fopen($filepath,"w")) {
print_error("Cannot open for writing: $filepath");
print_error('cannotopenforwrit', '', '', $filepath);
}
if (!fwrite($fh, $expout)) {
print_error("Cannot write exported questions to $filepath");
print_error('cannotwriteto', 'question', '', $filepath);
}
fclose($fh);

Expand All @@ -295,10 +295,10 @@ function exportprocess() {

$filepath = $path.'/'.$this->get_assesment_item_id($question) . ".xml";
if (!$fh=fopen($filepath,"w")) {
print_error("Cannot open for writing: $filepath");
print_error('cannotopenforwrit', '', '', $filepath);
}
if (!fwrite($fh, $expout)) {
print_error("Cannot write exported questions to $filepath");
print_error('cannotwriteto', 'question', '', $filepath);
}
fclose($fh);

Expand Down Expand Up @@ -332,13 +332,13 @@ function export_quiz($course, $quiz, $questions, $result, $redirect, $submiturl
$this->xml_entitize($result);
$this->xml_entitize($submiturl);
if (! $this->exportpreprocess(0, $course)) { // Do anything before that we need to
print_error("Error occurred during pre-processing!", '', $redirect);
print_error('errorduringpre', 'question', $redirect);
}
if (! $this->exportprocess_quiz($quiz, $questions, $result, $submiturl, $course)) { // Process the export data
print_error("Error occurred during processing!", '', $redirect);
print_error('errorduringproc', 'question', $redirect);
}
if (! $this->exportpostprocess()) { // In case anything needs to be done after
print_error("Error occurred during post-processing!", '', $redirect);
print_error('errorduringpost', 'question', $redirect);
}

}
Expand Down Expand Up @@ -675,7 +675,7 @@ function & init_smarty() {
$path = $CFG->dataroot."/smarty_c";
if (!is_dir($path)) {
if (!mkdir($path, $CFG->directorypermissions)) {
print_error("Cannot create path: $path");
print_error('nopermissiontomkdir');
}
}
$smarty = new Smarty;
Expand Down
10 changes: 5 additions & 5 deletions question/format/webct/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,21 @@ function qformat_webct_convert_formula($formula) {
for ($i = 1 ; $deep ; ++$i) {
if (!ereg('^(.*[^[:alnum:]_])?([[:alnum:]_]*([)(])([^)(]*[)(]){'.$i.'})$',
$splits[0], $regs)) {
print_error("Parenthesis before ** is not properly started in $splits[0]**");
print_error("parenthesisinproperstart", 'question', '', $splits[0]);
}
if ('(' == $regs[3]) {
--$deep;
} else if (')' == $regs[3]) {
++$deep;
} else {
print_error("Impossible character $regs[3] detected as parenthesis character");
print_error('impossiblechar', 'question', '', $regs[3]);
}
}
$base = $regs[2];
$splits[0] = $regs[1];

} else {
print_error("Bad base before **: $splits[0]**");
print_error('badbase', 'question', '', $splits[0]);
}

// Find $exp (similar to above but a little easier)
Expand All @@ -136,14 +136,14 @@ function qformat_webct_convert_formula($formula) {
for ($i = 1 ; $deep ; ++$i) {
if (!ereg('^([+-]?[[:alnum:]_]*([)(][^)(]*){'.$i.'}([)(]))(.*)',
$splits[1], $regs)) {
print_error("Parenthesis after ** is not properly closed in **$splits[1]");
print_error("parenthesisinproperclose", 'question', '', $splits[1]);
}
if (')' == $regs[3]) {
--$deep;
} else if ('(' == $regs[3]) {
++$deep;
} else {
print_error("Impossible character $regs[3] detected as parenthesis character");
print_error("impossiblechar", 'question');
}
}
$exp = $regs[1];
Expand Down
2 changes: 1 addition & 1 deletion question/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$module = null;
$cm = null;
} else {
print_error('Need to pass courseid or cmid to this script.');
print_error('missingcourseorcmid', 'question');
}
$contexts = new question_edit_contexts($thiscontext);

Expand Down
2 changes: 1 addition & 1 deletion question/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$currenttab = '';
}
if (!isset($COURSE)) {
print_error('No course specified');
print_error('invalidcourse');
}

$tabs = array();
Expand Down

0 comments on commit 0be2c85

Please sign in to comment.