Browse Source

New 'select all' row of radio buttons on attendance page

MOODLE_28_STABLE
Davo Smith 10 years ago
parent
commit
a67c3d166c
  1. 1
      lang/en/attendance.php
  2. 17
      renderer.php
  3. 7
      styles.css
  4. 17
      tests/behat/extra_features.feature

1
lang/en/attendance.php

@ -234,6 +234,7 @@ $string['sessiontype_help'] = 'There are two types of sessions: common and group
';
$string['sessiontypeshort'] = 'Type';
$string['sessionupdated'] = 'Session successfully updated';
$string['setallstatuses'] = 'Set status for all users';
$string['setallstatusesto'] = 'Set status for all users to «{$a}»';
$string['settings'] = 'Settings';
$string['showdefaults'] = 'Show defaults';

17
renderer.php

@ -489,6 +489,23 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table->size[] = '20px';
$table->attributes['class'] = 'generaltable takelist';
// Show a 'select all' row of radio buttons.
$row = new html_table_row();
$row->cells[] = '';
$row->cells[] = html_writer::div(get_string('setallstatuses', 'attendance'), 'setallstatuses');
foreach ($takedata->statuses as $st) {
$attribs = array(
'type' => 'radio',
'title' => get_string('setallstatusesto', 'attendance', $st->description),
'onclick' => "select_all_in(null, 'st" . $st->id . "', null);",
'name' => 'setallstatuses',
'class' => "st{$st->id}",
);
$row->cells[] = html_writer::empty_tag('input', $attribs);
}
$row->cells[] = '';
$table->data[] = $row;
$i = 0;
foreach ($takedata->users as $user) {
$i++;

7
styles.css

@ -125,4 +125,9 @@
}
#page-mod-attendance-sessions input[type="checkbox"] {
margin-right: 2px;
}
}
.path-mod-attendance .setallstatuses {
text-align: right;
}

17
tests/behat/extra_features.feature

@ -194,3 +194,20 @@ Feature: Test the various new features in the attendance module
And "Set status for all users to «OK»" "link" should exist
And "Set status for all users to «Bad»" "link" should exist
Scenario: A teacher can use the radio buttons to set attendance values for all users
Given I log in as "teacher1"
And I follow "Course 1"
And I follow "Test attendance"
And I follow "Add"
And I set the following fields to these values:
| Create multiple sessions | 0 |
And I click on "submitbutton" "button"
And I follow "Sessions"
And I click on "Take attendance" "link"
When I click on "setallstatuses" "field" in the ".takelist tbody td.c3" "css_element"
And I press "Save attendance"
And I follow "Report"
Then "L" "text" should exist in the "Student 1" "table_row"
And "L" "text" should exist in the "Student 2" "table_row"
And "L" "text" should exist in the "Student 3" "table_row"

Loading…
Cancel
Save