Facebook-like Notifications

Facebook-like Notifications

by Trolling in the Deep -
Number of replies: 10

Can someone give me an initial tutorial on how to implement a facebook-like notification in Moodle?

Average of ratings: -
In reply to Trolling in the Deep

Re: Facebook-like Notifications

by Christopher O'Kelly -

Are you talking about the little window showing up in the bottom right in realtime or moreso the email notifications?

If the first I would look at the code that generates the new message notifications. I couldn't say off the top of my head but logicwise the way I would do it is to use javascript to set an interval (google js setInterval). Not sure how much js you have worked with before, but if you aren't aware this is basically a repeated, timed event (every x milliseconds do y).

 

You'll want the function called by the interval to run an AJAX call. Most of the js development I have done is not with Moodle - it is with Alfresco, which has capabilities for server side javascript. I am not aware of moodle having the same capability (although I am not specifically aware of it NOT having this capability either). If it does/did then I would have the AJAX call post the current username to a server side JS to mine the database for new events to notify the user of (you may also need to add another table to the db and some logic to remember which events x user has been notified of already). Finally, I would have the server side js return a json object with an array of the events to the original page which would render the results, most likely in a div which you could either change the display value of ("none" by default, "block" or whatever else when a new event arrives, "none" again when the user clicks it or after a set time, use js setTimeout() for this) or change the opacity value of (filter: alpha(foo) for IE) if you prefer a more sexy fade effect.

I know that even without server side JS there are other ways to send AJAX calls and receive responses, I am just not sure what they are or how to implement them.

I may be over-complicating the issue but at least the way I see it this is no minor change, it will require a good deal of work.

 

On the other hand, if it is just email notifications you are looking for I would find the scripts that execute actions you want to notify users of (for instance, perhaps, /calendar/event.php for new event creation) and add a mail section. This would be alot more simple, though you may end up copying alot of your code to quite a few files to get all the actions you want notified.

 

Sorry for the lack of actual code as well btw, I'm not really in the right place to be able to type it up. Good luck!

In reply to Christopher O'Kelly

Re: Facebook-like Notifications

by Trolling in the Deep -

Yeah. I figured it would require a huge amount of work. I mean, I want to implement something like when a teacher uploads a quiz, the student gets the following:

1. email 

2. notification about it within the site

--

If every activity (Exam, Assignment, Grading) will have this implemented, a change in the database is also mandatory, right? 

In reply to Trolling in the Deep

Re: Facebook-like Notifications

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The Moodle notification system in Moodle 2 does allow users to control how messages are received. Built in, there is support for email, jabber chat and Moodle messaging. It is fairly straight forward to add a new message and you should be able to create a local plugin that responds to 'new activity created' events and sends out notifications; all without core modifications.

I'd offer a bit more help, but I'm typing this on my phone, so can't look it up at the moment.

Btw, for extra credit you could implement a new notification type of 'pop up message' (unless that already exists and I've missed it).
In reply to Davo Smith

Re: Facebook-like Notifications

by Trolling in the Deep -

WOW. Really? Thanks guys.

Hey Davo, perhaps you can point me to the right direction on how to implement it. I mean, I really don't know where to start.

I've been hacking/editing moodle for the last 3 months and this is the last function that the client wants to happen.

Thanks for the help.

In reply to Trolling in the Deep

Re: Facebook-like Notifications

by Mr. Marc -

is there a way for a student to like a forum post like you can like a post in Facebook?  I know about rating a post i'm talking about additional to that.

In reply to Trolling in the Deep

Re: Facebook-like Notifications

by Hubert Chathi -

You can look at existing messaging plugins in /message/output, and is documented here: http://docs.moodle.org/dev/Messaging_2.0.  You are probably most interested in the "Adding new message type" and "Message outputs (processors)" sections.

Moodle's events system is documented here: http://docs.moodle.org/dev/Events.

In reply to Hubert Chathi

Re: Facebook-like Notifications

by Trolling in the Deep -

Thank you. 

I am reading on "events" right now.

Is it possible to do something like:

If a teacher uploads an assignment.

- the students of the course will receive a popup notification when he logs in

if a student answers the assignment

- the teacher will receive a pop up notif when he logs in

-----

if the pop up is clicked..it will land to a page "recent notifications" page like in the "messaging"

In reply to Trolling in the Deep

Re: Facebook-like Notifications

by Hubert Chathi -

You can check for new messages in a block (see the messages block that comes with Moodle), and add in any code you need to display the popup.

In reply to Hubert Chathi

Re: Facebook-like Notifications

by Trolling in the Deep -

how do i add an "event" instance when a teacher uploads an assignment so that it will send a pop up notification to the students enrolled in that course?

I was able to see the send_message function in the message_output_popup class but I dont know how to use it or where to start.

In reply to Davo Smith

Re: Facebook-like Notifications

by Mr. Marc -

I would love to know how or someone point me in the direction of how i can implement into our 2.2 moodle this type of option for every one of our forums.

like