MDL-44017 Events: Deprecated content_viewed event

Replaced content_viewed event with appropriate events and deprecated
content_viewed event
This commit is contained in:
Rajesh Taneja 2014-03-04 16:13:28 +08:00
parent 0a489777fc
commit e1b16f9773
39 changed files with 1291 additions and 453 deletions

View file

@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class chapter_viewed extends \core\event\content_viewed {
class chapter_viewed extends \core\event\base {
/**
* Returns description of what happened.
@ -81,17 +81,4 @@ class chapter_viewed extends \core\event\content_viewed {
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'book_chapters';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
// Hack to please the parent class. 'view chapter' was the key used in old add_to_log().
$this->data['other']['content'] = 'view chapter';
parent::validate_data();
}
}

View file

@ -28,18 +28,15 @@ defined('MOODLE_INTERNAL') || die();
/**
* mod_chat sessions viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* @type int start start of period.
* @type int end end of period.
* }
* @property-read array $other Extra information about the event.
* -int start: start of period.
* -int end: end of period.
*
* @package mod_chat
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class sessions_viewed extends \core\event\content_viewed {
class sessions_viewed extends \core\event\base {
/**
* Returns description of what happened.
@ -96,8 +93,12 @@ class sessions_viewed extends \core\event\content_viewed {
* @return void
*/
protected function validate_data() {
// The parent class requires this to be non-empty. We are setting it and ignore the parent validation.
$this->data['other']['content'] = '';
if (!isset($this->data['other']['start'])) {
throw new \coding_exception('The property start must be set in other.');
}
if (!isset($this->data['other']['end'])) {
throw new \coding_exception('The property end must be set in other.');
}
}
}

View file

@ -28,17 +28,11 @@ defined('MOODLE_INTERNAL') || die();
/**
* Event for when a choice activity report is viewed.
*
* @property-read array $other {
* Extra information about event.
*
* @type string content viewed content identifier.
* }
*
* @package mod_choice
* @copyright 2013 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class report_viewed extends \core\event\content_viewed {
class report_viewed extends \core\event\base {
/**
* Init method.
@ -58,6 +52,15 @@ class report_viewed extends \core\event\content_viewed {
return get_string('event_report_viewed', 'choice');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id $this->userid has viewed report for choice with instanceid $this->objectid";
}
/**
* Returns relevant URL.
* @return \moodle_url