$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,
$row->cells[2]->text .= implode('', $links);
if ($bulkoperations) {
- $row->cells[2]->text .= '<br /><input type="checkbox" class="usercheckbox" name="user'.$user->id.'" /> ';
+ if ($selectall) {
+ $checked = 'checked="true"';
+ } else {
+ $checked = '';
+ }
+ $row->cells[2]->text .= '<br /><input type="checkbox" class="usercheckbox" name="user'.$user->id.'" ' .$checked .'/> ';
}
$table->data = array($row);
echo html_writer::table($table);
$data = array();
if ($bulkoperations) {
- $data[] = '<input type="checkbox" class="usercheckbox" name="user'.$user->id.'" />';
+ if ($selectall) {
+ $checked = 'checked="true"';
+ } else {
+ $checked = '';
+ }
+ $data[] = '<input type="checkbox" class="usercheckbox" name="user'.$user->id.'" ' . $checked .'/>';
}
$data[] = $OUTPUT->user_picture($user, array('size' => 35, 'courseid' => $course->id));
$data[] = $profilelink;
if ($bulkoperations) {
echo '<br /><div class="buttons">';
- echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> ';
+
+ 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 '<input type="button" id="checkall" value="' . $label . '" data-showallink="' . $showalllink . '" /> ';
+ // Select all users, mark all users on page as selected.
+ echo '<input type="button" id="checkallonpage" value="' . get_string('selectallusersonpage') . '" /> ';
+ } else {
+ echo '<input type="button" id="checkallonpage" value="' . get_string('selectall') . '" /> ';
+ }
+
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> ';
$displaylist = array();
$displaylist['messageselect.php'] = get_string('messageselectadd');
--- /dev/null
+@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