Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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.
  13  //
  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/>.
  16  
  17  /**
  18   * Evidence of prior learning updated event.
  19   *
  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
  23   */
  24  namespace core\event;
  25  
  26  use core\event\base;
  27  use core_competency\user_evidence;
  28  
  29  defined('MOODLE_INTERNAL') || die();
  30  
  31  /**
  32   * Evidence of prior learning updated event class.
  33   *
  34   * @property-read array $other {
  35   *      Extra information about event.
  36   * }
  37   *
  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
  42   */
  43  class competency_user_evidence_updated extends base {
  44  
  45      /**
  46       * Convenience method to instantiate the event.
  47       *
  48       * @param user_evidence $userevidence The evidence of prior learning.
  49       * @return self
  50       */
  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.');
  54          }
  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;
  62      }
  63  
  64      /**
  65       * Returns localised general event name.
  66       *
  67       * @return string
  68       */
  69      public static function get_name() {
  70          return get_string('eventuserevidenceupdated', 'core_competency');
  71      }
  72  
  73      /**
  74       * Returns non-localised description of what happened.
  75       *
  76       * @return string
  77       */
  78      public function get_description() {
  79          return "The user with id '$this->userid' updated the evidence of prior learning with id '$this->objectid'.";
  80      }
  81  
  82      /**
  83       * Returns relevant URL.
  84       *
  85       * @return \moodle_url
  86       */
  87      public function get_url() {
  88          return \core_competency\url::user_evidence($this->objectid);
  89      }
  90  
  91      /**
  92       * Initialise the event data.
  93       */
  94      protected function init() {
  95          $this->data['objecttable'] = user_evidence::TABLE;
  96          $this->data['crud'] = 'u';
  97          $this->data['edulevel'] = self::LEVEL_OTHER;
  98      }
  99  
 100      /**
 101       * Get_objectid_mapping method.
 102       *
 103       * @return string the name of the restore mapping the objectid links to
 104       */
 105      public static function get_objectid_mapping() {
 106          return base::NOT_MAPPED;
 107      }
 108  
 109  }