General developer forum

Picture of Manuri Perera
Sending SMS when an important event occurs


I'm new to Moodle. I have a project to create a plugin for Moodle to send SMS to students who subscribe for this service,

1. when a new resource is added to a course

2. At the commencement of a quiz

3. Number of hours defined by the student before an assignment deadline

4. When a new post is posted in a subscribed forum

As I understand I have to develop a block type plugin. And I read about cron method and I think it will be useful. But first what I had in mind was event handling. That is, defining events and developing event handlers so when an event occurs it's event handler will be executed and SMS will be sent. Still haven't found out whether this is possible or suitable though.

I installed Moodle and now figuring out what are the tables I will need.

Any idea on where to begin ? I have to complete this very soon and any help would be highly appreciated. smile


Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Sending SMS when an important event occurs
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Actually, you need to write a message output plugin that sends SMS messages. Then tie into Moodle's messaging API to configure things:

Average of ratings:Useful (1)
Picture of Manuri Perera
Re: Sending SMS when an important event occurs

Thank you for the reply.

Sir could you please tell me if my approach is correct ?

This is the simple picture I have in mind after reading about Moodle a bit.

I have a cron() method inside my block.

Inside that cron() method of my block,

I write the code to check the moodle database for new assignment deadlines, new quizzes, new resource updates, new forums posts 


the code to send SMS via my gateway(I'm going to use Kannel WAP/SMS gateway for this project).

I didn't quite understand your reply since I'm still trying to understand how moodle works and where I should start. Im not familiar with php either but hopefully I'll catch up soon.


Average of ratings: -
Picture of Rex Lorenzo
Re: Sending SMS when an important event occurs
Group DevelopersGroup Particularly helpful MoodlersGroup Testers

Please read the links that Tim had provided. Rather than doing things in a cron, the messaging system will call your messaging handler. So it is a push, rather than a polling type of system.

If there are some events that are not currently triggering a message event, then you can add them in the code.

However, one of your criteria about sending a message when there is X minutes before an assignment is due, will still need to be done in a cron type of event.

Average of ratings:Useful (1)
Picture of Manuri Perera
Re: Sending SMS when an important event occurs

Thank you. smile 

I think event triggering is better than doing this in cron.

As I understood so far, what I have to do is,

for example, when considering adding a new resource, 
1. I should go through the code of resource module and find out where in that code "adding a resource to the database" happens and write code to create an eventdata object and trigger the event(call events_trigger() function) 

2. Then write the event handler function

3. Then I have to insert my handler in events.php inside the db folder of resource module. If events.php doesnt already exist I have to create it

Am I correct ?

Average of ratings: -
Picture of akila pemasiri
Re: Sending SMS when an important event occurs

I too have a same kind of project and there what I have to do is send an fb notification to the user according to the same criteria that Manuri has stated. Would I be able to use the same API s mentioned above?


Average of ratings: -