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 use core_external\external_api; 20 use core_external\external_function_parameters; 21 use core_external\external_value; 22 use mod_lti\local\types_helper; 23 24 defined('MOODLE_INTERNAL') || die(); 25 26 global $CFG; 27 require_once($CFG->dirroot . '/mod/lti/locallib.php'); 28 29 /** 30 * External function to toggle showinactivitychooser setting. 31 * 32 * @package mod_lti 33 * @copyright 2023 Ilya Tregubov <ilya.a.tregubov@gmail.com> 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class toggle_showinactivitychooser extends external_api { 37 38 /** 39 * Get parameter definition. 40 * 41 * @return external_function_parameters 42 */ 43 public static function execute_parameters(): external_function_parameters { 44 return new external_function_parameters([ 45 'tooltypeid' => new external_value(PARAM_INT, 'Tool type ID'), 46 'courseid' => new external_value(PARAM_INT, 'Course ID'), 47 'showinactivitychooser' => new external_value(PARAM_BOOL, 'Show in activity chooser'), 48 ]); 49 } 50 51 /** 52 * Toggles showinactivitychooser setting. 53 * 54 * @param int $tooltypeid the id of the course external tool type. 55 * @param int $courseid the id of the course we are in. 56 * @param bool $showinactivitychooser Show in activity chooser setting. 57 * @return bool true or false 58 */ 59 public static function execute(int $tooltypeid, int $courseid, bool $showinactivitychooser): bool { 60 [ 61 'tooltypeid' => $tooltypeid, 62 'courseid' => $courseid, 63 'showinactivitychooser' => $showinactivitychooser, 64 ] = self::validate_parameters(self::execute_parameters(), [ 65 'tooltypeid' => $tooltypeid, 66 'courseid' => $courseid, 67 'showinactivitychooser' => $showinactivitychooser, 68 ]); 69 70 $context = \core\context\course::instance($courseid); 71 self::validate_context($context); 72 return types_helper::override_type_showinactivitychooser($tooltypeid, $courseid, $context, $showinactivitychooser); 73 } 74 75 /** 76 * Get service returns definition. 77 * 78 * @return external_value 79 */ 80 public static function execute_returns(): external_value { 81 return new external_value(PARAM_BOOL, 'Success'); 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body