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 67c56595351..e6b8d4efd03 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1810,7 +1810,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);