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
This commit is contained in:
Laurent David 2023-12-07 13:14:06 +01:00
parent 810554ee83
commit 31d4af83c6
3 changed files with 24 additions and 2 deletions

View file

@ -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.

View file

@ -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"

View file

@ -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);