Hi, im trying to add an event to the logging report provided by moodle in site admin.
As i understand this has to be done by triggering an event. So triggering an event = event registers in logs?
I'm unsure if im doing this correctly since nothing is being added to the logs.
I went trough some plugins i had installed and noticed they didnt use observers for their events.
For testing purposes im trying to trigger the event once a course is viewed.
Currently i have this file structure
- plugin
- index.php
- classes
- event
- plugin_viewed.php
- plugin_viewed.php
- event
- (other_files)
My index.php has the following relevant lines
$context = context_system::instance();
$event = \plugin\event\plugin_viewed::create(array('login' => $Login));
$event->trigger();
My plugin_viewed.php file has the following
<?php
namespace plugin\event;
defined('MOODLE_INTERNAL') || die();
class plugin_viewed extends \core\event\course_viewed {
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->login' viewed plugin" ;
}
/**.
/**"course module id '$this->contextinstanceid'.";
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
}