|
|
|
[
Permlink
| « Hide
]
Dongsheng Cai - 04/Apr/08 11:40 AM
All the error() calls are changed to print_error() now, creating error strings may take a while, tooooo many strings need to be created.
Wow,
I thought your were going to do this "gradually", adding new strings and changing some calls each day. In fact, now that all them are "correct" print_error() calls it's more difficult to find them, when it was trivial to do before your commit. Also be prevented about those BIG commits because they use to make more difficult to merge things (sometimes, not now, I guess) and to revert and so on. Just a recommendation. And yes, next step is about to creating error strings and replace them in current calls to print_error(), that's a huge task (I'd recommend to make that "gradually" ;-) ) Ciao :-) Oops, sorry, I didn't realize these problems before I commited changes, I will be careful about these changes from now on, thanks for your recommendation, Eloy.
Hi Dongsheng,
just saw you latest gradual changes about this issue and have found that here: http://cvs.moodle.org/moodle/backup/backup.php?r1=1.48&r2=1.49 You've used the same error string "cannotusepage" in THREE places. If you look at this carefully you'll see that the second replacement is incorrect, only admins can use that page (whereas the rest are admins and teachers). I'd suggesto you to fix this by: 1) Adding some different lang strings like: cannotuseadmin cannotuseadminadminorteacher ... (i.e. all them will start by "cannotuse" followed by the list of roles allowed to use the page). Just a example proposal, feel free to improve it. 2) Apply then where necessary. That way, always you find one error message, you can resuse those langs strings safely in future changes of this gradual task. Ciao :-) As it seems, the transition from error() to print_error() does now not only go to HEAD, but to MOODLE_19_STABLE as well. Thus, should error() no more be used when creating new error checks in the STABLE branch?
Why using the error string cannotuseadminadminorteacher (cannotuse admin admin or teacher) at http://cvs.moodle.org/moodle/backup/backup.php?r1=1.50&r2=1.48 ? Hi, Robert, you'd better use print_error from now on, you can easily merge new error check to HEAD.
Hi Dongsheng,
Thanks for your tedious but necessary work on print_error. However you have done some changes on multianswer/questiontype (19 may) /// MULTIANSWER /// (Embedded - cloze) @@ -439,7 +439,7 @@ echo $feedbackimg; break; default: - print_error("Unable to recognize questiontype of question part #$positionkey."); + print_error('unknownquestiontype', 'question'); break; } echo "</label>"; // @@ -672,7 +672,7 @@ $answer = $exploded[1]; // $sequence is an ordered array of the question ids. if (!$sequence = get_field('question_multianswer', 'sequence', 'question', $state->question)) { - print_error("The cloze question $state->question is missing its options"); + print_error('missingoption', 'question', '', $state->question); } $sequence = explode(',', $sequence); // The id of the current question. @@ -799,7 +799,7 @@ $wrapped->partiallycorrectfeedback = ''; $wrapped->incorrectfeedback = ''; } else { - print_error("Cannot identify qtype $answerregs[2]"); + print_error('unknownquestiontype', 'question', '', $answerregs[2]); return false; } The multianswer being the only one of its type in the actual question bank, identifying which subquestion have a problem needs specific infos. So I propose to create specific message in lang qtype_multianswer.php and refer to them in the print_erro call. If you agree, I will do the necessary work so that you can continue on the 620 left ... There are some hidden error calls in question code related to the return from questiontype save_question_options()
i.e. line 366 of question/type/questiontype.php $result->error = "No data for field $field when saving " . $this->name() . ' question id ' . $question->id; and used line 318 as if (!empty($result->error)) { print_error($result->error); } they can be found by searching ->error in question files. I will take care of them In addition, some print_error like:
print_error( $this->error ); This command will help you find them: grep "print_error([$ ]" --color -rn . All done!! (Is this the longest change list in moodle?)
Please reopen it if you find more unfixed print_error calls or hidden ones, TIA. It is OK for direct print_error calls, however the main project is also to remove all hardcoded error messages and in question code the work on indirect error is not finished. so don't close.
Hi Dongsheng,
Thanks for your hardworking :-) I fixed some of your new strings as below. [error.php] -$string['csvloaderror'] = 'Error occur during loading vcs file!'; +$string['csvloaderror'] = 'Error occur during loading CSV file!'; [scorm.php] -$string['cannotfindsco'] = 'Cannot found SCO'; +$string['cannotfindsco'] = 'Could not find SCO'; And we need to add one more string $string['secretalreadyused'] to error.php. This string is used for login/forget_password.php. Mits Pierre,I changed the indirect error:
print_error($result->error); to: print_error('questionsaveerror', 'question', '', $result->error); It is ugly, do you have any better idea? I found more indirect error in other modules, I made a "TODO" mark in source code. Thanks, Mitsuhiro, there may be many other mistakes, this issue reopened
I found $string['secretalreadyused'] in lang/en_utf8/moodle.php, I copied one to error.php
The main idea is that result->error contains the correct string using the get_string('erroe..','question or qtype')
so that you use print_error($result->error); Hi Dongsheng,
there are still calls to error() in the HEAD versions of mod/data/lib.php and mod/data/preset.php Thanks, Robert, I will fix them tomorrow :-)
Robert, I replaced all error() calls in data mod. It seems some print_error calls are reverted when I focus on this issue, that why I didn't find them.
More work need to be done :) Thank you for your quick response, Dongsheng!
I just replaced "invildpreset" by the proper wording "invalidpreset" introduced by your last commit. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||