mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-40059 glossary: event course_module_viewed
This commit is contained in:
parent
9b8555fbea
commit
3dbe89ac62
70
mod/glossary/classes/event/course_module_viewed.php
Normal file
70
mod/glossary/classes/event/course_module_viewed.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* This file contains an event for when a glossary activity is viewed.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @copyright 2014 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_glossary\event;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event for when a page activity is viewed.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @copyright 2014 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class course_module_viewed extends \core\event\course_module_viewed {
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'r';
|
||||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
||||
$this->data['objecttable'] = 'glossary';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL related to the action.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
$params = array('id' => $this->contextinstanceid);
|
||||
if (!empty($this->other['mode'])) {
|
||||
$params['mode'] = $this->other['mode'];
|
||||
}
|
||||
return new \moodle_url("/mod/$this->objecttable/view.php", $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function get_legacy_logdata() {
|
||||
// In moodle 2.6 and below the url was logged incorrectly, always having tab=-1 .
|
||||
return array($this->courseid, $this->objecttable, 'view',
|
||||
'view.php?id=' . $this->contextinstanceid . '&tab=-1',
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
}
|
@ -124,11 +124,6 @@ if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $con
|
||||
echo $OUTPUT->header();
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", $glossary->id, $cm->id);
|
||||
|
||||
// Mark as viewed
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
/// stablishing flag variables
|
||||
if ( $sortorder = strtolower($sortorder) ) {
|
||||
@ -229,6 +224,21 @@ default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Trigger module viewed event.
|
||||
$event = \mod_glossary\event\course_module_viewed::create(array(
|
||||
'objectid' => $glossary->id,
|
||||
'context' => $context,
|
||||
'other' => array('mode' => $mode)
|
||||
));
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('glossary', $glossary);
|
||||
$event->trigger();
|
||||
|
||||
// Mark as viewed
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
/// Printing the heading
|
||||
$strglossaries = get_string("modulenameplural", "glossary");
|
||||
$strglossary = get_string("modulename", "glossary");
|
||||
|
Loading…
x
Reference in New Issue
Block a user