Help with events!

Re: Help with events!

by Mike Churchward -
Number of replies: 0
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Alejandro -

To answer the original question, there are no specific events generated (assuming you mean the Moodle events system) for entering or exiting a course. This is because there is no easy way to determine this.

To develop a plugin that determines this, you would first need to define what actions constitute entering and exiting a course.

For example, if use access the course from the "view" page (e.g. http://[yoursite]/course/view.php?id=2), a "course viewed" event will be generated to the logging system. If a user goes directly to an activity in the course (e.g. http://[yoursite]/mod/page/view.php?id=10), a "course module event" will be generated for that module. Both of these events could be considered to be an "enter the course" event, if the user was not previously considered already "entered".

Likewise, what actions do you want to consider as "exiting the course"? A user could login, look at a course resource, and then leave for a holiday with their session logged in. At what point after that would you consider there to have been an "exit the course" action?

Other people have created plugins, such as reports, to estimate the amount of time a user spends in a course. But it will always be at best a inaccurate estimate. You can never be sure that the user actually did anything useful in that time. Typically these estimates comb through the log records, looking for unbroken entries for a specific course, and adding up the time differences. You also have to consider using the session timeout setting for the site. This is the amount of inactive time a user is allowed before they are automatically logged out. If you can't find log records for a user from one entry to the next that is within that time frame, you should assume that they were inactive and left the session.

Hope this helps, and good luck.

mike