Thursday, April 19, 2012

Be careful when using custom plug-in code

So moodle is all about modularity.  Is designed with design in mind. Recently, I took a shot at adding a new option to the native moodle user reporting.  After reminding myself of how moodle likes you do do things, I added a new folder complete with all the moodle compliance necessary.  I added the new folder in the moodle\grade\report folder. Upon adding a folder here, moodle, as it does when you add new folders in other places, sees it and brings up the Plugins check form.


 I let the install do its thing and then browsed to where I expected to see the new selection, see the Student AU report option, that's the one I added.



My first realization that I had broke something was when I looked at my automated course backups and saw that they had not backed up for a couple days.  This lead me to look in the php error file, where I saw a re-occurring error message that there was a conflict with a existing method name in a core lib file.

PHP Fatal error:  Cannot re-declare class grade_report_user in C:\wamp\www\moodle\grade\report\user\lib.php on line 744

Hmmm, must be since I copied the report\user folder and renamed it studentau, that I created a conflict in the lib.php file, each of them is declaring the same class.  I am going to remove the class from the file in the studentau folder and see if that is what is causing the problem.

Two things come to mind, 1 - know the moodle API (which i really don't that well) 2 - Either turn on message debugging so it reports to the screen (when im doing stuff like this) or check the php error log when im doing stuff like this (developing plug-ins).


No comments:

Post a Comment