You'll need to create a local plugin.
http://docs.moodle.org/dev/Local_plugins
Create the plugin in /local/myplugnname
Create an events.php file
/local/mypluginname/db/events.php
With this
$handlers = array (
'course_completed' => array (
'handlerfile' => '/local/mypluginname/lib.php',
'handlerfunction' => 'local_mypluginname_course_completed',
'schedule' => 'cron',
'internal' => 1,
),
Have a look here for more info http://docs.moodle.org/dev/Events_API#Handling_an_event
You'll need a version.php file to install the plugin and add the event handler.
Then create a function
function local_mypluginname_course_completed($eventdata)
in
/local/mypluginname/lib.pgp
This will be called when the cron runs
To find out the contents of $eventdata have a look at
events_trigger('course_completed', $this->get_record_data());
in
/completion/completion_completion.php
To update a remote database have a look at the code in db authentication
/auth/db/auth.php
Something like
$mydb = ADONewConnection('mysql');
$mydb->Connect($dbhost, $dbuser, $dbpass, $dbname, false);
$mydb->Execute($insertsql);
$mydb->Close();