Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Gradebook export

From MoodleDocs

Introduction

The Moodle 1.9 gradebook provides support for plug-in export modules. Moodle includes several export modules in the release. However, you may need the gradebook data formatted differently than the provided modules. Two primary uses for the gradebook export is to provide a teacher with a point in time copy of their gradebook and to extract student assessment data collected in Moodle so that it can be loaded into a different district software application without having to reenter that data.

Getting started

The gradebook export modules are located in the grade/export directory. To create a new gradebook export, complete the steps listed below.

Note: For the remainder of this topic when you see [newexport], replace it with the short name you have choosen for your export, do not include the []. Moodle 1.9 comes with the following exports: ods, txt, xls, and xml so you cannot use those.

New Gradebook Export Creation Steps

  • Decide on a short name for this new export. This name will be referred to as [newexport] the remainder of this topic.
  • Create a new directory in Moodle's grade/export directory for your export's files.
  • Review the export formats that ship with Moodle and choose the export format most like the one you wish to develop. Refer to that export's files as needed.
  • Copy the files from the export format you selected into your newly created directory of grade/export/[newexport]
  • Alter each of the files listed below so they produce the data you desire.
  • Click on Notifications in the Site Administration menu to setup the permissions for your export format.
  • Test, test, test - until your export performs properly.


/grade/export/[newexport]/db/access.php

The access.php file makes your gradebook export available to teachers and allows the security administrator to decide who can and cannot access this export module.

For your export to have the same permissions as the other exports, change the three lines listed below to your [newexport] name.

    $gradeexport_[newexport]_capabilities = array(
    
        'gradeexport/[newexport]:view' => array(
        'gradeexport/[newexport]:publish' => array(

/grade/export/[newexport]/dump.php

/grade/export/[newexport]/export.php

/grade/export/[newexport]/grade_export_[newexport].php

/grade/export/[newexport]/index.php

/grade/export/[newexport]/version.php

Use the current dates for your export module. If any adjustments are made to your security or if any database changes are needed (see the db/access.php file above) the version will need to be incremented and the Notifications link on the Site Administration menu will need to be clicked.

Your version.php will look something like this ...

    $plugin->version  = 2007092700;
    $plugin->requires = 2007101000;

/lang/en_utf8/gradeexport_[newexport].php

Replace en_utf8 with your language directory if using multiple languages or a language other than English.

The gradeexport_txt.php (Plain text file export) is shown below. Change "Plain text file" to the name of the new export and replace "txt" with the [newexport] value. Change the comments after the ":view" and ":publish" to descriptions that should appear on the role details page for your new export.

    $string['modulename'] = 'Plain text file';
    $string['txt:view'] = 'Use text grade export';
    $string['txt:publish'] = 'Publish TXT grade export';

To better illustrate, if your module had a short name of "sis" and a description of "My Student Info System", then this file would like something like the following ...

    $string['modulename'] = 'My Student Info System';
    $string['sis:view'] = 'Use My SIS grade export';
    $string['sis:publish'] = 'Publish SIS grade export';

See also