LCMS Writing your own repository data manager

From Dokeos

Jump to: navigation, search

LCMS_Developer_Cookbook

Original author: Tim De Pauw

To make learning objects persistent, i.e. make sure that they may exist outside the scope of the script, we use something called a data manager.

A learning object repository data manager is just another class that resides in the directory repository/lib/data_manager. That class must extend the abstract class RepositoryDataManager and hence implement a couple of methods. The data manager class must use a fixed naming scheme. Say the data manager you are creating is based on flat files—which may not be that useful, but for argument’s sake, bear with us. You will want to name your class aptly, i.e. make it clear that this particular repository data manager deals with flat files. All repository data manager class names must end in RepositoryDataManager, so you will probably want to name yours FlatFileRepositoryDataManager.

The class definition is stored in a file which uses a similar filename. You leave off the RepositoryDataManager part of your class name, and convert the rest from camel case to lowercase separated by underscores. For instance, FlatFile would become flat_file and FlatFileRepositoryDataManager would be defined in the file repository/lib/data_manager/flat_file.class.php. Consequently, if the user configures a data manager type, Dokeos automatically loads the corresponding PHP file and instantiates the corresponding class.

For a list of functions that every RepositoryDataManager must implement, we recommend you consult the API documentation, which has a detailed explanation of each function’s purpose.

Personal tools