From 0aa833de2e89e612d90827709991db51922fa213 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 21 Dec 2017 14:23:21 +1300 Subject: [PATCH] MDL-65935 mod_feedback: Use new core/checkbox_toggleall Plus: * Add labels for each nonrespondent's checkbox to improve accessibility. * Remove the now-unused mod/feedback/feedback.js --- mod/feedback/feedback.js | 15 ----------- mod/feedback/lang/en/feedback.php | 1 + mod/feedback/show_nonrespondents.php | 40 +++++++++++++++++++--------- 3 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 mod/feedback/feedback.js diff --git a/mod/feedback/feedback.js b/mod/feedback/feedback.js deleted file mode 100644 index c7c8da86460..00000000000 --- a/mod/feedback/feedback.js +++ /dev/null @@ -1,15 +0,0 @@ -M.mod_feedback = {}; - -M.mod_feedback.init_sendmessage = function(Y) { - Y.on('click', function(e) { - Y.all('input.usercheckbox').each(function() { - this.set('checked', 'checked'); - }); - }, '#checkall'); - - Y.on('click', function(e) { - Y.all('input.usercheckbox').each(function() { - this.set('checked', ''); - }); - }, '#checknone'); -}; diff --git a/mod/feedback/lang/en/feedback.php b/mod/feedback/lang/en/feedback.php index cf070d28349..993defefd4d 100644 --- a/mod/feedback/lang/en/feedback.php +++ b/mod/feedback/lang/en/feedback.php @@ -139,6 +139,7 @@ $string['downloadresponseas'] = 'Download all responses as:'; $string['importfromthisfile'] = 'Import from this file'; $string['import_questions'] = 'Import questions'; $string['import_successfully'] = 'Import successfully'; +$string['includeuserinrecipientslist'] = 'Include {$a} in the list of recipients'; $string['indicator:cognitivedepth'] = 'Feedback cognitive'; $string['indicator:cognitivedepth_help'] = 'This indicator is based on the cognitive depth reached by the student in a Feedback activity.'; $string['indicator:socialbreadth'] = 'Feedback social'; diff --git a/mod/feedback/show_nonrespondents.php b/mod/feedback/show_nonrespondents.php index 8be8e65cc21..fb20199168f 100644 --- a/mod/feedback/show_nonrespondents.php +++ b/mod/feedback/show_nonrespondents.php @@ -76,7 +76,8 @@ if (($formdata = data_submitted()) AND !confirm_sesskey()) { require_capability('mod/feedback:viewreports', $context); -if ($action == 'sendmessage' AND has_capability('moodle/course:bulkmessaging', $coursecontext)) { +$canbulkmessaging = has_capability('moodle/course:bulkmessaging', $coursecontext); +if ($action == 'sendmessage' AND $canbulkmessaging) { $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); @@ -164,9 +165,22 @@ $baseurl->params(array('id'=>$id, 'showall'=>$showall)); $tablecolumns = array('userpic', 'fullname', 'status'); $tableheaders = array(get_string('userpic'), get_string('fullnameuser'), get_string('status')); -if (has_capability('moodle/course:bulkmessaging', $coursecontext)) { +if ($canbulkmessaging) { $tablecolumns[] = 'select'; - $tableheaders[] = get_string('select'); + + // Build the select/deselect all control. + $selectallid = 'selectall-non-respondents'; + $mastercheckbox = new \core\output\checkbox_toggleall('feedback-non-respondents', true, [ + 'id' => $selectallid, + 'name' => $selectallid, + 'value' => 1, + 'label' => get_string('select'), + // Consistent label to prevent the select column from resizing. + 'selectall' => get_string('select'), + 'deselectall' => get_string('select'), + 'labelclasses' => 'm-0', + ]); + $tableheaders[] = $OUTPUT->render($mastercheckbox); } $table = new flexible_table('feedback-shownonrespondents-'.$course->id); @@ -232,7 +246,6 @@ if (empty($students)) { echo $OUTPUT->notification(get_string('noexistingparticipants', 'enrol')); } else { - $canbulkmessaging = has_capability('moodle/course:bulkmessaging', $coursecontext); if ($canbulkmessaging) { echo '
'; } @@ -251,7 +264,15 @@ if (empty($students)) { //selections to bulk messaging if ($canbulkmessaging) { - $data[] = ''; + $checkbox = new \core\output\checkbox_toggleall('feedback-non-respondents', false, [ + 'id' => 'messageuser-' . $student->id, + 'name' => 'messageuser[]', + 'class' => 'mr-1', + 'value' => $student->id, + 'label' => get_string('includeuserinrecipientslist', 'mod_feedback', fullname($student)), + 'labelclasses' => 'accesshide', + ]); + $data[] = $OUTPUT->render($checkbox); } $table->add_data($data); } @@ -268,11 +289,7 @@ if (empty($students)) { $allurl->param('showall', 1); echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), array(), 'showall'); } - if (has_capability('moodle/course:bulkmessaging', $coursecontext)) { - echo '

'; - echo ' '; - echo ' '; - echo '
'; + if ($canbulkmessaging) { echo '
'; echo ''.get_string('send_message', 'feedback').''; echo '
'; @@ -290,9 +307,6 @@ if (empty($students)) { echo ''; echo '
'; echo '
'; - //include the needed js - $module = array('name'=>'mod_feedback', 'fullpath'=>'/mod/feedback/feedback.js'); - $PAGE->requires->js_init_call('M.mod_feedback.init_sendmessage', null, false, $module); } }