Moodle Grade Book Plugins

My Internet has been down from late Friday (30th of May) night till about mid week and still is dropping a lot of packets thanks to bell, witch has made it some what difficult to look at the references for PHP and Moodle but I still have hopes to have a demo of the text based statics plug in done by this Friday or at worst this weekend.

One of the big things in Moodle is it’s modular design witch makes it rather easy to drop in new components and plug-ins with out having to change much if any of the existing code. Grade book plug-ins are no exception to this and can be dropped in to grade book by making a new directory in grade/report/ with the name of your plug-in, then a few files need to be created inside it:

/grade/report/[yourplugin]/db/access.php
<?php
$gradereport_stats_capabilities = array(
'gradereport/stats:view' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),
);
?>

This file controls the access to your plug-in and the risk of giving roles access to it. I believe these settings are turned into new rows in the capabilities part of the database.

/grade/report/[yourplugin]/lang/en_utf8/gradereport_[yourplugin].php
<?php
$string['modulename'] = '[yourplugin'sname]';
$string['[yourplugin]:view'] = 'View [nameofyourpluginsreport] report';
?>

This is the langue file where all the strings should go so they can be easly transalted if need be. ‘modulename’ and ‘[yourplugin]:view’ and used threw out Moodle and should be set as a minimum.

/grade/report/[yourplugin]/version.php
<?php
$plugin->version = 2008060500;
$plugin->requires = 2008060500;
?>

This is the version file for the plug-in and should use the current date.

/grade/report/[yourplugin]/index.php
This is the file that will be ran/viewed when the user views the report. Links to it will be automatically generated if you set everything up correctly.

/grade/report/[yourplugin]/lib.php
It is recommend that you use this file to make a class witch extends the grade_report class to get access to use full methods and variables to make your report plug-in however it is not necessary to do so and a plug-in could be developed with out this file.

For my text based statistics plug-in i have made an harvest, report and adapter methods in side a class witch extends grade_report. Then to keep with the modular design, i have made an abstract class called stats witch can be extended to add in new statistics with out modifying other parts of the plug-ins code. Currently i have highest, lowest, median, mode, mean and standard deviation sub classes but a new statistics could be added by simply making a new class that extends stats and has a report method to calculate it (more about the design in my next blog post).

For more information about grade book plugi-in’s in Moodle see the tutorial here.

3 Responses to “Moodle Grade Book Plugins”

  1. The Third Bit » Blog Archive » Three Weeks and Change Says:

    […] Daniel Servos likes Moodle plugins. […]

  2. Three Weeks and Change « Software Carpentry Says:

    […] Daniel Servos likes Moodle plugins. […]

  3. Software Carpentry » Three Weeks and Change Says:

    […] Daniel Servos likes Moodle plugins. […]

Leave a Reply