mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
MDL-49963 core: Select all button on participant list works across pages
This commit is contained in:
parent
03b8b55f10
commit
5b7c500a71
@ -1655,6 +1655,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';
|
||||
|
@ -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,
|
||||
@ -714,7 +715,12 @@ if ($mode === MODE_USERDETAILS) { // Print simple listing.
|
||||
$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);
|
||||
@ -768,7 +774,12 @@ if ($mode === MODE_USERDETAILS) { // Print simple listing.
|
||||
|
||||
$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;
|
||||
@ -798,7 +809,27 @@ if ($mode === MODE_USERDETAILS) { // Print simple listing.
|
||||
|
||||
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');
|
||||
|
@ -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() {
|
||||
|
204
user/tests/behat/view_participants.feature
Normal file
204
user/tests/behat/view_participants.feature
Normal file
@ -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"
|
Loading…
x
Reference in New Issue
Block a user