Moodle L2P local_sd_sync module
This project is based on the core pugin enrol_database. It synchronises courses and appointments from an external database with the Moodle system.
Features:
- Course field description in addition to the fields from the original plugin.
- Course synchronisation on changes of the fields title and description in external database.
- Appointments from external database are synchronised as calendar events in moodle.
This plugin adds an additional table to the moodle database to identify the calendar event source. Synchronised calendar events from external database are marked with 'rwthonline' as event source.
Like the enrol_database plugin this plugin creates courses that do not exist yet in Moodle. No courses are deleted though, if they do no longer exist in the external database.. Appointments marked for synchronisation are updated and delted on corresponding changes in the external database.
Prerequisites
Moodle installation
Dependencies
- PHP as defined by Moodle
- Moodle 3.x
Installation
Deploy project into moodleroot/local folder (Module path has to be moodleroot/local/rwth_sd_sync).
Configuration
The plugin has to be configured by a site-administrator via the web interface.
- Go to Site administration -> Plugins -> Local -> RWTH Sitedirectory synchronisation
- Configure the database connection and field mappings
To make sure users can't edit or delete the events synchronized by this plugin take the capability 'moodle/calendar:manageentries' away from them.
Synchronization
cronjob
The folder local/rwth_sd_sync/cli contains a sync.php file. That is the script which synchronises course and event data from the sitedirectory to Moodle.
You can add a cron entry for that file to make it run on its own:
# every 15 minutes
*/15 * * * * /usr/bin/php /path/to/moodle/local/rwth_sd_sync/cli/sync.php
Moodle scheduled task
The plugin implements the scheduled task interface. Admins can configure a schedule via the Moodle Admin interface. The cronjob way should be preferred though.
Development
Whenever changes are made to the moodle database, they have to be pushed into moodle:
- Increase plugin->version in version.php
- (Redeploy the plugin, if not on development machine.)
- Go to moodle-UI site administration and perform module upgrade (If no upgrade is available for this module, something went wrong).
Tests
- Requires PHPUnit. See moodle docs for how to configure PHPUnit with Moodle.
- Tests are located in moodleroot/local/rwth_sd_sync/tests.
- To run tests from this module, exectue e.g. moodleroot/vendor/bin/phpunit local_rwth_sd_sync_testcase local/rwth_sd_sync/tests/sync_test.php