Moodle development traffic 13/2010

Latest stable version 1.9.8+

There are 6 commits into MOODLE_19_STABLE from the last development week (from Tuesday to Monday). Tim Hunt fixed a gradebook bug occurring during repeated imports of grades that are normally pushed into the gradebook from activity modules or are calculated and can be overridden (MDL-21987). Petr Å koda fixed incorrect usage of E_ALL constants which lead to deprecation warnings in PHP 5.3 and therefore break output when generating images. Developers must use our DEBUG_xxx constants only (MDL-22006). I committed two patches that could not land at the stable branch during our recent code freeze. The first one may be useful for developers who are debugging some emailing feature in Moodle. It allows to divert all outgoing emails generated by Moodle to a single recipient (MDL-18903). The second one fixes a bug in multilang support for custom profile field labels (MDL-21845). Helen Foster (accessing CVS via command line as all real hackers do!) improved wording of a recently introduced gradebook option and added a missing help file for it (MDL-21218).

Unstable development version 2.0dev

There are 51 commits into the main development branch.

Quotes of the week

“It’s easier to say sorry than to ask permission”
Penny Leach on committing procedure

Pruning the trees of code

The spring comes to the central Europe. For gardeners, it is time to clean up the orchards and prune the apple trees (which may turn into kind of physical exercise both with and without the chain saw). For hackers, this season is perfect for cleaning up the source codes and getting rid of zombies hiding here and there. We are currently working on localization subsystem in Moodle and there was a good opportunity to remove some not-so-nice hacks and rules that were present for a long time.

If you have ever developed a plugin for Moodle 1.x, you probably know Moodle defines strings as items in an associative array, for example

$string['greeting'] = 'Hello world';

For some known reasons, there are several rules that developers must follow when adding new strings into the English language pack (and translators when editing the packages manually) at Moodle 1.x. Some of them are not much intuitive, like double quotes must be always escaped as in

$string['author'] = 'Petr \"skodak\" Skoda';

When you want to display a percentage sign, you must remember to actually type double %% to get just one:

$string['maxgrade'] = 'Max grade exceeds 100%%';

Replacing placeholders in Moodle with their values has been always done by eval(). So everybody had to properly quote all other occurrences of the dollar sign in order not to get it replaced by the real value of producing an error (or white screen of PHP death):

$string['greeting'] = 'Hello $a->firstname, how are you?';
$string['configerror'] = 'Your \$CFG->wwwroot is not correct';

As you can imagine, it was pretty easy to make a mistake. And various syntax-related mistakes were really done by developers and by translators as well.

Luckily, the format of $string[] items was significantly simplified for Moodle 2.0. The basic principle now is what you type is what you get. That means that developers no longer need to think too much about the $string syntax. In Moodle 2.x, all the following strings will be displayed as expected:

$string['author'] = 'Petr "skodak" Skoda';
$string['maxgrade'] = 'Max grade exceeds 100%';
$string['configerror'] = 'Your $CFG->wwwroot is not correct';

If the string contains a placeholder to be replaced with a value, it must be enclosed in curly brackets:

$string['foo'] = 'This {$a} will be replaced with a value';
$string['bar'] = 'This $a will be printed as a dollar sign followed by the a letter';

Good news is we no more use eval() on the whole string so it is much easier to detect and fix errors. Even better news is that all existing 1.x strings will be automatically converted into the new syntax format. The current plan is to switch to the new strings format during the next week, after we debug the new implementation of get_string() a bit and migrate all core strings into the new syntax.


2 Responses to “Moodle development traffic 13/2010”

Leave a Reply

Spam Protection by WP-SpamFree Plugin




film streaming sur Megaupload