From bd8538c3bb766521d0f988221d04cf7dd3cf7d75 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Mon, 29 Jan 2018 10:45:20 +1300 Subject: [PATCH] Fixes #289 sorted grid layout select all fix. thank to Andrew Debevec for report. --- renderer.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/renderer.php b/renderer.php index 6973906..c779be6 100644 --- a/renderer.php +++ b/renderer.php @@ -704,6 +704,7 @@ class mod_attendance_renderer extends plugin_renderer_base { * @return string */ protected function render_attendance_take_grid(attendance_take_data $takedata) { + global $PAGE; $table = new html_table(); for ($i = 0; $i < $takedata->pageparams->gridcols; $i++) { $table->align[] = 'center'; @@ -713,8 +714,16 @@ class mod_attendance_renderer extends plugin_renderer_base { $table->headspan = $takedata->pageparams->gridcols; $head = array(); foreach ($takedata->statuses as $st) { - $head[] = html_writer::link("javascript:select_all_in(null, 'st" . $st->id . "', null);", $st->acronym, - array('title' => get_string('setallstatusesto', 'attendance', $st->description))); + $head[] = html_writer::link("#", $st->acronym, array('id' => 'checkstatus'.$st->id, + 'title' => get_string('setallstatusesto', 'attendance', $st->description))); + // JS to select all radios of this status and prevent default behaviour of # link. + $PAGE->requires->js_amd_inline(" + require(['jquery'], function($) { + $('#checkstatus".$st->id."').click(function(e) { + $('#attendancetakeform').find('.st".$st->id."').prop('checked', true); + e.preventDefault(); + }); + });"); } $table->head[] = implode('  ', $head);