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
This commit is contained in:
Jun Pataleta
2019-09-08 10:01:05 +08:00
parent a672f021ea
commit 0aa833de2e
3 changed files with 28 additions and 28 deletions
-15
View File
@@ -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');
};
+1
View File
@@ -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';
+27 -13
View File
@@ -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 '<form class="mform" action="show_nonrespondents.php" method="post" id="feedback_sendmessageform">';
}
@@ -251,7 +264,15 @@ if (empty($students)) {
//selections to bulk messaging
if ($canbulkmessaging) {
$data[] = '<input type="checkbox" class="usercheckbox" name="messageuser[]" value="'.$student->id.'" />';
$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 '<div class="buttons"><br />';
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" class="btn btn-secondary" /> ';
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" class="btn btn-secondary" /> ';
echo '</div>';
if ($canbulkmessaging) {
echo '<fieldset class="clearfix">';
echo '<legend class="ftoggler">'.get_string('send_message', 'feedback').'</legend>';
echo '<div>';
@@ -290,9 +307,6 @@ if (empty($students)) {
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '</fieldset>';
echo '</form>';
//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);
}
}