mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-78203 core_courseformat: groupmode action menu item
This commit is contained in:
parent
57ae65f514
commit
cb541081bd
@ -74,7 +74,7 @@ class groupmode implements named_templatable, renderable {
|
||||
if (!$this->format->show_groupmode($this->mod)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->format->show_editor()) {
|
||||
if ($this->format->show_editor() && $this->format->supports_components()) {
|
||||
return $this->build_editor_data($output);
|
||||
}
|
||||
// If the group mode is not editable, the no groups badge is not displayed.
|
||||
@ -152,7 +152,7 @@ class groupmode implements named_templatable, renderable {
|
||||
* Create a choice list for the dropdown.
|
||||
* @return choicelist the choice list
|
||||
*/
|
||||
protected function get_choice_list(): choicelist {
|
||||
public function get_choice_list(): choicelist {
|
||||
$choice = new choicelist();
|
||||
$choice->add_option(
|
||||
NOGROUPS,
|
||||
|
@ -107,7 +107,10 @@
|
||||
|
||||
{{! Group mode }}
|
||||
{{#groupmodeinfo}}
|
||||
<div class="activity-groupmode-info align-self-start mr-sm-2">
|
||||
<div
|
||||
class="activity-groupmode-info align-self-start mr-sm-2"
|
||||
data-region="groupmode"
|
||||
>
|
||||
{{$ core_courseformat/local/content/cm/groupmode}}
|
||||
{{> core_courseformat/local/content/cm/groupmode}}
|
||||
{{/ core_courseformat/local/content/cm/groupmode}}
|
||||
|
@ -26,7 +26,7 @@
|
||||
}
|
||||
}}
|
||||
{{#hasmenu}}
|
||||
<div class="cm_action_menu actions" data-cmid="{{id}}">
|
||||
<div class="cm_action_menu actions" data-cmid="{{id}}" data-region="actionmenu">
|
||||
{{#menu}}
|
||||
{{$ core/action_menu }}
|
||||
{{> core/action_menu }}
|
||||
|
@ -13,32 +13,30 @@ Feature: Verify activity group mode interface.
|
||||
And the following "groups" exist:
|
||||
| name | course | idnumber |
|
||||
| G1 | C1 | GI1 |
|
||||
And the following "activities" exist:
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
|
||||
@javascript
|
||||
Scenario: Teacher can see the group mode badges in both edit and no edit mode
|
||||
Given the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber | section | groupmode |
|
||||
| forum | Activity sample 1 | Test forum description | C1 | sample1 | 1 | 0 |
|
||||
| forum | Activity sample 2 | Test forum description | C1 | sample2 | 1 | 1 |
|
||||
| forum | Activity sample 3 | Test forum description | C1 | sample3 | 1 | 2 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
Given I am on the "C1" "Course" page logged in as "teacher1"
|
||||
And I turn editing mode on
|
||||
|
||||
@javascript
|
||||
Scenario: Teacher can see the group mode badges in both edit and no edit mode
|
||||
Given "Visible groups" "icon" should not exist in the "Activity sample 1" "activity"
|
||||
And I am on the "C1" "Course" page logged in as "teacher1"
|
||||
When I turn editing mode on
|
||||
Then "Visible groups" "icon" should not exist in the "Activity sample 1" "activity"
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample 1" "activity"
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample 2" "activity"
|
||||
And "Separate groups" "icon" should exist in the "Activity sample 2" "activity"
|
||||
And "Visible groups" "icon" should exist in the "Activity sample 3" "activity"
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample 3" "activity"
|
||||
When I turn editing mode off
|
||||
Then "Visible groups" "icon" should not exist in the "Activity sample 1" "activity"
|
||||
And I turn editing mode off
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample 1" "activity"
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample 1" "activity"
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample 2" "activity"
|
||||
And "Separate groups" "icon" should exist in the "Activity sample 2" "activity"
|
||||
@ -47,19 +45,47 @@ Feature: Verify activity group mode interface.
|
||||
|
||||
@javascript
|
||||
Scenario: Teacher can edit the group mode using the activity group mode badge
|
||||
Given I click on "Separate groups" "icon" in the "Activity sample 2" "activity"
|
||||
And I click on "Visible groups" "link" in the "Activity sample 2" "activity"
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample 2" "activity"
|
||||
And "Visible groups" "icon" should exist in the "Activity sample 2" "activity"
|
||||
When I click on "Visible groups" "icon" in the "Activity sample 2" "activity"
|
||||
And I click on "Separate groups" "link" in the "Activity sample 2" "activity"
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample 2" "activity"
|
||||
And "Separate groups" "icon" should exist in the "Activity sample 2" "activity"
|
||||
Then I click on "Separate groups" "icon" in the "Activity sample 2" "activity"
|
||||
And I click on "No groups" "link" in the "Activity sample 2" "activity"
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample 2" "activity"
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample 2" "activity"
|
||||
And I open "Activity sample 2" actions menu
|
||||
When I click on "No groups" "icon" in the "Activity sample 2" "activity"
|
||||
And I click on "Separate groups" "link" in the "Activity sample 2" "activity"
|
||||
And "Separate groups" "icon" should exist in the "Activity sample 2" "activity"
|
||||
Given the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber | section | groupmode |
|
||||
| forum | Activity sample | Test forum description | C1 | sample | 1 | 1 |
|
||||
And I am on the "C1" "Course" page logged in as "teacher1"
|
||||
And I turn editing mode on
|
||||
And I click on "Separate groups" "icon" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And I click on "Visible groups" "link" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Visible groups" "icon" should exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
When I click on "Visible groups" "icon" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And I click on "Separate groups" "link" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Separate groups" "icon" should exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
Then I click on "Separate groups" "icon" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And I click on "No groups" "link" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And I open "Activity sample" actions menu
|
||||
And I click on "No groups" "icon" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And I click on "Separate groups" "link" in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Separate groups" "icon" should exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
|
||||
@javascript
|
||||
Scenario: Teacher can edit the group mode using the activity action menu
|
||||
Given the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber | section | groupmode |
|
||||
| forum | Activity sample | Test forum description | C1 | sample | 1 | 1 |
|
||||
And I am on the "C1" "Course" page logged in as "teacher1"
|
||||
And I turn editing mode on
|
||||
And I open "Activity sample" actions menu
|
||||
And I choose "Group mode > Visible groups" in the open action menu
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Visible groups" "icon" should exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
When I open "Activity sample" actions menu
|
||||
And I choose "Group mode > Separate groups" in the open action menu
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Separate groups" "icon" should exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
Then I open "Activity sample" actions menu
|
||||
And I choose "Group mode > No groups" in the open action menu
|
||||
And "Separate groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
And "Visible groups" "icon" should not exist in the "Activity sample" "core_courseformat > Activity groupmode"
|
||||
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"
|
||||
|
@ -38,6 +38,9 @@ class behat_courseformat extends behat_base {
|
||||
new behat_component_named_selector('Activity completion', [
|
||||
".//*[@data-activityname=%locator%]//*[@data-region='completionrequirements']",
|
||||
]),
|
||||
new behat_component_named_selector('Activity groupmode', [
|
||||
".//*[@data-activityname=%locator%]//*[@data-region='groupmode']",
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
use core_course\external\course_summary_exporter;
|
||||
use core_courseformat\base as course_format;
|
||||
use core\output\local\action_menu\subpanel as action_menu_subpanel;
|
||||
|
||||
require_once($CFG->libdir.'/completionlib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
@ -1645,6 +1646,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
|
||||
$modcontext = context_module::instance($mod->id);
|
||||
$courseformat = course_get_format($mod->get_course());
|
||||
$usecomponents = $courseformat->supports_components();
|
||||
$sectioninfo = $mod->get_section_info();
|
||||
|
||||
$editcaps = array('moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/role:assign');
|
||||
$dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
|
||||
@ -1664,10 +1666,8 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
|
||||
],
|
||||
'moodle'
|
||||
);
|
||||
$str->assign = get_string('assignroles', 'role');
|
||||
$str->groupsnone = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsnone"));
|
||||
$str->groupsseparate = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsseparate"));
|
||||
$str->groupsvisible = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsvisible"));
|
||||
$str->assign = get_string('assignroles', 'role');
|
||||
$str->groupmode = get_string('groupmode', 'group');
|
||||
}
|
||||
|
||||
$baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
|
||||
@ -1759,9 +1759,9 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
|
||||
|
||||
// Hide/Show/Available/Unavailable.
|
||||
if (has_capability('moodle/course:activityvisibility', $modcontext)) {
|
||||
$allowstealth = !empty($CFG->allowstealth) && $courseformat->allow_stealth_module_visibility($mod, $mod->get_section_info());
|
||||
$allowstealth = !empty($CFG->allowstealth) && $courseformat->allow_stealth_module_visibility($mod, $sectioninfo);
|
||||
|
||||
$sectionvisible = $mod->get_section_info()->visible;
|
||||
$sectionvisible = $sectioninfo->visible;
|
||||
// The module on the course page may be in one of the following states:
|
||||
// - Available and displayed on the course page ($displayedoncoursepage);
|
||||
// - Not available and not displayed on the course page ($unavailable);
|
||||
@ -1860,6 +1860,19 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
|
||||
);
|
||||
}
|
||||
|
||||
// Groupmode.
|
||||
if ($courseformat->show_groupmode($mod) && $usecomponents) {
|
||||
$groupmodeclass = $courseformat->get_output_classname('content\\cm\\groupmode');
|
||||
/** @var core_courseformat\output\local\content\cm\groupmode */
|
||||
$groupmode = new $groupmodeclass($courseformat, $sectioninfo, $mod);
|
||||
$actions['groupmode'] = new action_menu_subpanel(
|
||||
$str->groupmode,
|
||||
$groupmode->get_choice_list(),
|
||||
['class' => 'editing_groupmode'],
|
||||
new pix_icon('i/groupv', '', 'moodle', ['class' => 'iconsmall'])
|
||||
);
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if ($hasmanageactivities) {
|
||||
$actions['delete'] = new action_menu_link_secondary(
|
||||
@ -3237,7 +3250,6 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
|
||||
'groupsnone',
|
||||
'groupsvisible',
|
||||
'groupsseparate',
|
||||
'clicktochangeinbrackets',
|
||||
'markthistopic',
|
||||
'markedthistopic',
|
||||
'movesection',
|
||||
|
@ -83,3 +83,4 @@ showmore,core_availability
|
||||
backpackemail,core_badges
|
||||
backpackemail_help,core_badges
|
||||
editcoursecompletionsettings,core_completion
|
||||
clicktochangeinbrackets,core
|
||||
|
@ -265,7 +265,6 @@ $string['clearsearch'] = 'Clear search input';
|
||||
$string['clickhelpiconformoreinfo'] = '... continues ... Click on the help icon to read the full article';
|
||||
$string['clickhere'] = 'Click here ...';
|
||||
$string['clicktohideshow'] = 'Click to expand or collapse';
|
||||
$string['clicktochangeinbrackets'] = '{$a} (Click to change)';
|
||||
$string['closeblockdrawer'] = 'Close block drawer';
|
||||
$string['closecourseindex'] = 'Close course index';
|
||||
$string['closedrawer'] = 'Close drawer';
|
||||
@ -2450,3 +2449,6 @@ $string['deprecatedeventname'] = '{$a} (no longer in use)';
|
||||
$string['createuserandpass'] = 'Choose your username and password';
|
||||
$string['descriptiona'] = 'Description: {$a}';
|
||||
$string['supplyinfo'] = 'More details';
|
||||
|
||||
// Deprecated since Moodle 4.3.
|
||||
$string['clicktochangeinbrackets'] = '{$a} (Click to change)';
|
||||
|
Loading…
x
Reference in New Issue
Block a user