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 * Abstract assessable uploaded event. 19 * 20 * @package core 21 * @copyright 2013 Frédéric Massart 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core\event; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 /** 30 * Abstract assessable uploaded event class. 31 * 32 * This class has to be extended by any event which represent that some content, 33 * on which someone will be assessed, has been uploaded. This is different 34 * than other events such as assessable_submitted, which means that the content 35 * has been submitted and made available for grading. 36 * 37 * Both events could be triggered in a row, first the uploaded, then the submitted. 38 * 39 * @property-read array $other { 40 * Extra information about event. 41 * 42 * - array pathnamehashes: uploaded files path name hashes. 43 * - string content: the content. 44 * } 45 * 46 * @package core 47 * @since Moodle 2.6 48 * @copyright 2013 Frédéric Massart 49 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 50 */ 51 abstract class assessable_uploaded extends base { 52 53 /** 54 * Init method. 55 * 56 * @return void 57 */ 58 protected function init() { 59 $this->data['crud'] = 'c'; 60 $this->data['edulevel'] = self::LEVEL_PARTICIPATING; 61 } 62 63 /** 64 * Validation that should be shared among child classes. 65 * 66 * @throws \coding_exception when validation fails. 67 * @return void 68 */ 69 protected function validate_data() { 70 parent::validate_data(); 71 if ($this->contextlevel != CONTEXT_MODULE) { 72 throw new \coding_exception('Context level must be CONTEXT_MODULE.'); 73 } else if (!isset($this->other['pathnamehashes']) || !is_array($this->other['pathnamehashes'])) { 74 throw new \coding_exception('The \'pathnamehashes\' value must be set in other and must be an array.'); 75 } else if (!isset($this->other['content']) || !is_string($this->other['content'])) { 76 throw new \coding_exception('The \'content\' value must be set in other and must be a string.'); 77 } 78 } 79 80 public static function get_other_mapping() { 81 // Nothing to map. 82 return false; 83 } 84 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body