diff --git a/lang/en/moodle.php b/lang/en/moodle.php
index 53c98f4a5ab..8a06424cefc 100644
--- a/lang/en/moodle.php
+++ b/lang/en/moodle.php
@@ -1645,6 +1645,8 @@ $string['selectagroup'] = 'Select a group';
$string['selectaregion'] = 'Select a region';
$string['selctauser'] = 'Select a user';
$string['selectall'] = 'Select all';
+$string['selectallusersonpage'] = 'Select all users on this page';
+$string['selectalluserswithcount'] = 'Select all {$a} users';
$string['selectamodule'] = 'Please select an activity module';
$string['selectanoptions'] = 'Select an option';
$string['selectdefault'] = 'Select default';
diff --git a/user/index.php b/user/index.php
index c1d104b975b..d51f72f0db1 100644
--- a/user/index.php
+++ b/user/index.php
@@ -42,6 +42,7 @@ $search = optional_param('search', '', PARAM_RAW); // Make sure it is proc
$roleid = optional_param('roleid', 0, PARAM_INT); // Optional roleid, 0 means all enrolled users (or all on the frontpage).
$contextid = optional_param('contextid', 0, PARAM_INT); // One of this or.
$courseid = optional_param('id', 0, PARAM_INT); // This are required.
+$selectall = optional_param('selectall', false, PARAM_BOOL); // When rendering checkboxes against users mark them all checked.
$PAGE->set_url('/user/index.php', array(
'page' => $page,
@@ -713,7 +714,12 @@ if ($mode === MODE_USERDETAILS) { // Print simple listing.
$row->cells[2]->text .= implode('', $links);
if ($bulkoperations) {
- $row->cells[2]->text .= ' ';
+ if ($selectall) {
+ $checked = 'checked="true"';
+ } else {
+ $checked = '';
+ }
+ $row->cells[2]->text .= ' ';
}
$table->data = array($row);
echo html_writer::table($table);
@@ -767,7 +773,12 @@ if ($mode === MODE_USERDETAILS) { // Print simple listing.
$data = array();
if ($bulkoperations) {
- $data[] = '';
+ if ($selectall) {
+ $checked = 'checked="true"';
+ } else {
+ $checked = '';
+ }
+ $data[] = '';
}
$data[] = $OUTPUT->user_picture($user, array('size' => 35, 'courseid' => $course->id));
$data[] = $profilelink;
@@ -797,7 +808,27 @@ if ($mode === MODE_USERDETAILS) { // Print simple listing.
if ($bulkoperations) {
echo '
';
- echo ' ';
+
+ if ($matchcount > 0 && $perpage < $matchcount) {
+ $perpageurl = clone($baseurl);
+ $perpageurl->remove_params('perpage');
+ $perpageurl->param('perpage', SHOW_ALL_PAGE_SIZE);
+ $perpageurl->param('selectall', true);
+ $showalllink = $perpageurl;
+ } else {
+ $showalllink = false;
+ }
+
+ if ($perpage < $matchcount) {
+ // Select all users, refresh page showing all users and mark them all selected.
+ $label = get_string('selectalluserswithcount', 'moodle', $matchcount);
+ echo ' ';
+ // Select all users, mark all users on page as selected.
+ echo ' ';
+ } else {
+ echo ' ';
+ }
+
echo ' ';
$displaylist = array();
$displaylist['messageselect.php'] = get_string('messageselectadd');
diff --git a/user/module.js b/user/module.js
index 324a2af2de6..98c9040280f 100644
--- a/user/module.js
+++ b/user/module.js
@@ -21,10 +21,17 @@ M.core_user.init_participation = function(Y) {
}, '#formactionid');
Y.on('click', function(e) {
+ // Presence of a show all link indicates we should redirect to
+ // a page with all users listed and checked, otherwise just check
+ // those already shown.
+ var showallink = this.getAttribute('data-showallink');
+ if (showallink) {
+ window.location = showallink;
+ }
Y.all('input.usercheckbox').each(function() {
this.set('checked', 'checked');
});
- }, '#checkall');
+ }, '#checkall, #checkallonpage');
Y.on('click', function(e) {
Y.all('input.usercheckbox').each(function() {
diff --git a/user/tests/behat/view_participants.feature b/user/tests/behat/view_participants.feature
new file mode 100644
index 00000000000..c21ca02082a
--- /dev/null
+++ b/user/tests/behat/view_participants.feature
@@ -0,0 +1,204 @@
+@core @core_user
+Feature: View course participants
+ In order to know who is on a course
+ As a teacher
+ I need to be able to view the participants on a course
+
+ Background:
+ Given the following "users" exist:
+ | username | firstname | lastname | email |
+ | teacher1 | Teacher | 1 | teacher1@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 |
+ | student8 | Student | 8 | student8@example.com |
+ | student9 | Student | 9 | student9@example.com |
+ | student10 | Student | 10 | student10@example.com |
+ | student11 | Student | 11 | student11@example.com |
+ | student12 | Student | 12 | student12@example.com |
+ | student13 | Student | 13 | student13@example.com |
+ | student14 | Student | 14 | student14@example.com |
+ | student15 | Student | 15 | student15@example.com |
+ | student16 | Student | 16 | student16@example.com |
+ | student17 | Student | 17 | student17@example.com |
+ | student18 | Student | 18 | student18@example.com |
+ | student19 | Student | 19 | student19@example.com |
+ | student20 | Student | 20 | student20@example.com |
+ And the following "courses" exist:
+ | fullname | shortname | format |
+ | Course 1 | C1 | topics |
+ And the following "course enrolments" exist:
+ | user | course | role |
+ | teacher1 | C1 | editingteacher |
+ | student1 | C1 | student |
+ | student2 | C1 | student |
+ | student3 | C1 | student |
+ | student4 | C1 | student |
+ | student5 | C1 | student |
+ | student6 | C1 | student |
+ | student7 | C1 | student |
+ | student8 | C1 | student |
+ | student9 | C1 | student |
+ | student10 | C1 | student |
+ | student11 | C1 | student |
+ | student12 | C1 | student |
+ | student13 | C1 | student |
+ | student14 | C1 | student |
+ | student15 | C1 | student |
+ | student16 | C1 | student |
+ | student17 | C1 | student |
+ | student18 | C1 | student |
+ | student19 | C1 | student |
+
+ @javascript
+ Scenario: Use select and deselect all buttons
+ When I log in as "teacher1"
+ And I follow "Course 1"
+ And I follow "Participants"
+ And I press "Select all"
+ Then the field with xpath "//tbody//tr[1]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[2]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[3]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[4]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[5]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[6]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[7]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[8]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[9]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[10]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[11]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[12]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[13]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[14]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[15]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[16]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[17]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[18]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[19]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[20]//input[@class='usercheckbox']" matches value "1"
+
+ And I press "Deselect all"
+ Then the field with xpath "//tbody//tr[1]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[2]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[3]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[4]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[5]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[6]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[7]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[8]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[9]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[10]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[11]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[12]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[13]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[14]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[15]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[16]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[17]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[18]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[19]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[20]//input[@class='usercheckbox']" matches value "0"
+
+ @javascript
+ Scenario: Use select all users on this page, select all n users and deselect all
+ And the following "course enrolments" exist:
+ | user | course | role |
+ | student20 | C1 | student |
+ When I log in as "teacher1"
+ And I follow "Course 1"
+ And I follow "Participants"
+ And I press "Select all users on this page"
+ Then I should not see "Student 11"
+ Then the field with xpath "//tbody//tr[1]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[2]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[3]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[4]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[5]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[6]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[7]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[8]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[9]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[10]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[11]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[12]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[13]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[14]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[15]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[16]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[17]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[18]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[19]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[20]//input[@class='usercheckbox']" matches value "1"
+
+ And I press "Deselect all"
+ Then the field with xpath "//tbody//tr[1]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[2]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[3]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[4]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[5]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[6]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[7]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[8]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[9]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[10]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[11]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[12]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[13]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[14]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[15]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[16]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[17]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[18]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[19]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[20]//input[@class='usercheckbox']" matches value "0"
+
+ And I press "Select all 21 users"
+ Then I should see "Student 11"
+ Then the field with xpath "//tbody//tr[1]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[2]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[3]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[4]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[5]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[6]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[7]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[8]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[9]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[10]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[11]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[12]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[13]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[14]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[15]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[16]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[17]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[18]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[19]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[20]//input[@class='usercheckbox']" matches value "1"
+ Then the field with xpath "//tbody//tr[21]//input[@class='usercheckbox']" matches value "1"
+
+ And I press "Deselect all"
+ Then the field with xpath "//tbody//tr[1]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[2]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[3]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[4]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[5]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[6]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[7]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[8]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[9]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[10]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[11]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[12]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[13]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[14]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[15]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[16]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[17]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[18]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[19]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[20]//input[@class='usercheckbox']" matches value "0"
+ Then the field with xpath "//tbody//tr[21]//input[@class='usercheckbox']" matches value "0"
\ No newline at end of file