Merge branch 'MDL-57742_master' of git://github.com/markn86/moodle
[moodle.git] / lib / classes / event / competency_user_evidence_updated.php
blob69c25f20a70486262d5e6b389d4e56cecbfaab39
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
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.
8 //
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/>.
17 /**
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
24 namespace core\event;
26 use core\event\base;
27 use core_competency\user_evidence;
29 defined('MOODLE_INTERNAL') || die();
31 /**
32 * Evidence of prior learning updated event class.
34 * @property-read array $other {
35 * Extra information about event.
36 * }
38 * @package core_competency
39 * @since Moodle 3.1
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 {
45 /**
46 * Convenience method to instantiate the event.
48 * @param user_evidence $userevidence The evidence of prior learning.
49 * @return self
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')
59 ));
60 $event->add_record_snapshot(user_evidence::TABLE, $userevidence->to_record());
61 return $event;
64 /**
65 * Returns localised general event name.
67 * @return string
69 public static function get_name() {
70 return get_string('eventuserevidenceupdated', 'core_competency');
73 /**
74 * Returns non-localised description of what happened.
76 * @return string
78 public function get_description() {
79 return "The user with id '$this->userid' updated the evidence of prior learning with id '$this->objectid'.";
82 /**
83 * Returns relevant URL.
85 * @return \moodle_url
87 public function get_url() {
88 return \core_competency\url::user_evidence($this->objectid);
91 /**
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;