Skip to content

Commit

Permalink
"MDL-14129, fix print_error"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Jun 15, 2008
1 parent fd9f6cd commit bd8ee7c
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 26 deletions.
3 changes: 2 additions & 1 deletion admin/uploaduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
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);
}
Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function print_entry($course)
break;
}
if (!empty($authorizeerror)) {
print_error($authorizeerror);
print_error('authorizeerror');
}
}
$frmenrol->display();
Expand Down
2 changes: 1 addition & 1 deletion grade/import/xml/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}

} else {
print_error($error);
print_error('error', 'gradeimport_xml');
}

?>
2 changes: 2 additions & 0 deletions lang/en_utf8/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ';
Expand Down Expand Up @@ -174,6 +175,7 @@
$string['csvinvalidcolsnum'] = 'INVALID CSV FILE; Each line must include 49 or 70 fields';
$string['csvinvalidcols'] = '<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"';
$string['csvweirdcolumns'] = 'Invalid CSV file format - number of columns is not constant!';
$string['csvloaderror'] = 'Error occur during loading vcs file!';
$string['dbconnectionfailed'] = '<p>Error: Database connection failed.</p>
<p>It is possible that the database is overloaded or otherwise not running properly.</p>
<p>The site administrator should also check that the database details have been correctly specified in config.php</p>$a';
Expand Down
1 change: 1 addition & 0 deletions lang/en_utf8/gradeimport_xml.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?PHP // $Id$

$string['error'] = 'Errors occur';
$string['errbadxmlformat'] = 'Error - bad XML format';
$string['errduplicateidnumber'] = 'Error - duplicate idnumber';
$string['errincorrectidnumber'] = 'Error - incorrect idnumber';
Expand Down
2 changes: 2 additions & 0 deletions lang/en_utf8/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
$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?';
Expand Down Expand Up @@ -125,6 +126,7 @@
$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.';
Expand Down
2 changes: 2 additions & 0 deletions lang/en_utf8/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
$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';
Expand Down Expand Up @@ -252,6 +253,7 @@
$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%%<br />Instead, they add up to $a%%<br />Do you want to go back and fix this question?';
$string['fractionsnomax'] = 'One of the answers should be 100%%, so that it is<br />possible to get a full grade for this question.<br />Do you want to go back and fix this question?';
$string['fromfile'] = 'from file:';
Expand Down
6 changes: 3 additions & 3 deletions question/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<hr />";

Expand Down
3 changes: 2 additions & 1 deletion question/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<hr />";
Expand Down
24 changes: 6 additions & 18 deletions question/type/calculated/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,40 +293,28 @@ function create_runtime_question($question, $form) {
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:<br />";
foreach ($calculatedmessages as $msg) {
$errorstring .= $msg . '<br />';
}
print_error($errorstring);
}

break;
default:
return parent::validate_form($form);
Expand Down
2 changes: 1 addition & 1 deletion question/type/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function save_question($question, $form, $course) {
$result = $this->save_question_options($form);

if (!empty($result->error)) {
print_error($result->error);
print_error('questionsaveerror', 'question', '', $result->error);
}

if (!empty($result->notice)) {
Expand Down

0 comments on commit bd8ee7c

Please sign in to comment.