Merge branch 'wip-MDL-60546-master' of git://github.com/abgreeve/moodle

This commit is contained in:
Jun Pataleta
2017-11-22 13:24:33 +01:00
committed by David Monllao
3 changed files with 39 additions and 6 deletions
+1
View File
@@ -0,0 +1 @@
define(["jquery"],function(a){return{init:function(){a(".selectallnone a").on("click",function(b){b.preventDefault(),a("#attemptsform").find("input:checkbox").prop("checked",a(this).data("selectInfo"))})}}});
+33
View File
@@ -0,0 +1,33 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Ticks or unticks all checkboxes when clicking the Select all or Deselect all elements when viewing the response overview.
*
* @module mod_choice/select_all_choices
* @copyright 2017 Marcus Fabriczy <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery'], function($) {
return {
init: function () {
$('.selectallnone a').on('click', function(e) {
e.preventDefault();
$('#attemptsform').find('input:checkbox').prop('checked', $(this).data('selectInfo'));
});
}
};
});
+5 -6
View File
@@ -267,13 +267,9 @@ class mod_choice_renderer extends plugin_renderer_base {
$selecturl = new moodle_url('#');
$actiondata .= html_writer::start_div('selectallnone');
$selectallactions = new component_action('click',"checkall");
$selectall = new action_link($selecturl, get_string('selectall'), $selectallactions);
$actiondata .= $this->output->render($selectall) . ' / ';
$actiondata .= html_writer::link($selecturl, get_string('selectall'), ['data-select-info' => true]) . ' / ';
$deselectallactions = new component_action('click',"checknone");
$deselectall = new action_link($selecturl, get_string('deselectall'), $deselectallactions);
$actiondata .= $this->output->render($deselectall);
$actiondata .= html_writer::link($selecturl, get_string('deselectall'), ['data-select-info' => false]);
$actiondata .= html_writer::end_div();
@@ -287,6 +283,9 @@ class mod_choice_renderer extends plugin_renderer_base {
$select = new single_select($actionurl, 'action', $actionoptions, null,
array('' => get_string('chooseaction', 'choice')), 'attemptsform');
$select->set_label(get_string('withselected', 'choice'));
$PAGE->requires->js_call_amd('mod_choice/select_all_choices', 'init');
$actiondata .= $this->output->render($select);
}
$html .= html_writer::tag('div', $actiondata, array('class'=>'responseaction'));