From e35be12fb7b2e33b7a4bcc6a0f419f34a202b79e Mon Sep 17 00:00:00 2001 From: Laurent David Date: Fri, 21 Apr 2023 11:30:29 +0200 Subject: [PATCH] MDL-80019 mod_bigbluebuttonbn: Completion form freeze fix * When the completion is locked, we should not be able to edit the completion elements --- mod/bigbluebuttonbn/mod_form.php | 16 -------- .../tests/behat/edit_instance.feature | 37 +++++++++++++++++-- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/mod/bigbluebuttonbn/mod_form.php b/mod/bigbluebuttonbn/mod_form.php index 07810c7ae83..83d09dbd512 100644 --- a/mod/bigbluebuttonbn/mod_form.php +++ b/mod/bigbluebuttonbn/mod_form.php @@ -748,26 +748,10 @@ class mod_bigbluebuttonbn_mod_form extends moodleform_mod { * unwanted warnings. */ public function definition_after_data() { - global $COURSE; parent::definition_after_data(); foreach ($this->formextensions as $formextension) { $formextension->definition_after_data(); } - $completion = new completion_info($COURSE); - if ($completion->is_enabled()) { - $mform = $this->_form; - $suffix = $this->get_suffix(); - $completionattendancegroupel = 'completionattendancegroup' . $suffix; - $completionengagementgroupel = 'completionengagementgroup' . $suffix; - foreach ([$completionattendancegroupel, $completionengagementgroupel] as $groupname) { - if ($mform->elementExists($groupname)) { - $element = $mform->getElement($groupname); - if ($element->isFrozen()) { - $element->unfreeze(); - } - } - } - } } /** diff --git a/mod/bigbluebuttonbn/tests/behat/edit_instance.feature b/mod/bigbluebuttonbn/tests/behat/edit_instance.feature index 1396e6ee741..2725e896182 100644 --- a/mod/bigbluebuttonbn/tests/behat/edit_instance.feature +++ b/mod/bigbluebuttonbn/tests/behat/edit_instance.feature @@ -1,6 +1,6 @@ @mod @mod_bigbluebuttonbn @javascript Feature: I can edit a bigbluebutton instance - As a user I can edit a BigbluebuttonBN instance + As a user I can edit a BigbluebuttonBN instance Background: Make sure that a course is created Given a BigBlueButton mock server is configured @@ -8,8 +8,8 @@ Feature: I can edit a bigbluebutton instance And the following config values are set as admin: | bigbluebuttonbn_voicebridge_editable | 1 | And the following "courses" exist: - | fullname | shortname | category | - | Test course | Test course | 0 | + | fullname | shortname | category | enablecompletion | + | Test course | Test course | 0 | 1 | Scenario Outline: Add a mod_bigbluebuttonbn instance with Room with recordings Given the following "activities" exist: @@ -26,3 +26,34 @@ Feature: I can edit a bigbluebutton instance | Activity with recording | 0 | should see | should see | | Activity only | 1 | should see | should see | | Recordings only | 2 | should not see | should not see | + + Scenario: When the activity completion are locked, all the completion settings, including + the one specific to BigBlueButtonBN are disabled + Given the following "activities" exist: + | activity | course | name | type | + | bigbluebuttonbn | Test course | RoomRecordings | 0 | + And the following config values are set as admin: + | bigbluebuttonbn_config_experimental_features | 1 | + | bigbluebuttonbn_meetingevents_enabled | 1 | + And the following "users" exist: + | username | firstname | lastname | + | student1 | Student1 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | Test course | student | + And I am on the "RoomRecordings" "bigbluebuttonbn activity editing" page logged in as "admin" + And I expand all fieldsets + And I set the following fields to these values: + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + And I press "Save and return to course" + And I log out + # Then I visit the page first to make sure that completion settings are locked. + And I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as "student1" + And I log out + And I am on the "RoomRecordings" "bigbluebuttonbn activity editing" page logged in as "admin" + When I expand all fieldsets + Then I should see "Completion options locked" + And the "Require view" "field" should be disabled + And the "completionattendanceenabled" "field" should be disabled + And the "Chats" "field" should be disabled