Sajin Shereef
Sajin Shereef

Reputation: 119

Can we get course start callback and complete callback response from moodle to our system?

When a student starts a course in moodle, we need to update our system with the date with which they started the course. So we need to get a response from moodle to update that in our system, same for course completion.

Upvotes: 0

Views: 426

Answers (1)

forloops
forloops

Reputation: 329

You cannot get first course access in moodle 3+. This action is not logged anymore, you can only get last access (unless you are on an older Moodle).

You can get the last access date to a course by querying the mdl_logstore_standard_log for the event "\core\event\course_viewed" event.

For example:

SELECT * FROM mdl_logstore_standard_log WHERE eventname = '\\core\\event\\course_viewed' AND userid=?

To get the course completed date, you can search for event "\core\event\course_completed". for example:

SELECT * FROM mdl_logstore_standard_log WHERE eventname = '\\core\\event\\course_completed' AND userid=?

If you want to get the date they were enrolled, you can use this query:

SELECT u.username, u.lastname, u.firstname, c.fullname, DATE_FORMAT(FROM_UNIXTIME(ue.timecreated), '%Y-%m-%d %H:%i') AS 'DateAndTimeCreated' FROM mdl_user_enrolments ue LEFT JOIN mdl_enrol e ON (ue.enrolid = e.id) LEFT JOIN mdl_course c ON (e.courseid = c.id) LEFT JOIN mdl_user u ON (ue.userid = u.id)

I would recommend creating a local plugin and using cron to check for changes and push them into your system.

Upvotes: 2

Related Questions