Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.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   * Insights page viewed event.
  19   *
  20   * @property-read array $other {
  21   *      Extra information about event.
  22   *
  23   *      - string modelid: The model id
  24   * }
  25   *
  26   * @package    core_analytics
  27   * @copyright  2017 David Monllao {@link http://www.davidmonllao.com}
  28   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  29   */
  30  
  31  namespace core\event;
  32  defined('MOODLE_INTERNAL') || die();
  33  
  34  /**
  35   * Event triggered after a user views the insights page.
  36   *
  37   * @package    core_analytics
  38   * @copyright  2017 David Monllao {@link http://www.davidmonllao.com}
  39   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  40   */
  41  class insights_viewed extends \core\event\base {
  42  
  43      /**
  44       * Set basic properties for the event.
  45       */
  46      protected function init() {
  47          $this->data['crud'] = 'r';
  48          // It depends on the insight really.
  49          $this->data['edulevel'] = self::LEVEL_OTHER;
  50      }
  51  
  52      /**
  53       * Returns localised general event name.
  54       *
  55       * @return string
  56       */
  57      public static function get_name() {
  58          return get_string('eventinsightsviewed', 'analytics');
  59      }
  60  
  61      /**
  62       * Returns non-localised event description with id's for admin use only.
  63       *
  64       * @return string
  65       */
  66      public function get_description() {
  67          return "The user with id '$this->userid' has viewed model '{$this->other['modelid']}' insights in " .
  68              "context with id '{$this->data['contextid']}'";
  69      }
  70  
  71      /**
  72       * Returns relevant URL.
  73       * @return \moodle_url
  74       */
  75      public function get_url() {
  76          return new \moodle_url('/report/insights/insights.php', array('modelid' => $this->other['modelid'],
  77              'contextid' => $this->data['contextid']));
  78      }
  79  }