| 1 | efrain | 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 | namespace mod_quiz\event;
 | 
        
           |  |  | 18 |   | 
        
           |  |  | 19 | /**
 | 
        
           |  |  | 20 |  * Event to record a quiz grade item being created.
 | 
        
           |  |  | 21 |  *
 | 
        
           |  |  | 22 |  * @property-read array $other {
 | 
        
           |  |  | 23 |  * }
 | 
        
           |  |  | 24 |  *
 | 
        
           |  |  | 25 |  * @package   mod_quiz
 | 
        
           |  |  | 26 |  * @copyright 2023 The Open University
 | 
        
           |  |  | 27 |  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
        
           |  |  | 28 |  */
 | 
        
           |  |  | 29 | class quiz_grade_item_created extends \core\event\base {
 | 
        
           |  |  | 30 |     protected function init() {
 | 
        
           |  |  | 31 |         $this->data['objecttable'] = 'quiz_grade_items';
 | 
        
           |  |  | 32 |         $this->data['crud'] = 'c';
 | 
        
           |  |  | 33 |         $this->data['edulevel'] = self::LEVEL_TEACHING;
 | 
        
           |  |  | 34 |     }
 | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 |     public static function get_name() {
 | 
        
           |  |  | 37 |         return get_string('eventquizgradeitemcreated', 'mod_quiz');
 | 
        
           |  |  | 38 |     }
 | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 |     public function get_description() {
 | 
        
           |  |  | 41 |         return "The user with id '$this->userid' created quiz grade item with id '$this->objectid' " .
 | 
        
           |  |  | 42 |                 "for the quiz with course module id '$this->contextinstanceid'.";
 | 
        
           |  |  | 43 |     }
 | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 |     public function get_url() {
 | 
        
           |  |  | 46 |         return new \moodle_url('/mod/quiz/editgrading.php', [
 | 
        
           |  |  | 47 |             'cmid' => $this->contextinstanceid,
 | 
        
           |  |  | 48 |         ]);
 | 
        
           |  |  | 49 |     }
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 |     protected function validate_data() {
 | 
        
           |  |  | 52 |         parent::validate_data();
 | 
        
           |  |  | 53 |   | 
        
           |  |  | 54 |         if (!isset($this->objectid)) {
 | 
        
           |  |  | 55 |             throw new \coding_exception('The \'objectid\' value must be set.');
 | 
        
           |  |  | 56 |         }
 | 
        
           |  |  | 57 |   | 
        
           |  |  | 58 |         if (!isset($this->contextinstanceid)) {
 | 
        
           |  |  | 59 |             throw new \coding_exception('The \'contextinstanceid\' value must be set.');
 | 
        
           |  |  | 60 |         }
 | 
        
           |  |  | 61 |     }
 | 
        
           |  |  | 62 |   | 
        
           |  |  | 63 |     public static function get_objectid_mapping() {
 | 
        
           |  |  | 64 |         return ['db' => 'quiz_grade_items', 'restore' => 'quiz_grade_items'];
 | 
        
           |  |  | 65 |     }
 | 
        
           |  |  | 66 |   | 
        
           |  |  | 67 |     public static function get_other_mapping() {
 | 
        
           |  |  | 68 |         return [
 | 
        
           |  |  | 69 |             'quizid' => ['db' => 'quiz', 'restore' => 'quiz'],
 | 
        
           |  |  | 70 |         ];
 | 
        
           |  |  | 71 |     }
 | 
        
           |  |  | 72 | }
 |