From bd8ee7c1c498a6ad0b602edbc20ed68ea991ae61 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sun, 15 Jun 2008 12:02:43 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- admin/uploaduser.php | 3 ++- enrol/authorize/enrol.php | 2 +- grade/import/xml/import.php | 2 +- lang/en_utf8/error.php | 2 ++ lang/en_utf8/gradeimport_xml.php | 1 + lang/en_utf8/question.php | 2 ++ lang/en_utf8/quiz.php | 2 ++ question/export.php | 6 +++--- question/import.php | 3 ++- question/type/calculated/questiontype.php | 24 ++++++----------------- question/type/questiontype.php | 2 +- 11 files changed, 23 insertions(+), 26 deletions(-) diff --git a/admin/uploaduser.php b/admin/uploaduser.php index 1a83c4a4da..c442213e14 100755 --- a/admin/uploaduser.php +++ b/admin/uploaduser.php @@ -96,7 +96,8 @@ if (empty($iid)) { unset($content); if ($readcount === false) { - print_error($cir->get_error(), '', $returnurl); + //TODO: need more detailed error info + print_error('csvloaderror', '', $returnurl); } else if ($readcount == 0) { print_error('csvemptyfile', 'error', $returnurl); } diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 7f9659af88..6cceb911c1 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -92,7 +92,7 @@ class enrolment_plugin_authorize break; } if (!empty($authorizeerror)) { - print_error($authorizeerror); + print_error('authorizeerror'); } } $frmenrol->display(); diff --git a/grade/import/xml/import.php b/grade/import/xml/import.php index 6407e47514..a7b41e2740 100644 --- a/grade/import/xml/import.php +++ b/grade/import/xml/import.php @@ -85,7 +85,7 @@ if ($importcode !== false) { } } else { - print_error($error); + print_error('error', 'gradeimport_xml'); } ?> diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index f9d85fdeed..ceb5a1061b 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -3,6 +3,7 @@ $string['adminprimarynoedit'] = 'The primary admin cannot be edited by others'; +$string['authorizeerror'] = 'Authorize Error'; $string['blockdoesnotexist'] = 'This block does not exist'; $string['blockcannotinistantiate'] = 'Problem in instantiating block object'; $string['blockcannotread'] = 'Could not read data for blockid= $a '; @@ -174,6 +175,7 @@ $string['csvfewcolumns'] = 'Not enough columns, please verify the delimiter sett $string['csvinvalidcolsnum'] = 'INVALID CSV FILE; Each line must include 49 or 70 fields'; $string['csvinvalidcols'] = 'INVALID CSV FILE: First line must include "Header Fields" and the file must be type of
"Expanded Fields/Comma Separated"
or
"Expanded Fields with CAVV Result Code/Comma Separated"'; $string['csvweirdcolumns'] = 'Invalid CSV file format - number of columns is not constant!'; +$string['csvloaderror'] = 'Error occur during loading vcs file!'; $string['dbconnectionfailed'] = '

Error: Database connection failed.

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php

$a'; diff --git a/lang/en_utf8/gradeimport_xml.php b/lang/en_utf8/gradeimport_xml.php index ec2e5f4a39..e2f3bb7413 100644 --- a/lang/en_utf8/gradeimport_xml.php +++ b/lang/en_utf8/gradeimport_xml.php @@ -1,5 +1,6 @@ name $string['errorupdatingattempt'] = 'Error updating attempt $a->id in the database.'; $string['emptyxml'] = 'Unkown error - empty imsmanifest.xml'; $string['exportcategory'] = 'Export category'; +$string['exporterror'] = 'Errors occur during exporting!'; $string['filesareasite']= 'the site files area'; $string['filesareacourse']= 'the course files area'; $string['filestomove']= 'Move / copy files to $a?'; @@ -125,6 +126,7 @@ $string['questionbank'] = 'Question bank'; $string['questioncategory'] = 'Question category'; $string['questioncatsfor'] = 'Question Categories for \'$a\''; $string['questiondoesnotexist'] = 'This question does not exist'; +$string['questionsaveerror'] = 'Errors occur during saving question - ($a)'; $string['questionsmovedto'] = 'Questions still in use moved to "$a" in the parent course category.'; $string['questionsrescuedfrom'] = 'Questions saved from context $a.'; $string['questionsrescuedfrominfo'] = 'These questions (some of which may be hidden) where saved when context $a was deleted because they are still used by some quizzes or other activities.'; diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index 172fc36cab..0611cef468 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -53,6 +53,7 @@ $string['attempt'] = 'Attempt $a'; $string['attemptclosed'] = 'Attempt has not closed yet'; $string['attemptduration'] = 'Time taken'; $string['attemptedon'] = 'Attempted on'; +$string['attempterror'] = 'Attempt error'; $string['attemptfirst'] = 'First attempt'; $string['attemptincomplete'] = 'That attempt (by $a) is not yet completed.'; $string['attemptlast'] = 'Last attempt'; @@ -252,6 +253,7 @@ $string['finishreview'] = 'Finish review'; $string['forceregeneration'] = 'force regeneration'; $string['formatnotfound'] = 'Import/export format $a not found'; $string['formatnotimplemented'] = 'This format has not been correctly implemented, please post a bug report'; +$string['formulaerror'] = 'Formula errors!'; $string['fractionsaddwrong'] = 'The positive grades you have chosen do not add up to 100%%
Instead, they add up to $a%%
Do you want to go back and fix this question?'; $string['fractionsnomax'] = 'One of the answers should be 100%%, so that it is
possible to get a full grade for this question.
Do you want to go back and fix this question?'; $string['fromfile'] = 'from file:'; diff --git a/question/export.php b/question/export.php index 5ebf3a3dc9..d0738298a4 100644 --- a/question/export.php +++ b/question/export.php @@ -104,15 +104,15 @@ $qformat->setContexttofile(!empty($from_form->contexttofile)); if (! $qformat->exportpreprocess()) { // Do anything before that we need to - print_error($txt->exporterror, '', $thispageurl->out()); + print_error('exporterror', 'question', $thispageurl->out()); } if (! $qformat->exportprocess()) { // Process the export data - print_error($txt->exporterror, '', $thispageurl->out()); + print_error('exporterror', 'question', $thispageurl->out()); } if (! $qformat->exportpostprocess()) { // In case anything needs to be done after - print_error($txt->exporterror, '', $thispageurl->out()); + print_error('exporterror', 'question', $thispageurl->out()); } echo "
"; diff --git a/question/import.php b/question/import.php index 619b9f2adb..9eedd4d1d3 100644 --- a/question/import.php +++ b/question/import.php @@ -143,7 +143,8 @@ // In case anything needs to be done after if (! $qformat->importpostprocess()) { - print_error($txt->importerror, '', $thispageurl->out()); + //TODO: need more detailed error info + print_error('cannotimport', '', $thispageurl->out()); } echo "
"; diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index e7a2b7446c..0b0a2a49e0 100644 --- a/question/type/calculated/questiontype.php +++ b/question/type/calculated/questiontype.php @@ -293,40 +293,28 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype function validate_form($form) { switch($form->wizardpage) { case 'question': - $calculatedmessages = array(); if (empty($form->name)) { - $calculatedmessages[] = get_string('missingname', 'quiz'); + print_error('missingname', 'quiz'); } if (empty($form->questiontext)) { - $calculatedmessages[] = get_string('missingquestiontext', 'quiz'); + print_error('missingquestiontext', 'quiz'); } // Verify formulas foreach ($form->answers as $key => $answer) { if ('' === trim($answer)) { - $calculatedmessages[] = - get_string('missingformula', 'quiz'); + print_error('missingformula', 'quiz'); } - if ($formulaerrors = - qtype_calculated_find_formula_errors($answer)) { - $calculatedmessages[] = $formulaerrors; + if ($formulaerrors = qtype_calculated_find_formula_errors($answer)) { + print_error('formulaerror', 'quiz'); } if (! isset($form->tolerance[$key])) { $form->tolerance[$key] = 0.0; } if (! is_numeric($form->tolerance[$key])) { - $calculatedmessages[] = - get_string('tolerancemustbenumeric', 'quiz'); + print_error('tolerancemustbenumeric', 'quiz'); } } - if (!empty($calculatedmessages)) { - $errorstring = "The following errors were found:
"; - foreach ($calculatedmessages as $msg) { - $errorstring .= $msg . '
'; - } - print_error($errorstring); - } - break; default: return parent::validate_form($form); diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 7824debf67..3118e4d534 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -316,7 +316,7 @@ class default_questiontype { $result = $this->save_question_options($form); if (!empty($result->error)) { - print_error($result->error); + print_error('questionsaveerror', 'question', '', $result->error); } if (!empty($result->notice)) { -- 2.39.5