New 'select all' row of radio buttons on attendance page
authorDavo Smith <git@davosmith.co.uk>
Thu, 25 Jun 2015 10:50:07 +0000 (11:50 +0100)
committerDavo Smith <git@davosmith.co.uk>
Fri, 26 Jun 2015 07:14:34 +0000 (08:14 +0100)
lang/en/attendance.php
renderer.php
styles.css
tests/behat/extra_features.feature

index 540760d..2a16291 100644 (file)
@@ -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';
index c393bf0..753c560 100644 (file)
@@ -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++;
index f31ea62..c08ce76 100644 (file)
 }
 #page-mod-attendance-sessions input[type="checkbox"] {
     margin-right: 2px;
-}
\ No newline at end of file
+}
+
+.path-mod-attendance .setallstatuses {
+    text-align: right;
+}
+
index 991bdfa..ad2d73f 100644 (file)
@@ -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"