Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
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 contenttype_testable; 18 19 /** 20 * Testable contenttype plugin class. 21 * 22 * @package core_contentbank 23 * @copyright 2020 Sara Arjona <sara@moodle.com> 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 class contenttype extends \core_contentbank\contenttype { 27 28 /** Feature for testing */ 29 const CAN_TEST = 'test'; 30 31 /** @var array Additional features for testing */ 32 public static $featurestotest; 33 34 /** 35 * Return an array of implemented features by this plugin. 36 * 37 * @return array 38 */ 39 protected function get_implemented_features(): array { 40 $features = [self::CAN_TEST]; 41 42 if (!empty(self::$featurestotest)) { 43 $features = array_merge($features, self::$featurestotest); 44 } 45 46 return $features; 47 } 48 49 /** 50 * Return an array of extensions this plugin could manage. 51 * 52 * @return array 53 */ 54 public function get_manageable_extensions(): array { 55 return ['.txt', '.png', '.h5p']; 56 } 57 58 /** 59 * Returns the list of different types of the given content type. 60 * 61 * @return array 62 */ 63 public function get_contenttype_types(): array { 64 $type = new \stdClass(); 65 $type->typename = 'testable'; 66 67 return [$type]; 68 } 69 70 /** 71 * Returns true, so the user has permission on the feature. 72 * 73 * @return bool True if content could be edited or created. False otherwise. 74 */ 75 final public function can_test2(): bool { 76 if (!$this->is_feature_supported('test2')) { 77 return false; 78 } 79 80 return true; 81 } 82 83 /** 84 * This implements custom file serving. 85 * 86 * @param stdClass $course the course object 87 * @param stdClass $cm the course module object 88 * @param \context $context the context 89 * @param string $filearea the name of the file area 90 * @param array $args extra arguments (itemid, path) 91 * @param bool $forcedownload whether or not force download 92 * @param array $options additional options affecting the file serving 93 * @return void 94 */ 95 public static function pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []): void { 96 return; 97 } 98 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body