See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 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 mod_lti\external; 18 19 defined('MOODLE_INTERNAL') || die(); 20 21 /** 22 * External function for fetching all tool types and proxies. 23 * 24 * @package mod_lti 25 * @author Andrew Madden <andrewmadden@catalyst-au.net> 26 * @copyright 2021 Catalyst IT 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 */ 29 class get_tool_types_and_proxies extends \external_api { 30 31 /** 32 * Get parameter definition for get_tool_types_and_proxies(). 33 * 34 * @return \external_function_parameters 35 */ 36 public static function execute_parameters(): \external_function_parameters { 37 return new \external_function_parameters( 38 [ 39 'toolproxyid' => new \external_value(PARAM_INT, 'Tool proxy id', 40 VALUE_DEFAULT, 0), 41 'orphanedonly' => new \external_value(PARAM_BOOL, 'Orphaned tool types only', 42 VALUE_DEFAULT, 0), 43 'limit' => new \external_value(PARAM_INT, 'How many tool types displayed per page', 44 VALUE_DEFAULT, 60, NULL_NOT_ALLOWED), 45 'offset' => new \external_value(PARAM_INT, 'Current offset of tool elements', 46 VALUE_DEFAULT, 0, NULL_NOT_ALLOWED), 47 ] 48 ); 49 } 50 51 /** 52 * Get data for all tool types and tool proxies. 53 * 54 * @param int $toolproxyid The tool proxy id 55 * @param bool $orphanedonly Whether to get orphaned proxies only. 56 * @param int $limit How many elements to return if using pagination. 57 * @param int $offset Which chunk of elements to return is using pagination. 58 * @return array 59 */ 60 public static function execute($toolproxyid, $orphanedonly, $limit, $offset): array { 61 $params = self::validate_parameters(self::execute_parameters(), 62 [ 63 'toolproxyid' => $toolproxyid, 64 'orphanedonly' => $orphanedonly, 65 'limit' => $limit, 66 'offset' => $offset, 67 ]); 68 $toolproxyid = $params['toolproxyid'] !== null ? $params['toolproxyid'] : 0; 69 $orphanedonly = $params['orphanedonly'] !== null ? $params['orphanedonly'] : false; 70 $limit = $params['limit'] !== null ? $params['limit'] : 0; 71 $offset = $params['offset'] !== null ? $params['offset'] : 0; 72 73 $context = \context_system::instance(); 74 self::validate_context($context); 75 require_capability('moodle/site:config', $context); 76 77 list($proxies, $types) = lti_get_lti_types_and_proxies($limit, $offset, $orphanedonly, $toolproxyid); 78 79 return [ 80 'types' => $types, 81 'proxies' => $proxies, 82 'limit' => $limit, 83 'offset' => $offset, 84 ]; 85 } 86 87 /** 88 * Get return definition for get_tool_types_and_proxies. 89 * 90 * @return \external_single_structure 91 */ 92 public static function execute_returns(): \external_single_structure { 93 return new \external_single_structure([ 94 'types' => \mod_lti_external::get_tool_types_returns(), 95 'proxies' => \mod_lti_external::get_tool_proxies_returns(), 96 'limit' => new \external_value(PARAM_INT, 'Limit of how many tool types to show', VALUE_OPTIONAL), 97 'offset' => new \external_value(PARAM_INT, 'Offset of tool types', VALUE_OPTIONAL), 98 ]); 99 } 100 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body