1 |
efrain |
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 |
/**
|
|
|
18 |
* Behat data generator for mod_bigbluebuttonbn.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_bigbluebuttonbn
|
|
|
21 |
* @category test
|
|
|
22 |
* @copyright 2018 - present, Blindside Networks Inc
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
* @author Laurent David (laurent@call-learning.fr)
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Behat data generator for behat_mod_bigbluebuttonbn_generator.
|
|
|
29 |
*
|
|
|
30 |
* @package mod_bigbluebuttonbn
|
|
|
31 |
* @copyright 2018 - present, Blindside Networks Inc
|
|
|
32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
33 |
* @author Laurent David (laurent@call-learning.fr)
|
|
|
34 |
*/
|
|
|
35 |
class behat_mod_bigbluebuttonbn_generator extends behat_generator_base {
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
* Get all entities that can be create through this behat_generator
|
|
|
39 |
*
|
|
|
40 |
* @return array
|
|
|
41 |
*/
|
|
|
42 |
protected function get_creatable_entities(): array {
|
|
|
43 |
return [
|
|
|
44 |
'recordings' => [
|
|
|
45 |
'singular' => 'recording',
|
|
|
46 |
'datagenerator' => 'recording',
|
|
|
47 |
'required' => ['bigbluebuttonbn', 'name'],
|
|
|
48 |
'switchids' => [
|
|
|
49 |
'bigbluebuttonbn' => 'bigbluebuttonbnid',
|
|
|
50 |
'group' => 'groupid',
|
|
|
51 |
],
|
|
|
52 |
],
|
|
|
53 |
'logs' => [
|
|
|
54 |
'singular' => 'log',
|
|
|
55 |
'datagenerator' => 'override',
|
|
|
56 |
'required' => ['bigbluebuttonbn', 'user'],
|
|
|
57 |
'switchids' => [
|
|
|
58 |
'bigbluebuttonbn' => 'bigbluebuttonbnid',
|
|
|
59 |
'user' => 'userid',
|
|
|
60 |
],
|
|
|
61 |
],
|
|
|
62 |
'meetings' => [
|
|
|
63 |
'singular' => 'meeting',
|
|
|
64 |
'datagenerator' => 'meeting',
|
|
|
65 |
'required' => [
|
|
|
66 |
'activity',
|
|
|
67 |
],
|
|
|
68 |
'switchids' => [
|
|
|
69 |
'activity' => 'instanceid',
|
|
|
70 |
'group' => 'groupid',
|
|
|
71 |
],
|
|
|
72 |
],
|
|
|
73 |
];
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* Look up the id of a bigbluebutton activity from its name.
|
|
|
78 |
*
|
|
|
79 |
* @param string $bbactivityname the bigbluebutton activity name, for example 'Test meeting'.
|
|
|
80 |
* @return int corresponding id.
|
|
|
81 |
* @throws Exception
|
|
|
82 |
*/
|
|
|
83 |
protected function get_bigbluebuttonbn_id(string $bbactivityname): int {
|
|
|
84 |
global $DB;
|
|
|
85 |
|
|
|
86 |
if (!$id = $DB->get_field('bigbluebuttonbn', 'id', ['name' => $bbactivityname])) {
|
|
|
87 |
throw new Exception('There is no bigbluebuttonbn with name "' . $bbactivityname . '" does not exist');
|
|
|
88 |
}
|
|
|
89 |
return $id;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* Get the activity id from its name
|
|
|
94 |
*
|
|
|
95 |
* @param string $activityname
|
|
|
96 |
* @return int
|
|
|
97 |
* @throws Exception
|
|
|
98 |
*/
|
|
|
99 |
protected function get_activity_id(string $activityname): int {
|
|
|
100 |
global $DB;
|
|
|
101 |
|
|
|
102 |
$sql = <<<EOF
|
|
|
103 |
SELECT cm.instance
|
|
|
104 |
FROM {course_modules} cm
|
|
|
105 |
INNER JOIN {modules} m ON m.id = cm.module
|
|
|
106 |
INNER JOIN {bigbluebuttonbn} bbb ON bbb.id = cm.instance
|
|
|
107 |
WHERE cm.idnumber = :idnumber or bbb.name = :name
|
|
|
108 |
EOF;
|
|
|
109 |
$id = $DB->get_field_sql($sql, ['idnumber' => $activityname, 'name' => $activityname]);
|
|
|
110 |
if (empty($id)) {
|
|
|
111 |
throw new Exception("There is no bigbluebuttonbn with name '{$activityname}' does not exist");
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
return $id;
|
|
|
115 |
}
|
|
|
116 |
}
|