Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are 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 deleted 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 deleted 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_deleted 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('eventuserevidencedeleted', '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' deleted the evidence of prior learning with id '$this->objectid'.";
  80      }
  81  
  82      /**
  83       * Initialise the event data.
  84       */
  85      protected function init() {
  86          $this->data['objecttable'] = user_evidence::TABLE;
  87          $this->data['crud'] = 'd';
  88          $this->data['edulevel'] = self::LEVEL_OTHER;
  89      }
  90  
  91      /**
  92       * Get_objectid_mapping method.
  93       *
  94       * @return string the name of the restore mapping the objectid links to
  95       */
  96      public static function get_objectid_mapping() {
  97          return base::NOT_MAPPED;
  98      }
  99  
 100  }