diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php new file mode 100644 index 0000000..f11c1bd --- /dev/null +++ b/classes/event/course_module_instance_list_viewed.php @@ -0,0 +1,37 @@ +. + +/** + * Contains the course module instance list viewed event class. + * + * @package mod_customcert + * @copyright 2017 Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_customcert\event; + +defined('MOODLE_INTERNAL') || die(); + +/** + * The course module instance list viewed event class. + * + * @package mod_customcert + * @copyright 2017 Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { +} diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php new file mode 100644 index 0000000..509d28f --- /dev/null +++ b/classes/event/course_module_viewed.php @@ -0,0 +1,41 @@ +. + +/** + * Contains the course module viewed event class. + * + * @package mod_customcert + * @copyright 2017 Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_customcert\event; + +defined('MOODLE_INTERNAL') || die(); + +/** + * The course module viewed event class. + * + * @package mod_customcert + * @copyright 2017 Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class course_module_viewed extends \core\event\course_module_viewed { + protected function init() { + $this->data['objecttable'] = 'customcert'; + parent::init(); + } +} diff --git a/index.php b/index.php index 52d895d..bc85fa6 100644 --- a/index.php +++ b/index.php @@ -40,6 +40,13 @@ $pageurl = new moodle_url('/mod/customcert/index.php', array('id' => $course->id $PAGE->set_pagelayout('incourse'); $PAGE->navbar->add(get_string('modulenameplural', 'customcert')); +// Add the page view to the Moodle log +$event = \mod_customcert\event\course_module_instance_list_viewed::create(array( + 'context' => context_course::instance($course->id) +)); +$event->add_record_snapshot('course', $course); +$event->trigger(); + // Get the customcerts, if there are none display a notice. if (!$customcerts = get_all_instances_in_course('customcert', $course)) { echo $OUTPUT->header(); diff --git a/view.php b/view.php index 4b847cc..21a06be 100644 --- a/view.php +++ b/view.php @@ -51,6 +51,14 @@ if ($customcert->requiredtime && !has_capability('mod/customcert:manage', $conte } } +$event = \mod_customcert\event\course_module_viewed::create(array( + 'objectid' => $customcert->id, + 'context' => $context, +)); +$event->add_record_snapshot('course', $course); +$event->add_record_snapshot('customcert', $customcert); +$event->trigger(); + // Check that no action was passed, if so that means we are not outputting to PDF. if (empty($action)) { // Get the current groups mode.