MDL-60546 mod_choice: Update to select all functionality.
authorAdrian Greeve <adrian@moodle.com>
Wed, 22 Nov 2017 06:10:55 +0000 (14:10 +0800)
committerAdrian Greeve <adrian@moodle.com>
Wed, 22 Nov 2017 06:10:55 +0000 (14:10 +0800)
mod/choice/amd/build/select_all_choices.min.js
mod/choice/amd/src/select_all_choices.js
mod/choice/renderer.php

index 6bd9ba8..bdbfb17 100644 (file)
Binary files a/mod/choice/amd/build/select_all_choices.min.js and b/mod/choice/amd/build/select_all_choices.min.js differ
index 4cc2b58..5a4a4fb 100644 (file)
  * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-define(['jquery', 'core/str'], function($, str) {
+define(['jquery'], function($) {
     return {
         init: function () {
             $('.selectallnone a').on('click', function(e) {
                 e.preventDefault();
-
-                var flag = false;
-                var selectedtext = $(this).text();
-
-                str.get_string('selectall', 'core').done(function(string) {
-                    if (selectedtext === string) {
-                        flag = true;
-                    }
-                    $('#attemptsform').find('input:checkbox').prop('checked', flag);
-                });
+                $('#attemptsform').find('input:checkbox').prop('checked', $(this).data('selectInfo'));
             });
         }
     };
index 505ef87..f33d48a 100644 (file)
@@ -267,9 +267,9 @@ class mod_choice_renderer extends plugin_renderer_base {
             $selecturl = new moodle_url('#');
 
             $actiondata .= html_writer::start_div('selectallnone');
-            $actiondata .= html_writer::link($selecturl, get_string('selectall')) . ' / ';
+            $actiondata .= html_writer::link($selecturl, get_string('selectall'), ['data-select-info' => true]) . ' / ';
 
-            $actiondata .= html_writer::link($selecturl, get_string('deselectall'));
+            $actiondata .= html_writer::link($selecturl, get_string('deselectall'), ['data-select-info' => false]);
 
             $actiondata .= html_writer::end_div();