MDL-74052 mod_bigbluebuttonbn: Wait for moderator not working with app

* On the server the poll was not started when we load the page
resulting in the status not being updated on moodle / browser side.
This commit is contained in:
Laurent David 2022-03-06 20:02:11 +01:00
parent 1d99ba19a2
commit 96050a58ec
5 changed files with 72 additions and 28 deletions

View file

@ -5,6 +5,6 @@ define("mod_bigbluebuttonbn/rooms",["exports","./actions","./repository","./room
* @module mod_bigbluebuttonbn/rooms * @module mod_bigbluebuttonbn/rooms
* @copyright 2021 Blindside Networks Inc * @copyright 2021 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setupWindowAutoClose=_exports.init=void 0,repository=_interopRequireWildcard(repository),roomUpdater=_interopRequireWildcard(roomUpdater);_exports.init=bigbluebuttonbnid=>{const completionElement=document.querySelector("a[href*=completion_validate]");completionElement&&completionElement.addEventListener("click",(()=>{repository.completionValidate(bigbluebuttonbnid).catch(_notification.exception)})),document.addEventListener("click",(e=>{const joinButton=e.target.closest('[data-action="join"]');joinButton&&(roomUpdater.start(),window.open(joinButton.href,"bigbluebutton_conference"),e.preventDefault())})),document.addEventListener(_events.eventTypes.sessionEnded,(()=>{roomUpdater.stop(),roomUpdater.updateRoom(),(0,_notification.fetchNotifications)()})),window.addEventListener(_events.eventTypes.currentSessionEnded,(()=>{roomUpdater.stop(),roomUpdater.updateRoom(),(0,_notification.fetchNotifications)()}))};const autoclose=()=>{window.opener.setTimeout((()=>{roomUpdater.updateRoom(!0)}),5e3),window.removeEventListener("onbeforeunload",autoclose)};_exports.setupWindowAutoClose=()=>{(0,_events.notifyCurrentSessionEnded)(window.opener),window.addEventListener("onbeforeunload",autoclose),window.close()}})); */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setupWindowAutoClose=_exports.init=void 0,repository=_interopRequireWildcard(repository),roomUpdater=_interopRequireWildcard(roomUpdater);_exports.init=bigbluebuttonbnid=>{const completionElement=document.querySelector("a[href*=completion_validate]");completionElement&&completionElement.addEventListener("click",(()=>{repository.completionValidate(bigbluebuttonbnid).catch(_notification.exception)})),document.addEventListener("click",(e=>{const joinButton=e.target.closest('[data-action="join"]');joinButton&&(window.open(joinButton.href,"bigbluebutton_conference"),e.preventDefault())})),document.addEventListener(_events.eventTypes.sessionEnded,(()=>{roomUpdater.stop(),roomUpdater.updateRoom(),(0,_notification.fetchNotifications)()})),window.addEventListener(_events.eventTypes.currentSessionEnded,(()=>{roomUpdater.stop(),roomUpdater.updateRoom(),(0,_notification.fetchNotifications)()})),roomUpdater.start()};const autoclose=()=>{window.opener.setTimeout((()=>{roomUpdater.updateRoom(!0)}),5e3),window.removeEventListener("onbeforeunload",autoclose)};_exports.setupWindowAutoClose=()=>{(0,_events.notifyCurrentSessionEnded)(window.opener),window.addEventListener("onbeforeunload",autoclose),window.close()}}));
//# sourceMappingURL=rooms.min.js.map //# sourceMappingURL=rooms.min.js.map

View file

