See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401] [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_bigbluebuttonbn\external; 18 19 use context_module; 20 use core_course\external\helper_for_get_mods_by_courses; 21 use external_api; 22 use external_files; 23 use external_format_value; 24 use external_function_parameters; 25 use external_multiple_structure; 26 use external_single_structure; 27 use external_util; 28 use external_value; 29 use external_warnings; 30 31 defined('MOODLE_INTERNAL') || die(); 32 33 global $CFG; 34 require_once($CFG->libdir . '/externallib.php'); 35 36 /** 37 * External service to get activity per course 38 * 39 * This is mainly used by the mobile application. 40 * 41 * @package mod_bigbluebuttonbn 42 * @category external 43 * @copyright 2018 onwards, Blindside Networks Inc 44 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 45 */ 46 class get_bigbluebuttonbns_by_courses extends external_api { 47 /** 48 * Describes the parameters for get_bigbluebuttonbns_by_courses. 49 * 50 * @return external_function_parameters 51 * @since Moodle 3.11 52 */ 53 public static function execute_parameters() { 54 return new external_function_parameters([ 55 'courseids' => new external_multiple_structure( 56 new external_value(PARAM_INT, 'Course id'), 'Array of course ids', VALUE_DEFAULT, [] 57 ), 58 ] 59 ); 60 } 61 62 /** 63 * Returns a list of bigbluebuttonbns in a provided list of courses. 64 * If no list is provided all bigbluebuttonbns that the user can view will be returned. 65 * 66 * @param array $courseids course ids 67 * @return array of warnings and bigbluebuttonbns 68 * @since Moodle 3.11 69 */ 70 public static function execute($courseids = []) { 71 global $USER; 72 $warnings = []; 73 $returnedbigbluebuttonbns = []; 74 75 ['courseids' => $courseids] = self::validate_parameters(self::execute_parameters(), ['courseids' => $courseids]); 76 $mycourses = []; 77 if (empty($courseids)) { 78 $mycourses = enrol_get_my_courses(); 79 $courseids = array_keys($mycourses); 80 } 81 82 // Ensure there are courseids to loop through. 83 if (!empty($courseids)) { 84 [$courses, $warnings] = external_util::validate_courses($courseids, $mycourses); 85 86 // Get the bigbluebuttonbns in this course, this function checks users visibility permissions. 87 // We can avoid then additional validate_context calls. 88 $bigbluebuttonbns = get_all_instances_in_courses("bigbluebuttonbn", $courses, $USER->id); 89 foreach ($bigbluebuttonbns as $bigbluebuttonbn) { 90 helper_for_get_mods_by_courses::format_name_and_intro($bigbluebuttonbn, 'mod_bigbluebuttonbn'); 91 $returnedbigbluebuttonbns[] = $bigbluebuttonbn; 92 } 93 } 94 95 $result = [ 96 'bigbluebuttonbns' => $returnedbigbluebuttonbns, 97 'warnings' => $warnings 98 ]; 99 return $result; 100 } 101 102 /** 103 * Describes the get_bigbluebuttonbns_by_courses return value. 104 * 105 * @return external_single_structure 106 * @since Moodle 3.11 107 */ 108 public static function execute_returns() { 109 return new external_single_structure([ 110 'bigbluebuttonbns' => new external_multiple_structure( 111 new external_single_structure(array_merge( 112 helper_for_get_mods_by_courses::standard_coursemodule_elements_returns(), 113 [ 114 'meetingid' => new external_value(PARAM_RAW, 'Meeting id'), 115 'timemodified' => new external_value(PARAM_INT, 'Last time the instance was modified'), 116 ] 117 )) 118 ), 119 'warnings' => new external_warnings(), 120 ] 121 ); 122 } 123 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body