mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'wip-mdl-50647' of https://github.com/rajeshtaneja/moodle
This commit is contained in:
commit
8b1eea3bae
@ -26,6 +26,10 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
define('OVERVIEW_NO_GROUP', -1); // The fake group for users not in a group.
|
||||
define('OVERVIEW_GROUPING_GROUP_NO_GROUPING', -1); // The fake grouping for groups that have no grouping.
|
||||
define('OVERVIEW_GROUPING_NO_GROUP', -2); // The fake grouping for users with no group.
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
$groupid = optional_param('group', 0, PARAM_INT);
|
||||
$groupingid = optional_param('grouping', 0, PARAM_INT);
|
||||
@ -61,6 +65,9 @@ $strnotingrouping = get_string('notingrouping', 'group');
|
||||
$strfiltergroups = get_string('filtergroups', 'group');
|
||||
$strnogroups = get_string('nogroups', 'group');
|
||||
$strdescription = get_string('description');
|
||||
$strnotingroup = get_string('notingrouplist', 'group');
|
||||
$strnogroup = get_string('nogroup', 'group');
|
||||
$strnogrouping = get_string('nogrouping', 'group');
|
||||
|
||||
// Get all groupings and sort them by formatted name.
|
||||
$groupings = $DB->get_records('groupings', array('courseid'=>$courseid), 'name');
|
||||
@ -72,7 +79,7 @@ $members = array();
|
||||
foreach ($groupings as $grouping) {
|
||||
$members[$grouping->id] = array();
|
||||
}
|
||||
$members[-1] = array(); //groups not in a grouping
|
||||
$members[OVERVIEW_GROUPING_GROUP_NO_GROUPING] = array(); //groups not in a grouping
|
||||
|
||||
// Get all groups
|
||||
$groups = $DB->get_records('groups', array('courseid'=>$courseid), 'name');
|
||||
@ -86,8 +93,12 @@ if ($groupid) {
|
||||
}
|
||||
|
||||
if ($groupingid) {
|
||||
$groupingwhere = "AND gg.groupingid = :groupingid";
|
||||
$params['groupingid'] = $groupingid;
|
||||
if ($groupingid < 0) { // No grouping filter.
|
||||
$groupingwhere = "AND gg.groupingid IS NULL";
|
||||
} else {
|
||||
$groupingwhere = "AND gg.groupingid = :groupingid";
|
||||
$params['groupingid'] = $groupingid;
|
||||
}
|
||||
} else {
|
||||
$groupingwhere = "";
|
||||
}
|
||||
@ -108,7 +119,7 @@ foreach ($rs as $row) {
|
||||
$user = new stdClass();
|
||||
$user = username_load_fields_from_object($user, $row, null, array('id' => 'userid', 'username', 'idnumber'));
|
||||
if (!$row->groupingid) {
|
||||
$row->groupingid = -1;
|
||||
$row->groupingid = OVERVIEW_GROUPING_GROUP_NO_GROUPING;
|
||||
}
|
||||
if (!array_key_exists($row->groupid, $members[$row->groupingid])) {
|
||||
$members[$row->groupingid][$row->groupid] = array();
|
||||
@ -119,6 +130,47 @@ foreach ($rs as $row) {
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
// Add 'no groupings' / 'no groups' selectors.
|
||||
$groupings[OVERVIEW_GROUPING_GROUP_NO_GROUPING] = (object)array(
|
||||
'id' => OVERVIEW_GROUPING_GROUP_NO_GROUPING,
|
||||
'formattedname' => $strnogrouping,
|
||||
);
|
||||
$groups[OVERVIEW_NO_GROUP] = (object)array(
|
||||
'id' => OVERVIEW_NO_GROUP,
|
||||
'courseid' => $courseid,
|
||||
'idnumber' => '',
|
||||
'name' => $strnogroup,
|
||||
'description' => '',
|
||||
'descriptionformat' => FORMAT_HTML,
|
||||
'enrolmentkey' => '',
|
||||
'picture' => 0,
|
||||
'hidepicture' => 0,
|
||||
'timecreated' => 0,
|
||||
'timemodified' => 0,
|
||||
);
|
||||
|
||||
// Add users who are not in a group.
|
||||
if ($groupid <= 0 && $groupingid <= 0) {
|
||||
list($esql, $params) = get_enrolled_sql($context, null, 0, true);
|
||||
$sql = "SELECT u.id, $allnames, u.idnumber, u.username
|
||||
FROM {user} u
|
||||
JOIN ($esql) e ON e.id = u.id
|
||||
LEFT JOIN (
|
||||
SELECT gm.userid
|
||||
FROM {groups_members} gm
|
||||
JOIN {groups} g ON g.id = gm.groupid
|
||||
WHERE g.courseid = :courseid
|
||||
) grouped ON grouped.userid = u.id
|
||||
WHERE grouped.userid IS NULL";
|
||||
$params['courseid'] = $courseid;
|
||||
|
||||
$nogroupusers = $DB->get_records_sql($sql, $params);
|
||||
|
||||
if ($nogroupusers) {
|
||||
$members[OVERVIEW_GROUPING_NO_GROUP][OVERVIEW_NO_GROUP] = $nogroupusers;
|
||||
}
|
||||
}
|
||||
|
||||
navigation_node::override_active_url(new moodle_url('/group/index.php', array('id'=>$courseid)));
|
||||
$PAGE->navbar->add(get_string('overview', 'group'));
|
||||
|
||||
@ -164,7 +216,9 @@ $printed = false;
|
||||
$hoverevents = array();
|
||||
foreach ($members as $gpgid=>$groupdata) {
|
||||
if ($groupingid and $groupingid != $gpgid) {
|
||||
continue; // do not show
|
||||
if ($groupingid > 0 || $gpgid > 0) { // Still show 'not in group' when 'no grouping' selected.
|
||||
continue; // Do not show.
|
||||
}
|
||||
}
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('groupscount', 'group', count($groupdata)), get_string('groupmembers', 'group'), get_string('usercount', 'group'));
|
||||
@ -201,7 +255,12 @@ foreach ($members as $gpgid=>$groupdata) {
|
||||
continue;
|
||||
}
|
||||
if ($gpgid < 0) {
|
||||
echo $OUTPUT->heading($strnotingrouping, 3);
|
||||
// Display 'not in group' for grouping id == OVERVIEW_GROUPING_NO_GROUP.
|
||||
if ($gpgid == OVERVIEW_GROUPING_NO_GROUP) {
|
||||
echo $OUTPUT->heading($strnotingroup, 3);
|
||||
} else {
|
||||
echo $OUTPUT->heading($strnotingrouping, 3);
|
||||
}
|
||||
} else {
|
||||
echo $OUTPUT->heading($groupings[$gpgid]->formattedname, 3);
|
||||
$description = file_rewrite_pluginfile_urls($groupings[$gpgid]->description, 'pluginfile.php', $context->id, 'grouping', 'description', $gpgid);
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
|
||||
|
||||
use Behat\Behat\Context\Step\Then;
|
||||
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
|
||||
/**
|
||||
@ -84,4 +85,27 @@ class behat_groups extends behat_base {
|
||||
$this->find_button(get_string('backtogroups', 'group'))->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* A single or comma-separated list of groups expected within a grouping, on group overview page.
|
||||
*
|
||||
* @Given /^the group overview should include groups "(?P<groups_string>(?:[^"]|\\")*)" in grouping "(?P<grouping_string>(?:[^"]|\\")*)"$/
|
||||
* @param string $groups one or comma seperated list of groups.
|
||||
* @param string $grouping grouping in which all group should be present.
|
||||
* @return Then[]
|
||||
*/
|
||||
public function the_groups_overview_should_include_groups_in_grouping($groups, $grouping) {
|
||||
|
||||
$steps = array();
|
||||
$groups = array_map('trim', explode(',', $groups));
|
||||
|
||||
foreach ($groups as $groupname) {
|
||||
// Find the table after the H3 containing the grouping name, then look for the group name in the first column.
|
||||
$xpath = "//h3[normalize-space(.) = '{$grouping}']/following-sibling::table//tr//".
|
||||
"td[contains(concat(' ', normalize-space(@class), ' '), ' c0 ')][normalize-space(.) = '{$groupname}' ]";
|
||||
|
||||
$steps[] = new Then('"'.$xpath.'" "xpath_element" should exist');
|
||||
}
|
||||
|
||||
return $steps;
|
||||
}
|
||||
}
|
||||
|
203
group/tests/behat/overview.feature
Normal file
203
group/tests/behat/overview.feature
Normal file
@ -0,0 +1,203 @@
|
||||
@core @core_group
|
||||
Feature: Group overview
|
||||
In order to view an overview of the groups
|
||||
As a teacher
|
||||
I need to visit the group overview page
|
||||
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category | groupmode |
|
||||
| Course 1 | C1 | 0 | 1 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| student0 | Student | 0 | student0@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| student2 | Student | 2 | student2@example.com |
|
||||
| student3 | Student | 3 | student3@example.com |
|
||||
| student4 | Student | 4 | student4@example.com |
|
||||
| student5 | Student | 5 | student5@example.com |
|
||||
| student6 | Student | 6 | student6@example.com |
|
||||
| student7 | Student | 7 | student7@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student0 | C1 | student |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
| student3 | C1 | student |
|
||||
| student4 | C1 | student |
|
||||
| student5 | C1 | student |
|
||||
| student6 | C1 | student |
|
||||
| student7 | C1 | student |
|
||||
And the following "groups" exist:
|
||||
| name | course | idnumber |
|
||||
| Group 1 | C1 | G1 |
|
||||
| Group 2 | C1 | G2 |
|
||||
| Group 3 | C1 | G3 |
|
||||
| Group 4 | C1 | G4 |
|
||||
And the following "group members" exist:
|
||||
| user | group |
|
||||
| student0 | G1 |
|
||||
| student1 | G1 |
|
||||
| student2 | G2 |
|
||||
| student3 | G3 |
|
||||
| student4 | G3 |
|
||||
| student5 | G4 |
|
||||
And the following "groupings" exist:
|
||||
| name | course | idnumber |
|
||||
| Grouping 1 | C1 | GG1 |
|
||||
| Grouping 2 | C1 | GG2 |
|
||||
And the following "grouping groups" exist:
|
||||
| grouping | group |
|
||||
| GG1 | G1 |
|
||||
| GG1 | G2 |
|
||||
| GG2 | G2 |
|
||||
| GG2 | G3 |
|
||||
|
||||
Scenario: Filter the overview in various different ways
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I navigate to "Groups" node in "Course administration > Users"
|
||||
And I follow "Overview"
|
||||
|
||||
# Grouping All and Group All filter
|
||||
When I select "All" from the "Grouping" singleselect
|
||||
And I select "All" from the "group" singleselect
|
||||
# Following groups should exist in groupings.
|
||||
Then the group overview should include groups "Group 1, Group 2" in grouping "Grouping 1"
|
||||
And the group overview should include groups "Group 2,Group 3" in grouping "Grouping 2"
|
||||
And the group overview should include groups "Group 4" in grouping "[Not in a grouping]"
|
||||
And the group overview should include groups "No group" in grouping "[Not in a group]"
|
||||
# Following members should exit in group.
|
||||
And "Student 0" "text" should exist in the "Group 1" "table_row"
|
||||
And "Student 1" "text" should exist in the "Group 1" "table_row"
|
||||
And "Student 2" "text" should exist in the "Group 2" "table_row"
|
||||
And "Student 3" "text" should exist in the "Group 3" "table_row"
|
||||
And "Student 4" "text" should exist in the "Group 3" "table_row"
|
||||
And "Student 5" "text" should exist in the "Group 4" "table_row"
|
||||
And "Student 6" "text" should exist in the "No group" "table_row"
|
||||
And "Student 7" "text" should exist in the "No group" "table_row"
|
||||
|
||||
# Grouping 1 and Group All filter
|
||||
And I select "Grouping 1" from the "Grouping" singleselect
|
||||
And I select "All" from the "group" singleselect
|
||||
# Following groups should exist in groupings.
|
||||
And the group overview should include groups "Group 1, Group 2" in grouping "Grouping 1"
|
||||
# Following groups should not exits
|
||||
And "Group 3" "table_row" should not exist
|
||||
And "No group" "table_row" should not exist
|
||||
# Following members should exit in group.
|
||||
And "Student 0" "text" should exist in the "Group 1" "table_row"
|
||||
And "Student 1" "text" should exist in the "Group 1" "table_row"
|
||||
And "Student 2" "text" should exist in the "Group 2" "table_row"
|
||||
# Following members should not exit in group.
|
||||
And I should not see "Student 3"
|
||||
And I should not see "Student 4"
|
||||
And I should not see "Student 5"
|
||||
And I should not see "Student 6"
|
||||
And I should not see "Student 7"
|
||||
|
||||
# Grouping 2 and Group All filter
|
||||
And I select "Grouping 2" from the "Grouping" singleselect
|
||||
And I select "All" from the "group" singleselect
|
||||
# Following groups should exist in groupings.
|
||||
And the group overview should include groups "Group 2, Group 3" in grouping "Grouping 2"
|
||||
# Following groups should not exits
|
||||
And "Group 1" "table_row" should not exist
|
||||
And "No group" "table_row" should not exist
|
||||
# Following members should exit in group.
|
||||
And "Student 2" "text" should exist in the "Group 2" "table_row"
|
||||
And "Student 3" "text" should exist in the "Group 3" "table_row"
|
||||
And "Student 4" "text" should exist in the "Group 3" "table_row"
|
||||
# Following members should not exit in group.
|
||||
And I should not see "Student 0"
|
||||
And I should not see "Student 1"
|
||||
And I should not see "Student 5"
|
||||
And I should not see "Student 6"
|
||||
And I should not see "Student 7"
|
||||
|
||||
# No grouping and Group All filter
|
||||
And I select "No grouping" from the "Grouping" singleselect
|
||||
And I select "All" from the "group" singleselect
|
||||
# Following groups should exist in groupings.
|
||||
And the group overview should include groups "Group 4" in grouping "[Not in a grouping]"
|
||||
And the group overview should include groups "No group" in grouping "[Not in a group]"
|
||||
# Following groups should not exits
|
||||
And "Group 1" "table_row" should not exist
|
||||
And "Group 2" "table_row" should not exist
|
||||
And "Group 3" "table_row" should not exist
|
||||
# Following members should exit in group.
|
||||
And "Student 5" "text" should exist in the "Group 4" "table_row"
|
||||
And "Student 6" "text" should exist in the "No group" "table_row"
|
||||
And "Student 7" "text" should exist in the "No group" "table_row"
|
||||
# Following members should not exit in group.
|
||||
And I should not see "Student 0"
|
||||
And I should not see "Student 1"
|
||||
And I should not see "Student 2"
|
||||
And I should not see "Student 3"
|
||||
And I should not see "Student 4"
|
||||
|
||||
# Grouping All and Group 1 filter
|
||||
And I select "All" from the "Grouping" singleselect
|
||||
And I select "Group 1" from the "group" singleselect
|
||||
# Following groups should exist in groupings.
|
||||
And the group overview should include groups "Group 1" in grouping "Grouping 1"
|
||||
# Following groups should not exits
|
||||
And "Group 2" "table_row" should not exist
|
||||
And "Group 3" "table_row" should not exist
|
||||
And "Group 4" "table_row" should not exist
|
||||
And "No group" "table_row" should not exist
|
||||
# Following members should exit in group.
|
||||
And "Student 0" "text" should exist in the "Group 1" "table_row"
|
||||
And "Student 1" "text" should exist in the "Group 1" "table_row"
|
||||
# Following members should not exit in group.
|
||||
And I should not see "Student 2"
|
||||
And I should not see "Student 3"
|
||||
And I should not see "Student 4"
|
||||
And I should not see "Student 5"
|
||||
And I should not see "Student 6"
|
||||
And I should not see "Student 7"
|
||||
|
||||
# Grouping All and Group 2 filter
|
||||
And I select "All" from the "Grouping" singleselect
|
||||
And I select "Group 2" from the "group" singleselect
|
||||
# Following groups should exist in groupings.
|
||||
And the group overview should include groups "Group 2" in grouping "Grouping 1"
|
||||
And the group overview should include groups "Group 2" in grouping "Grouping 2"
|
||||
# Following groups should not exits
|
||||
And "Group 1" "table_row" should not exist
|
||||
And "Group 3" "table_row" should not exist
|
||||
And "Group 4" "table_row" should not exist
|
||||
And "No group" "table_row" should not exist
|
||||
# Following members should exit in group.
|
||||
And "Student 2" "text" should exist in the "Group 2" "table_row"
|
||||
# Following members should not exit in group.
|
||||
And I should not see "Student 0"
|
||||
And I should not see "Student 1"
|
||||
And I should not see "Student 3"
|
||||
And I should not see "Student 4"
|
||||
And I should not see "Student 5"
|
||||
And I should not see "Student 6"
|
||||
And I should not see "Student 7"
|
||||
|
||||
# Grouping All and No group filter
|
||||
And I select "All" from the "Grouping" singleselect
|
||||
And I select "No group" from the "group" singleselect
|
||||
# Following groups should exist in groupings.
|
||||
And the group overview should include groups "No group" in grouping "[Not in a group]"
|
||||
# Following groups should not exits
|
||||
And "Group 1" "table_row" should not exist
|
||||
And "Group 2" "table_row" should not exist
|
||||
And "Group 3" "table_row" should not exist
|
||||
And "Group 4" "table_row" should not exist
|
||||
# Following members should exit in group.
|
||||
And "Student 6" "text" should exist in the "No group" "table_row"
|
||||
And "Student 7" "text" should exist in the "No group" "table_row"
|
||||
# Following members should not exit in group.
|
||||
And I should not see "Student 0"
|
||||
And I should not see "Student 1"
|
||||
And I should not see "Student 2"
|
||||
And I should not see "Student 3"
|
||||
And I should not see "Student 4"
|
||||
And I should not see "Student 5"
|
@ -149,12 +149,15 @@ $string['newpicture'] = 'New picture';
|
||||
$string['newpicture_help'] = 'Select an image in JPG or PNG format. The image will be cropped to a square and resized to 100x100 pixels.';
|
||||
$string['noallocation'] = 'No allocation';
|
||||
$string['nogrouping'] = 'No grouping';
|
||||
$string['nogroup'] = 'No group';
|
||||
$string['nogrouping'] = 'No grouping';
|
||||
$string['nogroups'] = 'There are no groups set up in this course yet';
|
||||
$string['nogroupsassigned'] = 'No groups assigned';
|
||||
$string['nopermissionforcreation'] = 'Can\'t create group "{$a}" as you don\'t have the required permissions';
|
||||
$string['nosmallgroups'] = 'Prevent last small group';
|
||||
$string['notingroup'] = 'Ignore users in groups';
|
||||
$string['notingrouping'] = '[Not in a grouping]';
|
||||
$string['notingrouplist'] = '[Not in a group]';
|
||||
$string['nousersinrole'] = 'There are no suitable users in the selected role';
|
||||
$string['number'] = 'Group/member count';
|
||||
$string['numgroups'] = 'Number of groups';
|
||||
|
Loading…
x
Reference in New Issue
Block a user