Feb
17
2009
I published a simple Moodle block called Course contens. It generates a list of all visible topics/weeks in the course. Clicking at one of these links displays that particular week or topic. What I needed to solve was how to automatically obtain a title for every course section.
The block extracts a suitable title for every week or topic from the section summary. If you start summary with a heading (H1, H2, H3, etc), it will use such heading text. If your summary starts with a bold text, it will be used as a section title. If the summary consists of several paragraphs, the first one will be used. If the summary is empty, a customizable text “Unit X” (where X is the number) is displayed.
Technically spoken, the plain text content of the first non-empty HTML DOM node of the section summary is used as the summary title. I realized that Moodle 1.9 does not contain any HTML parser so the block source code is shipped with a its own Simple HTML DOM parser library (credit goes to S. C. Chen and other contributors).
no comments | tags: moodle, php
Jan
22
2009
Again, I ran into situation when a very o{l|d}d installation of Moodle displayed just an empty page instead of a useful error message. That’s why I again had to play a bit with all these error_reporting and display_error settings. Let me summarise how it works – at least as far as I know.
There are basically four places where PHP configuration parameters can be defined: 1) php.ini, 2) httpd.conf 3) .htaccess and 4) source code itself.
The file php.ini contains site-wide PHP configuration. You can define parameters by assigning them a value – eg display_errors=1
PHP configuration can be defined in Apache configuration as well (either in httpd.conf or a sub-config file included by it). This allows you to redefine defaults from php.ini for a particular directories. You can use statements like php_flag to php_value do it. Or, you can use php_admin_flag or php_admin_value to do the same with the exception that the later form can not be redefined at a lower level again.
If you have “AllowOverride Options” defined in Apache for the given location, you can use .htaccess files to redefine PHP settings. The statements php_flag or php_value can be used in .htaccess files. The forms php_admin_* are not supported at this level.
Finally, you can modify some settings by ini_set() or error_reporting() PHP commands. It seems to me that these are at the same level as .htaccess is. I mean – IMHO there is no way how to disable ini_set() in .htaccess.
What I needed was to disable Moodle code to call error_reporting(0) and ini_set(‘display_errors’, 0). Therefore I had to go a relevant httpd.conf section and use
php_admin_flag display_errors on
php_admin_value error_reporting 2147483647
With this settings, neither .htaccess nor source code itself is able to hide any error message any more.
no comments | tags: apache, moodle, php