Execute Code on Course Access

Re: Execute Code on Course Access

by Suraj Kumar -
Number of replies: 0

Dear Amy,

Both the ideas suggested by @Mark Johnson are quite good. You can also go with creating a local plugin and declaring a callback for event '\core\event\course_viewed' in db/events.php

like-

$observers = array(   array( 'eventname' => '\core\event\course_viewed', 'callback' => 'local_myplugin_observer::course_viewed_custom' );

https://docs.moodle.org/dev/Event_2

And, add settings.php for your plugin where you can add courses(course ids separated by commas) so that you can filter later the courses to be processed through event api.

Thanks.