Note:

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

Gradebook import

From MoodleDocs

Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.


Introduction

This document is for developers wanting to allow users to import Moodle grade information in a format that is not currently supported by Moodle. Here is another document if you are looking for an introduction to importing grades into Moodle

Moodle allows authorised users to import grade information. This can be used to transfer student grades from another piece of software into Moodle.

Since 1.9 the Moodle gradebook has provided support for the addition of plug-in import modules to allow Moodle to import grade information in new or custom formats. Moodle includes two default gradebook import modules, csv and xml.

This document describes how to implement a custom gradebook import plug-in.

Getting started

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

Note: For the remainder of this topic when you see [newimport], replace it with the short name you chose for your import module. Do not include the []. Moodle comes with the following import modules: csv and xml so you cannot use those names.

New Gradebook Import Creation Steps

  • Decide on a short name for this new import module. This name will be referred to as [newimport] in this document.
  • Create a new directory in Moodle's grade/import directory for your files.
  • Review the import formats that ship with Moodle and choose the import format most like the one you wish to develop. Refer to that import's files as needed. csv is the simplest.
  • Copy the files from the import format you selected into your newly created directory of grade/import/[newimport]
  • Alter each of the files listed below.
  • Click on Notifications link in the Site Administration menu to go through the upgrade process (if one didn't happen automatically) and set up the permissions for your import module.
  • Test, test, test - until your import module performs properly.

/grade/import/[newimport]/db/access.php

The access.php file makes your gradebook import module available to teachers and allows the security administrator to decide who can and cannot access the module. See the "View role details" page in Site Administration > Users > Permissions > Define roles for more details.

Review access.php of both csv and xml import modules and decide which capabilities make sense for your import module. Make sure to replace any references to the module you copied from with [new].

The new security role entries will be available after an upgrade has been completed (click the Notifications link in Site Administration). This should not be done until you have worked through each of the files listed in this section.

Note: The gradeimport_[newimport].php file in the lang directory works with the :view and :publish settings to provide a description. See the information about that file for more details.

See also