#76 Added standard course viewed events
This commit is contained in:
parent
325c5330d6
commit
041d49998e
4 changed files with 93 additions and 0 deletions
37
classes/event/course_module_instance_list_viewed.php
Normal file
37
classes/event/course_module_instance_list_viewed.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Contains the course module instance list viewed event class.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
||||
* @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 <markn@moodle.com>
|
||||
* @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 {
|
||||
}
|
41
classes/event/course_module_viewed.php
Normal file
41
classes/event/course_module_viewed.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Contains the course module viewed event class.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
||||
* @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 <markn@moodle.com>
|
||||
* @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();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
8
view.php
8
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.
|
||||
|
|
Loading…
Reference in a new issue