mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-73724' of https://github.com/call-learning/moodle
This commit is contained in:
commit
649fb3cc49
@ -60,7 +60,9 @@ class end_meeting extends external_api {
|
||||
* @param int $bigbluebuttonbnid the bigbluebuttonbn instance id
|
||||
* @param int $groupid the groupid (either 0 or the groupid)
|
||||
* @return array (empty array for now)
|
||||
* @throws \restricted_context_exception
|
||||
* @throws \invalid_parameter_exception
|
||||
* @throws \moodle_exception
|
||||
* @throws restricted_context_exception
|
||||
*/
|
||||
public static function execute(
|
||||
int $bigbluebuttonbnid,
|
||||
|
@ -62,7 +62,8 @@ class get_recordings extends external_api {
|
||||
* @param string|null $tools
|
||||
* @param int|null $groupid
|
||||
* @return array of warnings and status result
|
||||
* @throws \webservice_access_exception
|
||||
* @throws \invalid_parameter_exception
|
||||
* @throws restricted_context_exception
|
||||
*/
|
||||
public static function execute(
|
||||
int $bigbluebuttonbnid = 0,
|
||||
|
@ -71,12 +71,13 @@ class get_recordings_to_import extends external_api {
|
||||
* Get a list of recordings
|
||||
*
|
||||
* @param int $destinationinstanceid the bigbluebuttonbn instance id where recordings have been already imported.
|
||||
* @param int $sourcebigbluebuttonbnid the bigbluebuttonbn instance id to which the recordings are referred.
|
||||
* @param int $sourcecourseid the source courseid to filter by
|
||||
* @param int|null $sourcebigbluebuttonbnid the bigbluebuttonbn instance id to which the recordings are referred.
|
||||
* @param int|null $sourcecourseid the source courseid to filter by
|
||||
* @param string|null $tools
|
||||
* @param int|null $groupid
|
||||
* @return array of warnings and status result
|
||||
* @throws \webservice_access_exception
|
||||
* @throws \invalid_parameter_exception
|
||||
* @throws \restricted_context_exception
|
||||
*/
|
||||
public static function execute(
|
||||
int $destinationinstanceid,
|
||||
|
@ -49,7 +49,6 @@ class update_recording extends external_api {
|
||||
* @param string $action
|
||||
* @param string|null $additionaloptions
|
||||
* @return array (empty array for now)
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public static function execute(
|
||||
int $bigbluebuttonbnid,
|
||||
|
@ -47,7 +47,6 @@ class recording_data {
|
||||
* @param instance|null $instance
|
||||
* @param int $courseid
|
||||
* @return array
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public static function get_recording_table(array $recordings, array $tools, instance $instance = null,
|
||||
int $courseid = 0): array {
|
||||
|
@ -68,15 +68,15 @@ class files {
|
||||
/**
|
||||
* Helper for getting pluginfile.
|
||||
*
|
||||
* @param stdClass $course course object
|
||||
* @param \cm_info $cm course module object
|
||||
* @param stdClass|null $course course object
|
||||
* @param stdClass|null $cm course module object
|
||||
* @param context $context context object
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
*
|
||||
* @return \stored_file|bool
|
||||
*/
|
||||
public static function pluginfile_file(stdClass $course, \cm_info $cm, context $context, string $filearea, array $args) {
|
||||
public static function pluginfile_file(?stdClass $course, ?stdClass $cm, context $context, string $filearea, array $args) {
|
||||
$filename = self::get_plugin_filename($course, $cm, $context, $args);
|
||||
if (!$filename) {
|
||||
return false;
|
||||
@ -213,14 +213,14 @@ class files {
|
||||
/**
|
||||
* Helper for getting pluginfile name.
|
||||
*
|
||||
* @param stdClass $course course object
|
||||
* @param \cm_info $cm course module object
|
||||
* @param stdClass|null $course course object
|
||||
* @param stdClass|null $cm course module object
|
||||
* @param context $context context object
|
||||
* @param array $args extra arguments
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function get_plugin_filename(stdClass $course, \cm_info $cm, context $context, array $args): ?string {
|
||||
public static function get_plugin_filename(?stdClass $course, ?stdClass $cm, context $context, array $args): ?string {
|
||||
global $DB;
|
||||
if ($context->contextlevel != CONTEXT_SYSTEM) {
|
||||
// Plugin has a file to use as default in general setting.
|
||||
@ -245,7 +245,11 @@ class files {
|
||||
return ($args['0'] == $actualnonce) ? $args['1'] : null;
|
||||
|
||||
}
|
||||
require_course_login($course, true, $cm, true, true);
|
||||
if (!empty($course)) {
|
||||
require_course_login($course, true, $cm, true, true);
|
||||
} else {
|
||||
require_login(null, true, $cm, true, true);
|
||||
}
|
||||
if (!has_capability('mod/bigbluebuttonbn:join', $context)) {
|
||||
return null;
|
||||
}
|
||||
@ -257,7 +261,6 @@ class files {
|
||||
*
|
||||
* @param int $id
|
||||
* @return int
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected static function get_nonce(int $id): int {
|
||||
$cache = static::get_nonce_cache();
|
||||
|
@ -401,7 +401,6 @@ class bigbluebutton_proxy extends proxy_base {
|
||||
* @param string|null $presentationurl
|
||||
* @return array
|
||||
* @throws bigbluebutton_exception
|
||||
* @throws server_not_available_exception
|
||||
*/
|
||||
public static function create_meeting(
|
||||
array $data,
|
||||
|
@ -80,23 +80,22 @@ class curl extends \curl {
|
||||
* @param string $url
|
||||
* @param array|string $params
|
||||
* @param array $options
|
||||
* @return bool
|
||||
* @return null|SimpleXMLElement Null on error
|
||||
*/
|
||||
public function post($url, $params = '', $options = []) {
|
||||
if (!is_string($params)) {
|
||||
debugging('Only string paramaters are supported', DEBUG_DEVELOPER);
|
||||
debugging('Only string parameters are supported', DEBUG_DEVELOPER);
|
||||
$params = '';
|
||||
}
|
||||
|
||||
$options = [
|
||||
$options = array_merge($options, [
|
||||
'CURLOPT_HTTPHEADER' => [
|
||||
'Content-Type: ' . $this->get_content_type(),
|
||||
'Content-Length: ' . strlen($params),
|
||||
'Content-Language: en-US',
|
||||
],
|
||||
];
|
||||
]
|
||||
]);
|
||||
|
||||
return !empty($this->handle_response(parent::post($url, $params, $options)));
|
||||
return $this->handle_response(parent::post($url, $params, $options));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,8 +79,6 @@ class logger {
|
||||
* @param array|null $filters
|
||||
* @param int|null $timestart
|
||||
* @return array
|
||||
* @throws \coding_exception
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
public static function get_user_completion_logs(
|
||||
instance $instance,
|
||||
@ -102,8 +100,6 @@ class logger {
|
||||
* @param array|null $filters
|
||||
* @param int|null $timestart
|
||||
* @return array
|
||||
* @throws \coding_exception
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
public static function get_user_completion_logs_with_userfields(
|
||||
instance $instance,
|
||||
@ -138,8 +134,6 @@ EOF;
|
||||
* @param array|null $filters
|
||||
* @param int|null $timestart
|
||||
* @return int
|
||||
* @throws \coding_exception
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
public static function get_user_completion_logs_max_timestamp(
|
||||
instance $instance,
|
||||
@ -164,8 +158,6 @@ EOF;
|
||||
* @param int|null $timestart
|
||||
* @param string|null $logtablealias
|
||||
* @return array
|
||||
* @throws \coding_exception
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
protected static function get_user_completion_sql_params(instance $instance, ?int $userid, ?array $filters, ?int $timestart,
|
||||
?string $logtablealias = null) {
|
||||
@ -371,7 +363,6 @@ EOF;
|
||||
* @param array $overrides
|
||||
* @param string|null $meta
|
||||
* @return bool
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
protected static function raw_log(
|
||||
string $event,
|
||||
|
@ -64,7 +64,6 @@ class meeting {
|
||||
* @param int $origin
|
||||
* @return string
|
||||
* @throws meeting_join_exception this is sent if we cannot join (meeting full, user needs to wait...)
|
||||
* @throws server_not_available_exception
|
||||
*/
|
||||
public static function join_meeting(instance $instance, $origin = logger::ORIGIN_BASE): string {
|
||||
// See if the session is in progress.
|
||||
@ -80,7 +79,6 @@ class meeting {
|
||||
* Get currently stored meeting info
|
||||
*
|
||||
* @return mixed|stdClass
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public function get_meeting_info() {
|
||||
if (!$this->meetinginfo) {
|
||||
@ -162,8 +160,6 @@ class meeting {
|
||||
* Creates a bigbluebutton meeting, send the message to BBB and returns the response in an array.
|
||||
*
|
||||
* @return array
|
||||
* @throws bigbluebutton_exception
|
||||
* @throws server_not_available_exception
|
||||
*/
|
||||
public function create_meeting() {
|
||||
$data = $this->create_meeting_data();
|
||||
@ -196,7 +192,6 @@ class meeting {
|
||||
* Get meeting join URL
|
||||
*
|
||||
* @return string
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public function get_join_url() {
|
||||
return bigbluebutton_proxy::get_join_url(
|
||||
@ -301,8 +296,6 @@ class meeting {
|
||||
* @param bool $updatecache
|
||||
*
|
||||
* @return array
|
||||
* @throws \coding_exception
|
||||
* @throws bigbluebutton_exception
|
||||
*/
|
||||
protected static function retrieve_cached_meeting_info($meetingid, $updatecache = false) {
|
||||
$cachettl = (int) config::get('waitformoderator_cache_ttl');
|
||||
|
@ -47,7 +47,6 @@ abstract class recording_editable extends \core\output\inplace_editable {
|
||||
* @param instance $instance
|
||||
* @param string $edithint
|
||||
* @param string $editlabel
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public function __construct(recording $rec, instance $instance, string $edithint, string $editlabel) {
|
||||
$this->instance = $instance;
|
||||
|
@ -33,7 +33,6 @@ class recording_name_editable extends recording_editable {
|
||||
*
|
||||
* @param recording $rec
|
||||
* @param instance $instance
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public function __construct(recording $rec, instance $instance) {
|
||||
parent::__construct($rec, $instance,
|
||||
|
@ -407,8 +407,6 @@ class recording extends persistent {
|
||||
*
|
||||
* @param instance $targetinstance
|
||||
* @return recording
|
||||
* @throws \coding_exception
|
||||
* @throws \core\invalid_persistent_exception
|
||||
*/
|
||||
public function create_imported_recording(instance $targetinstance) {
|
||||
$recordingrec = $this->to_record();
|
||||
@ -611,7 +609,6 @@ class recording extends persistent {
|
||||
* Is protected. Return null if protected is not implemented.
|
||||
*
|
||||
* @return bool|null
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected function get_protected() {
|
||||
$protectedtext = $this->metadata_get('protected');
|
||||
@ -622,7 +619,6 @@ class recording extends persistent {
|
||||
* Start time
|
||||
*
|
||||
* @return mixed|null
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected function get_starttime() {
|
||||
return $this->metadata_get('starttime');
|
||||
@ -632,7 +628,6 @@ class recording extends persistent {
|
||||
* Start time
|
||||
*
|
||||
* @return mixed|null
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected function get_endtime() {
|
||||
return $this->metadata_get('endtime');
|
||||
@ -642,7 +637,6 @@ class recording extends persistent {
|
||||
* Is published
|
||||
*
|
||||
* @return bool
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected function get_published() {
|
||||
$publishedtext = $this->metadata_get('published');
|
||||
@ -654,7 +648,6 @@ class recording extends persistent {
|
||||
*
|
||||
* @param string $fieldname
|
||||
* @param mixed $value
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected function metadata_set($fieldname, $value) {
|
||||
// Can we can change the metadata on the imported record ?
|
||||
|
@ -158,7 +158,6 @@ trait testcase_helper_trait {
|
||||
* @param instance $instance
|
||||
* @param array $recordingdata array of recording information
|
||||
* @return array
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
protected function create_recordings_for_instance(instance $instance, array $recordingdata = []): array {
|
||||
$recordings = [];
|
||||
@ -215,8 +214,6 @@ trait testcase_helper_trait {
|
||||
*
|
||||
* @param array $dataset
|
||||
* @return mixed
|
||||
* @throws \coding_exception
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
protected function create_from_dataset(array $dataset) {
|
||||
list('type' => $type, 'recordingsdata' => $recordingsdata, 'groups' => $groups,
|
||||
|
@ -408,7 +408,8 @@ function bigbluebuttonbn_view($bigbluebuttonbn, $course, $cm, $context) {
|
||||
];
|
||||
|
||||
$event = \mod_bigbluebuttonbn\event\course_module_viewed::create($params); // Fix event name.
|
||||
$event->add_record_snapshot('course_modules', $cm->get_course_module_record());
|
||||
$cmrecord = $cm->get_course_module_record();
|
||||
$event->add_record_snapshot('course_modules', $cmrecord);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('bigbluebuttonbn', $bigbluebuttonbn);
|
||||
$event->trigger();
|
||||
|
@ -656,7 +656,6 @@ class mod_bigbluebuttonbn_mod_form extends moodleform_mod {
|
||||
* @param array|null $options
|
||||
* @param array|null $rule
|
||||
* @return void
|
||||
* @throws coding_exception
|
||||
*/
|
||||
private function bigbluebuttonbn_mform_add_element(MoodleQuickForm &$mform, string $type, string $name, ?string $datatype,
|
||||
?string $descriptionkey = "", $defaultvalue = null, ?array $options = null, ?array $rule = null): void {
|
||||
|
@ -86,7 +86,6 @@ XPATH
|
||||
* @param string $endpoint
|
||||
* @param array $params
|
||||
* @return moodle_url
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function get_mocked_server_url(string $endpoint = '', array $params = []): moodle_url {
|
||||
return new moodle_url(TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER . '/' . $endpoint, $params);
|
||||
@ -149,7 +148,6 @@ XPATH
|
||||
*
|
||||
* @param string $identifier
|
||||
* @return int
|
||||
* @throws dml_exception
|
||||
*/
|
||||
protected function get_course_id(string $identifier): int {
|
||||
global $DB;
|
||||
|
@ -229,7 +229,6 @@ class mod_bigbluebuttonbn_generator extends \testing_module_generator {
|
||||
* @param stdClass $recordingdata
|
||||
* @param array $data
|
||||
* @return string
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
protected function create_mockserver_recording(instance $instance, stdClass $recordingdata, array $data): string {
|
||||
$now = time();
|
||||
@ -343,7 +342,6 @@ class mod_bigbluebuttonbn_generator extends \testing_module_generator {
|
||||
* @param array $params
|
||||
* @param array $mockdata
|
||||
* @return SimpleXMLElement
|
||||
* @throws coding_exception
|
||||
*/
|
||||
protected function send_mock_request(string $endpoint, array $params = [], array $mockdata = []): SimpleXMLElement {
|
||||
$url = $this->get_mocked_server_url($endpoint, $params);
|
||||
|
@ -198,7 +198,6 @@ class lib_test extends \advanced_testcase {
|
||||
* @param int $user
|
||||
* @param int $group
|
||||
* @return array|void
|
||||
* @throws \moodle_exception
|
||||
*/
|
||||
protected function prepare_for_recent_activity_array($date, $user, $group) {
|
||||
// Same algorithm as in cource/recent.php, but stops at the first bbb activity.
|
||||
|
@ -72,9 +72,11 @@ class files_test extends \advanced_testcase {
|
||||
list($user, $bbactivity) = $this->create_user_and_activity($CFG->dirroot . self::PRESENTATION_FILEPATH);
|
||||
$this->setUser($user);
|
||||
$instance = instance::get_from_instanceid($bbactivity->id);
|
||||
$cm = $instance->get_cm();
|
||||
$cmrecord = $cm->get_course_module_record();
|
||||
/** @var stored_file $mediafile */
|
||||
$mediafile =
|
||||
files::pluginfile_file($this->get_course(), $instance->get_cm(), $instance->get_context(),
|
||||
files::pluginfile_file($this->get_course(), $cmrecord, $instance->get_context(),
|
||||
'presentation', [self::PRESENTATION_FILENAME]);
|
||||
$this->assertEquals(self::PRESENTATION_FILENAME, $mediafile->get_filename());
|
||||
}
|
||||
@ -89,8 +91,9 @@ class files_test extends \advanced_testcase {
|
||||
$this->setUser($user);
|
||||
|
||||
$instance = instance::get_from_instanceid($bbactivity->id);
|
||||
$mediafilename =
|
||||
files::get_plugin_filename($this->get_course(), $instance->get_cm(), $instance->get_context(), ['presentation.pptx']);
|
||||
$cm = $instance->get_cm();
|
||||
$cmrecord = $cm->get_course_module_record();
|
||||
$mediafilename = files::get_plugin_filename($this->get_course(), $cmrecord, $instance->get_context(), ['presentation.pptx']);
|
||||
$this->assertEquals('presentation.pptx', $mediafilename);
|
||||
}
|
||||
|
||||
@ -109,17 +112,17 @@ class files_test extends \advanced_testcase {
|
||||
$fulldirset = explode('/', $presentation['url']);
|
||||
$filename = array_pop($fulldirset);
|
||||
$nonce = array_pop($fulldirset);
|
||||
$cm = $instance->get_cm();
|
||||
$cmrecord = $cm->get_course_module_record();
|
||||
// The link should be valid twice.
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$mediafile =
|
||||
files::pluginfile_file($this->get_course(), $instance->get_cm(), $instance->get_context(), 'presentation',
|
||||
[$nonce, $filename]);
|
||||
$mediafile = files::pluginfile_file($this->get_course(), $cmrecord, $instance->get_context(), 'presentation',
|
||||
[$nonce, $filename]);
|
||||
$this->assertEquals($filename, $mediafile->get_filename());
|
||||
}
|
||||
// Third time is a charm, this should be false.
|
||||
$mediafile =
|
||||
files::pluginfile_file($this->get_course(), $instance->get_cm(), $instance->get_context(), 'presentation',
|
||||
[$nonce, $filename]);
|
||||
$mediafile = files::pluginfile_file($this->get_course(), $cmrecord, $instance->get_context(), 'presentation',
|
||||
[$nonce, $filename]);
|
||||
$this->assertFalse($mediafile);
|
||||
}
|
||||
|
||||
@ -139,13 +142,12 @@ class files_test extends \advanced_testcase {
|
||||
$filename = array_pop($fulldirset);
|
||||
$this->setGuestUser();
|
||||
$this->expectException(\require_login_exception::class);
|
||||
files::pluginfile_file($this->get_course(), $instance->get_cm(), $instance->get_context(), 'presentation',
|
||||
[$filename]);
|
||||
$cm = $instance->get_cm();
|
||||
$cmrecord = $cm->get_course_module_record();
|
||||
files::pluginfile_file($this->get_course(), $cmrecord, $instance->get_context(), 'presentation', [$filename]);
|
||||
|
||||
$this->setUser($user);
|
||||
$mediafile =
|
||||
files::pluginfile_file($this->get_course(), $instance->get_cm(), $instance->get_context(), 'presentation',
|
||||
[$filename]);
|
||||
$mediafile = files::pluginfile_file($this->get_course(), $cmrecord, $instance->get_context(), 'presentation', [$filename]);
|
||||
$this->assertNotNull($mediafile);
|
||||
}
|
||||
|
||||
@ -162,7 +164,7 @@ class files_test extends \advanced_testcase {
|
||||
$pathparts = explode('/', $presentationdef['url']);
|
||||
$filename = array_pop($pathparts);
|
||||
$salt = array_pop($pathparts);
|
||||
$filename = files::get_plugin_filename($this->get_course(), $bbactivitycm, $bbactivitycontext,
|
||||
$filename = files::get_plugin_filename($this->get_course(), $bbactivitycm->get_course_module_record(), $bbactivitycontext,
|
||||
[$salt, $filename]);
|
||||
$this->assertEquals(self::PRESENTATION_FILENAME, $filename);
|
||||
}
|
||||
|
@ -164,7 +164,6 @@ class meeting_test extends \advanced_testcase {
|
||||
* @param string|null $groupname
|
||||
* @param int $groupmode
|
||||
* @param array $canjoin
|
||||
* @throws \coding_exception
|
||||
* @dataProvider get_instance_types_meeting_info
|
||||
* @covers ::can_join
|
||||
*/
|
||||
@ -193,7 +192,6 @@ class meeting_test extends \advanced_testcase {
|
||||
* @param int $groupmode
|
||||
* @param array $canjoin
|
||||
* @param array $dates
|
||||
* @throws \coding_exception
|
||||
* @dataProvider get_data_can_join_with_dates
|
||||
* @covers ::can_join
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user