@ -1 +1 @@
{"version":3,"file":"rooms.min.js","sources":["../src/rooms.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * JS actions for the rooms page for mod_bigbluebuttonbn.\n *\n * @module mod_bigbluebuttonbn/rooms\n * @copyright 2021 Blindside Networks Inc\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport './actions';\nimport * as repository from './repository';\nimport * as roomUpdater from './roomupdater';\nimport {\n exception as displayException,\n fetchNotifications,\n} from 'core/notification';\n\nimport {eventTypes, notifyCurrentSessionEnded} from './events';\n\nexport const init = (bigbluebuttonbnid) => {\n const completionElement = document.querySelector('a[href*=completion_validate]');\n if (completionElement) {\n completionElement.addEventListener(\"click\", () => {\n repository.completionValidate(bigbluebuttonbnid).catch(displayException);\n });\n }\n\n document.addEventListener('click', e => {\n const joinButton = e.target.closest('[data-action=\"join\"]');\n if (joinButton) {\n roomUpdater.start();\n window.open(joinButton.href, 'bigbluebutton_conference');\n\n e.preventDefault();\n }\n });\n\n document.addEventListener(eventTypes.sessionEnded, () => {\n roomUpdater.stop();\n roomUpdater.updateRoom();\n fetchNotifications();\n });\n\n window.addEventListener(eventTypes.currentSessionEnded, () => {\n roomUpdater.stop();\n roomUpdater.updateRoom();\n fetchNotifications();\n });\n};\n\n/**\n * Handle autoclosing of the window.\n */\nconst autoclose = () => {\n window.opener.setTimeout(() => {\n roomUpdater.updateRoom(true);\n }, 5000);\n window.removeEventListener('onbeforeunload', autoclose);\n};\n\n/**\n * Auto close child windows when clicking the End meeting button.\n */\nexport const setupWindowAutoClose = () => {\n notifyCurrentSessionEnded(window.opener);\n window.addEventListener('onbeforeunload', autoclose);\n\n window.close(); // This does not work as scripts can only close windows that are opened by themselves.\n};\n"],"names":["bigbluebuttonbnid","completionElement","document","querySelector","addEventListener","repository","completionValidate","catch","displayException","e","joinButton","target","closest","roomUpdater","start","window","open","href","preventDefault","eventTypes","sessionEnded","stop","updateRoom","currentSessionEnded","autoclose","opener","setTimeout","removeEventListener","close"],"mappings":";;;;;;;8NAiCqBA,0BACXC,kBAAoBC,SAASC,cAAc,gCAC7CF,mBACAA,kBAAkBG,iBAAiB,SAAS,KACxCC,WAAWC,mBAAmBN,mBAAmBO,MAAMC,4BAI/DN,SAASE,iBAAiB,SAASK,UACzBC,WAAaD,EAAEE,OAAOC,QAAQ,wBAChCF,aACAG,YAAYC,QACZC,OAAOC,KAAKN,WAAWO,KAAM,4BAE7BR,EAAES,qBAIVhB,SAASE,iBAAiBe,mBAAWC,cAAc,KAC/CP,YAAYQ,OACZR,YAAYS,uDAIhBP,OAAOX,iBAAiBe,mBAAWI,qBAAqB,KACpDV,YAAYQ,OACZR,YAAYS,8DAQdE,UAAY,KACdT,OAAOU,OAAOC,YAAW,KACrBb,YAAYS,YAAW,KACxB,KACHP,OAAOY,oBAAoB,iBAAkBH,0CAMb,2CACNT,OAAOU,QACjCV,OAAOX,iBAAiB,iBAAkBoB,WAE1CT,OAAOa"} {"version":3,"file":"rooms.min.js","sources":["../src/rooms.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * JS actions for the rooms page for mod_bigbluebuttonbn.\n *\n * @module mod_bigbluebuttonbn/rooms\n * @copyright 2021 Blindside Networks Inc\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport './actions';\nimport * as repository from './repository';\nimport * as roomUpdater from './roomupdater';\nimport {\n exception as displayException,\n fetchNotifications,\n} from 'core/notification';\n\nimport {eventTypes, notifyCurrentSessionEnded} from './events';\n\nexport const init = (bigbluebuttonbnid) => {\n const completionElement = document.querySelector('a[href*=completion_validate]');\n if (completionElement) {\n completionElement.addEventListener(\"click\", () => {\n repository.completionValidate(bigbluebuttonbnid).catch(displayException);\n });\n }\n\n document.addEventListener('click', e => {\n const joinButton = e.target.closest('[data-action=\"join\"]');\n if (joinButton) {\n window.open(joinButton.href, 'bigbluebutton_conference');\n e.preventDefault();\n }\n });\n\n document.addEventListener(eventTypes.sessionEnded, () => {\n roomUpdater.stop();\n roomUpdater.updateRoom();\n fetchNotifications();\n });\n\n window.addEventListener(eventTypes.currentSessionEnded, () => {\n roomUpdater.stop();\n roomUpdater.updateRoom();\n fetchNotifications();\n });\n // Room update.\n roomUpdater.start();\n};\n\n/**\n * Handle autoclosing of the window.\n */\nconst autoclose = () => {\n window.opener.setTimeout(() => {\n roomUpdater.updateRoom(true);\n }, 5000);\n window.removeEventListener('onbeforeunload', autoclose);\n};\n\n/**\n * Auto close child windows when clicking the End meeting button.\n */\nexport const setupWindowAutoClose = () => {\n notifyCurrentSessionEnded(window.opener);\n window.addEventListener('onbeforeunload', autoclose);\n\n window.close(); // This does not work as scripts can only close windows that are opened by themselves.\n};\n"],"names":["bigbluebuttonbnid","completionElement","document","querySelector","addEventListener","repository","completionValidate","catch","displayException","e","joinButton","target","closest","window","open","href","preventDefault","eventTypes","sessionEnded","roomUpdater","stop","updateRoom","currentSessionEnded","start","autoclose","opener","setTimeout","removeEventListener","close"],"mappings":";;;;;;;8NAiCqBA,0BACXC,kBAAoBC,SAASC,cAAc,gCAC7CF,mBACAA,kBAAkBG,iBAAiB,SAAS,KACxCC,WAAWC,mBAAmBN,mBAAmBO,MAAMC,4BAI/DN,SAASE,iBAAiB,SAASK,UACzBC,WAAaD,EAAEE,OAAOC,QAAQ,wBAChCF,aACAG,OAAOC,KAAKJ,WAAWK,KAAM,4BAC7BN,EAAEO,qBAIVd,SAASE,iBAAiBa,mBAAWC,cAAc,KAC/CC,YAAYC,OACZD,YAAYE,uDAIhBR,OAAOT,iBAAiBa,mBAAWK,qBAAqB,KACpDH,YAAYC,OACZD,YAAYE,uDAIhBF,YAAYI,eAMVC,UAAY,KACdX,OAAOY,OAAOC,YAAW,KACrBP,YAAYE,YAAW,KACxB,KACHR,OAAOc,oBAAoB,iBAAkBH,0CAMb,2CACNX,OAAOY,QACjCZ,OAAOT,iBAAiB,iBAAkBoB,WAE1CX,OAAOe"}

