Skip to content

Commit

Permalink
Merge branch 'MDL-63620-master' of git://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Jan 16, 2019
2 parents 2a2fa61 + c617a72 commit fda6769
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 8 deletions.
1 change: 1 addition & 0 deletions group/autogroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
$newgroup = new stdClass();
$newgroup->courseid = $data->courseid;
$newgroup->name = $group['name'];
$newgroup->enablemessaging = $data->enablemessaging;
$groupid = groups_create_group($newgroup);
$createdgroups[] = $groupid;
foreach($group['members'] as $user) {
Expand Down
9 changes: 8 additions & 1 deletion group/autogroup_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class autogroup_form extends moodleform {
* Form Definition
*/
function definition() {
global $CFG, $COURSE;
global $USER, $COURSE;
$coursecontext = context_course::instance($COURSE->id);

$mform =& $this->_form;

Expand All @@ -68,6 +69,12 @@ function definition() {
$mform->addRule('number', null, 'numeric', null, 'client');
$mform->addRule('number', get_string('required'), 'required', null, 'client');

// Enable group messaging for the groups to be auto-created.
if (\core_message\api::can_create_group_conversation($USER->id, $coursecontext)) {
$mform->addElement('selectyesno', 'enablemessaging', get_string('enablemessaging', 'group'));
$mform->addHelpButton('enablemessaging', 'enablemessaging', 'group');
}

$mform->addElement('header', 'groupmembershdr', get_string('groupmembers', 'group'));
$mform->setExpanded('groupmembershdr', true);

Expand Down
4 changes: 3 additions & 1 deletion group/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
"groupidnumber" => 1,
"description" => 1,
"enrolmentkey" => 1,
"groupingname" => 1);
"groupingname" => 1,
"enablemessaging" => 1,
);

// --- get header (field names) ---
$header = explode($csv_delimiter, array_shift($rawlines));
Expand Down
27 changes: 27 additions & 0 deletions group/tests/behat/auto_creation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ Feature: Automatic creation of groups
And I press "Submit"
And the "groups" select box should contain "Group A (5)"
And the "groups" select box should contain "Group B (5)"
# Check that group messaging is not enabled for the auto-created groups.
And I set the field "groups" to "Group A"
And I press "Edit group settings"
And I should see "No" in the "Group messaging" "select"
And I press "Cancel"
And I set the field "groups" to "Group B"
And I press "Edit group settings"
And I should see "No" in the "Group messaging" "select"
And I press "Cancel"
# Check groupings.
And I follow "Groupings"
And I should see "Grouping name"
And I click on "Show groups in grouping" "link" in the "Grouping name" "table_row"
Expand Down Expand Up @@ -170,3 +180,20 @@ Feature: Automatic creation of groups
And I set the field "Group/member count" to "11"
And I press "Preview"
And I should not see "Suspended Student 11"

@javascript
Scenario: Auto-create groups with group messaging
Given I set the following fields to these values:
| Naming scheme | Group @ |
| Auto create based on | Number of groups |
| Group/member count | 2 |
| Grouping of auto-created groups | No grouping |
| Group messaging | Yes |
And I press "Submit"
And I set the field "groups" to "Group A"
When I press "Edit group settings"
Then I should see "Yes" in the "Group messaging" "select"
And I press "Cancel"
And I set the field "groups" to "Group B"
And I press "Edit group settings"
And I should see "Yes" in the "Group messaging" "select"
11 changes: 11 additions & 0 deletions group/tests/behat/groups_import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ Feature: Importing of groups and groupings
And I should see "group-id-1-duplicate"
And I should see "group-noid-1"
And I should see "group-noid-2"
# Group messaging should have been enabled for group-id-1.
And I set the field "groups" to "group-id-1"
And I press "Edit group settings"
And I should see "Yes" in the "Group messaging" "select"
And I press "Cancel"
# Group messaging should not have been enabled for group-id-2.
And I set the field "groups" to "group-id-2"
And I press "Edit group settings"
And I should see "No" in the "Group messaging" "select"
And I press "Cancel"
# Check groupings
And I follow "Groupings"
And I should see "Grouping-1"
And I should see "Grouping-2"
Expand Down
12 changes: 6 additions & 6 deletions group/tests/fixtures/groups_import.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
groupname, description, groupidnumber,groupingname
group-id-1, group-id-1, group-id-1,Grouping-1
group-id-2, group-id-2, group-id-2,Grouping-2
group-id-1-duplicate, Duplicate of group-id-1, group-id-1,Grouping-3
group-noid-1, group-noid-1,,Grouping-3
group-noid-2, group-noid-2,,Grouping-2
groupname, description, groupidnumber,groupingname,enablemessaging
group-id-1, group-id-1, group-id-1,Grouping-1,1
group-id-2, group-id-2, group-id-2,Grouping-2,0
group-id-1-duplicate, Duplicate of group-id-1, group-id-1,Grouping-3,0
group-noid-1, group-noid-1,,Grouping-3,0
group-noid-2, group-noid-2,,Grouping-2,0

0 comments on commit fda6769

Please sign in to comment.