From a67c3d166cc2fd6410ae97a0974d8c7350317b2f Mon Sep 17 00:00:00 2001 From: Davo Smith Date: Thu, 25 Jun 2015 11:50:07 +0100 Subject: [PATCH] New 'select all' row of radio buttons on attendance page --- lang/en/attendance.php | 1 + renderer.php | 17 +++++++++++++++++ styles.css | 7 ++++++- tests/behat/extra_features.feature | 17 +++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lang/en/attendance.php b/lang/en/attendance.php index 540760d..2a16291 100644 --- a/lang/en/attendance.php +++ b/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'; diff --git a/renderer.php b/renderer.php index c393bf0..753c560 100644 --- a/renderer.php +++ b/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++; diff --git a/styles.css b/styles.css index f31ea62..c08ce76 100644 --- a/styles.css +++ b/styles.css @@ -125,4 +125,9 @@ } #page-mod-attendance-sessions input[type="checkbox"] { margin-right: 2px; -} \ No newline at end of file +} + +.path-mod-attendance .setallstatuses { + text-align: right; +} + diff --git a/tests/behat/extra_features.feature b/tests/behat/extra_features.feature index 991bdfa..ad2d73f 100644 --- a/tests/behat/extra_features.feature +++ b/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"