View file

@ -42,9 +42,7 @@ export const init = (bigbluebuttonbnid) => {
document.addEventListener('click', e => { document.addEventListener('click', e => {
const joinButton = e.target.closest('[data-action="join"]'); const joinButton = e.target.closest('[data-action="join"]');
if (joinButton) { if (joinButton) {
roomUpdater.start();
window.open(joinButton.href, 'bigbluebutton_conference'); window.open(joinButton.href, 'bigbluebutton_conference');
e.preventDefault(); e.preventDefault();
} }
}); });
@ -60,6 +58,8 @@ export const init = (bigbluebuttonbnid) => {
roomUpdater.updateRoom(); roomUpdater.updateRoom();
fetchNotifications(); fetchNotifications();
}); });
// Room update.
roomUpdater.start();
}; };
/** /**

View file

@ -592,10 +592,10 @@ EOF;
* @return bool * @return bool
*/ */
public function can_join(): bool { public function can_join(): bool {
global $USER;
$groupid = $this->get_group_id(); $groupid = $this->get_group_id();
$context = $this->get_context(); $context = $this->get_context();
$inrightgroup = !$groupid || $this->user_has_group_access($USER, $groupid); $inrightgroup =
groups_group_visible($groupid, $this->get_course(), $this->get_cm());
$hascapability = has_capability('moodle/category:manage', $context) $hascapability = has_capability('moodle/category:manage', $context)
|| (has_capability('mod/bigbluebuttonbn:join', $context) && $inrightgroup); || (has_capability('mod/bigbluebuttonbn:join', $context) && $inrightgroup);
$canjoin = $this->get_type() != self::TYPE_RECORDING_ONLY && $hascapability; // Recording only cannot be joined ever. $canjoin = $this->get_type() != self::TYPE_RECORDING_ONLY && $hascapability; // Recording only cannot be joined ever.

View file

@ -2,51 +2,66 @@
Feature: Test the module in group mode. Feature: Test the module in group mode.
Background: Background:
# 1 = separate groups, we force the group # groupmode 1 = separate groups, we force the group
# groupmode 2 = visible group
Given a BigBlueButton mock server is configured Given a BigBlueButton mock server is configured
And the following "courses" exist: And the following "courses" exist:
| fullname | shortname | category | groupmode | groupmodeforce | | fullname | shortname | category | groupmode | groupmodeforce |
| Test Course 1 | C1 | 0 | 1 | 1 | | Test Course 1 | C1 | 0 | 1 | 1 |
| Test Course 2 | C2 | 0 | 2 | 1 |
And the following "groups" exist: And the following "groups" exist:
| name | course | idnumber | | name | course | idnumber |
| Group 1 | C1 | G1 | | Group 1 | C1 | G1 |
| Group 2 | C1 | G2 | | Group 2 | C1 | G2 |
| Group 1 | C2 | G1b |
| Group 2 | C2 | G2b |
And the following "users" exist: And the following "users" exist:
| username | firstname | lastname | email | | username | firstname | lastname | email |
| teacher1 | TeacherG1 | 1 | teacher1@example.com | | teacher1 | TeacherG1 | 1 | teacher1@example.com |
| teacher2 | TeacherG2 | 2 | teacher2@example.com | | user1 | User1G1 | 1 | user1@example.com |
| user1 | User1G1 | 1 | user1@example.com | | user2 | User2G2 | 2 | user2@example.com |
| user2 | User2G2 | 2 | user2@example.com | | user3 | User3NoGgroup | 3 | user3@example.com |
| user3 | User3NoG2 | 3 | user3@example.com |
And the following "course enrolments" exist: And the following "course enrolments" exist:
| user | course | role | | user | course | role |
| teacher1 | C1 | editingteacher | | teacher1 | C1 | editingteacher |
| teacher2 | C1 | editingteacher |
| user1 | C1 | student | | user1 | C1 | student |
| user2 | C1 | student | | user2 | C1 | student |
| user3 | C1 | student | | user3 | C1 | student |
| teacher1 | C2 | editingteacher |
| user1 | C2 | student |
| user2 | C2 | student |
| user3 | C2 | student |
And the following "group members" exist: And the following "group members" exist:
| user | group | | user | group |
| teacher1 | G1 | | teacher1 | G1 |
| teacher2 | G2 |
| user1 | G1 | | user1 | G1 |
| user2 | G2 | | user2 | G2 |
| teacher1 | G1b |
| user1 | G1b |
| user2 | G2b |
And the following "activities" exist: And the following "activities" exist:
| activity | name | intro | course | idnumber | type | recordings_imported | | activity | name | intro | course | idnumber | type | recordings_imported |
| bigbluebuttonbn | RoomRecordings | Test Room Recording description | C1 | bigbluebuttonbn1 | 0 | 0 | | bigbluebuttonbn | RoomRecordings | Test Room Recording description | C1 | bigbluebuttonbn1 | 0 | 0 |
| bigbluebuttonbn | RoomRecordingsVisibleGroups | Test Room Recording with visible groups | C2 | bigbluebuttonbn2 | 0 | 0 |
And the following "mod_bigbluebuttonbn > meeting" exists: And the following "mod_bigbluebuttonbn > meeting" exists:
| activity | RoomRecordings | | activity | RoomRecordings |
| activity | RoomRecordingsVisibleGroups |
And the following "mod_bigbluebuttonbn > meetings" exist: And the following "mod_bigbluebuttonbn > meetings" exist:
| activity | group | | activity | group |
| RoomRecordings | G1 | | RoomRecordings | G1 |
| RoomRecordings | G2 | | RoomRecordings | G2 |
| RoomRecordingsVisibleGroups | G1b |
| RoomRecordingsVisibleGroups | G2b |
And the following "mod_bigbluebuttonbn > recordings" exist: And the following "mod_bigbluebuttonbn > recordings" exist:
| bigbluebuttonbn | name | group | | bigbluebuttonbn | name | group |
| RoomRecordings | Recording G1 | G1 | | RoomRecordings | Recording G1 | G1 |
| RoomRecordings | Recording G2 | G2 | | RoomRecordings | Recording G2 | G2 |
| RoomRecordingsVisibleGroups | Recording G1b | G1b |
| RoomRecordingsVisibleGroups | Recording G2b | G2b |
And the following "mod_bigbluebuttonbn > recordings" exist: And the following "mod_bigbluebuttonbn > recordings" exist:
| bigbluebuttonbn | name | | bigbluebuttonbn | name |
| RoomRecordings | Recording No group | | RoomRecordings | Recording No group |
| RoomRecordingsVisibleGroups | Recording No group C2 |
@javascript @javascript
Scenario: When I create a BBB activity as a teacher who cannot access all groups, Scenario: When I create a BBB activity as a teacher who cannot access all groups,
@ -64,7 +79,7 @@ Feature: Test the module in group mode.
And I should see "Group 2" in the "select[name='group']" "css_element" And I should see "Group 2" in the "select[name='group']" "css_element"
@javascript @javascript
Scenario Outline: When I view a BBB activity as a student, I should only be able to see Recordings from my group Scenario Outline: When I view a BBB activity as a student in a course with separate groups, I should only be able to see Recordings from my group
When I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as "<user>" When I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as "<user>"
Then I <G1> "Recording G1" Then I <G1> "Recording G1"
And I <G2> "Recording G2" And I <G2> "Recording G2"
@ -74,4 +89,33 @@ Feature: Test the module in group mode.
| user | G1 | G2 | NO | | user | G1 | G2 | NO |
| user1 | should see | should not see | should not see | | user1 | should see | should not see | should not see |
| user2 | should not see | should see | should not see | | user2 | should not see | should see | should not see |
| user3 | should not see | should not see | should see | | user3 | should not see | should not see | should not see |
@javascript
Scenario Outline: When I view a BBB activity as a student in a course with visible group set, I should be able to see Recordings from my group or
the default meeting if I am not in a group.
When I am on the "RoomRecordingsVisibleGroups" "bigbluebuttonbn activity" page logged in as "user3"
And I select "<groupname>" from the "group" singleselect
Then I <G1> "Recording G1b"
And I <G2> "Recording G2b"
And I <NO> "Recording No group C2"
Examples:
| groupname | G1 | G2 | NO |
| All participants | should see | should see | should see |
| Group 1 | should see | should not see | should not see |
| Group 2 | should not see | should see | should not see |
@javascript
Scenario Outline: When I view a BBB activity as a student in a course with visible group set, I should be able to join meeting if not I should not see the activity
When I am on the "<Activity>" "bigbluebuttonbn activity" page logged in as "<user>"
Then I should see "<Message>"
Examples:
| user | Activity | Message |
| user1 | RoomRecordings | Join session |
| user2 | RoomRecordings | Join session |
| user3 | RoomRecordings | You do not have a role that is allowed to join this session |
| user1 | RoomRecordingsVisibleGroups | Join session |
| user2 | RoomRecordingsVisibleGroups | Join session |
| user3 | RoomRecordingsVisibleGroups | Join session |