2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Evidence of prior learning updated event.
20 * @package core_competency
21 * @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 use core_competency\user_evidence
;
29 defined('MOODLE_INTERNAL') ||
die();
32 * Evidence of prior learning updated event class.
34 * @property-read array $other {
35 * Extra information about event.
38 * @package core_competency
40 * @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
43 class competency_user_evidence_updated
extends base
{
46 * Convenience method to instantiate the event.
48 * @param user_evidence $userevidence The evidence of prior learning.
51 public static final function create_from_user_evidence(user_evidence
$userevidence) {
52 if (!$userevidence->get('id')) {
53 throw new \
coding_exception('The evidence of prior learning ID must be set.');
55 $event = static::create(array(
56 'contextid' => $userevidence->get_context()->id
,
57 'objectid' => $userevidence->get('id'),
58 'relateduserid' => $userevidence->get('userid')
60 $event->add_record_snapshot(user_evidence
::TABLE
, $userevidence->to_record());
65 * Returns localised general event name.
69 public static function get_name() {
70 return get_string('eventuserevidenceupdated', 'core_competency');
74 * Returns non-localised description of what happened.
78 public function get_description() {
79 return "The user with id '$this->userid' updated the evidence of prior learning with id '$this->objectid'.";
83 * Returns relevant URL.
87 public function get_url() {
88 return \core_competency\url
::user_evidence($this->objectid
);
92 * Initialise the event data.
94 protected function init() {
95 $this->data
['objecttable'] = user_evidence
::TABLE
;
96 $this->data
['crud'] = 'u';
97 $this->data
['edulevel'] = self
::LEVEL_OTHER
;
101 * Get_objectid_mapping method.
103 * @return string the name of the restore mapping the objectid links to
105 public static function get_objectid_mapping() {
106 return base
::NOT_MAPPED
;