Creating external database based on new students - **HELP**

Creating external database based on new students - **HELP**

by Shaun Reiger -
Number of replies: 5

Hi I want to be able to creat a new database entry in an external database base on a new student being added to the moodle system. But I'm strugling to figure out the best way to accomplish this task. I could build a block that checks the status of a parameter set when I create the student or I could hack in to the moodle core and do this when I click the submit button for the add a new student.

 

I'm new to moodle development and would appreachate if anyone could guide me in the right direction on this issue.

 

Cheers,

Average of ratings: -
In reply to Shaun Reiger

Re: Creating external database based on new students - **HELP**

by Hubert Chathi -

Moodle has an events systems that can run arbitrary functions when certain events happen.  One of those events in user creation.  Unfortunately, not every authentication plugin triggers the 'user_created' event (but the manual plugin does, so if you're just creating users manually, then you're OK).

The documentation that is available for the events system is here.

In reply to Hubert Chathi

Re: Creating external database based on new students - **HELP**

by Shaun Reiger -

Hi Hubert, thanks for the response. I'm wondering where I would build this event handler to responed to the new user creation.  As well when I respond to an event will I be able to find out if the admin checked create external database when he created the user. Will this be part of the event object that I can access. These questions are probably easy, but I'm new to the whole Moodle environment.

 

Cheers,

In reply to Shaun Reiger

Re: Creating external database based on new students - **HELP**

by Hubert Chathi -

I don't remember which plugin types can register event handlers in 1.9, but I know that blocks can.  In 2.0, probably all plugin types can register event handlers, and you probably want to use a local plugin.

The event data only includes the user record.  It will not include any extra form fields that you create.  But if you use a user custom field, then you can fetch that data based on the user record that you are given.

In reply to Hubert Chathi

Re: Creating external database based on new students - **HELP**

by Shaun Reiger -

Hi Hubert,

This is great news, but I'm not sure how I would create and install a local plugin. From the documention which is very shallow on the topic, would I create a file in the enrol folder then add a file to it called enrol.php. I'm kind of stuck on this. I would prefer not to use a block, and keep the code behind the sceens.

Cheers,

In reply to Hubert Chathi

Re: Creating external database based on new students - **HELP**

by Shaun Reiger -

Hubert,

I have been trying to build a local event to handle the user_created event but with no luck. I have a function that is setup in a lib.php file and a event.php file that outlines the location and type of event to handle. But when I create a user nothing happens. What are the requirement for handling events with in the local folder. More specificly what are the setup to the local files to handle this type of event.

 

Thanks for your feedback.