From 31d4af83c6916c399a49534b39812674accd44c8 Mon Sep 17 00:00:00 2001 From: Laurent David Date: Thu, 7 Dec 2023 13:14:06 +0100 Subject: [PATCH] MDL-80320 core_courseformat: Disable group selection * When forced groupmode is enabled for the course: - the group selection in the activity card be disabled - the activity action menu groupmode will not be visible. - only the icon will be visible * Add new test to check for visibility --- .../output/local/content/cm/groupmode.php | 3 ++- .../tests/behat/activity_groupmode.feature | 21 +++++++++++++++++++ course/lib.php | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/course/format/classes/output/local/content/cm/groupmode.php b/course/format/classes/output/local/content/cm/groupmode.php index ad96fd9395f..21434749ae6 100644 --- a/course/format/classes/output/local/content/cm/groupmode.php +++ b/course/format/classes/output/local/content/cm/groupmode.php @@ -74,7 +74,8 @@ class groupmode implements named_templatable, renderable { if (!$this->format->show_groupmode($this->mod)) { return null; } - if ($this->format->show_editor() && $this->format->supports_components()) { + $usecomponents = $this->format->supports_components(); + if ($this->format->show_editor() && $usecomponents && !$this->mod->coursegroupmodeforce) { return $this->build_editor_data($output); } // If the group mode is not editable, the no groups badge is not displayed. diff --git a/course/format/tests/behat/activity_groupmode.feature b/course/format/tests/behat/activity_groupmode.feature index b8b2b31909b..24f36b22abc 100644 --- a/course/format/tests/behat/activity_groupmode.feature +++ b/course/format/tests/behat/activity_groupmode.feature @@ -89,3 +89,24 @@ Feature: Verify activity group mode interface. And I open "Activity sample" actions menu And I choose "Group mode > Separate groups" in the open action menu And "Separate groups" "icon" should exist in the "Activity sample" "core_courseformat > Activity groupmode" + + @javascript + Scenario: Teacher cannot see Group mode submenu for an activity when group mode has been forced + Given the following "course" exists: + | fullname | Course 2 | + | shortname | C2 | + | category | 0 | + | numsections | 3 | + | groupmode | 1 | + | groupmodeforce | 1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C2 | editingteacher | + And the following "activities" exist: + | activity | name | intro | course | idnumber | section | + | forum | Activity sample | Test forum description | C2 | sample | 1 | + And I am on the "C2" "Course" page logged in as "teacher1" + And I turn editing mode on + When I open "Activity sample" actions menu + Then "Group mode" "link" should not exist in the "Activity sample" "activity" + And "Separate groups" "button" should not exist in the "Activity sample" "core_courseformat > Activity groupmode" diff --git a/course/lib.php b/course/lib.php index 4179702d083..ea57bd6ce27 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1667,7 +1667,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) { } // Groupmode. - if ($courseformat->show_groupmode($mod) && $usecomponents) { + if ($courseformat->show_groupmode($mod) && $usecomponents && !$mod->coursegroupmodeforce) { $groupmodeclass = $courseformat->get_output_classname('content\\cm\\groupmode'); /** @var core_courseformat\output\local\content\cm\groupmode */ $groupmode = new $groupmodeclass($courseformat, $sectioninfo, $mod);