2 This file is part of Moodle - http://moodle.org/
4 Moodle is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Moodle is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 @template core_course/bulkactivitycompletion
20 Activity completion selector.
22 Example context (json):
31 "modname": "Test activity",
32 "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/icon.png",
35 "icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png"
41 <div class="container-fluid">
42 <div class="row mb-2">
43 <div class="col">{{#str}}bulkactivitydetail, core_completion{{/str}}</div>
45 <form method="post" action="editbulkcompletion.php" class="mform" id="theform">
46 <div class="row mb-2">
48 <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-primary" name="submitbutton" aria-label="{{#str}}updateactivities, completion{{/str}}" disabled/>
51 <div class="row mb-1">
52 <div class="col-xs-6">
53 <input type="checkbox" class="mastercheck mr-1" aria-label="{{#str}}checkall, completion{{/str}}">
54 <label class="font-weight-bold">{{#str}}activitieslabel, core_completion{{/str}}</label>
56 <div class="col-xs-6">
57 <label class="font-weight-bold">{{#str}}completion, core_completion{{/str}}</label>
58 <span>{{{helpicon}}}</span>
65 <div class="row mb-1 row-fluid">
66 <div class="col-sm-12">
67 <input type="checkbox" data-section-master="{{sectionnumber}}" class="mr-1" aria-label="{{#str}}checkallsection, completion, {{{name}}}{{/str}}">
68 <h3 class="d-inline-block">{{{name}}}</h3>
71 {{> core_course/activityinstance}}
76 <input type="hidden" name="id" value="{{courseid}}" />
77 <input type="hidden" name="sesskey" value="{{sesskey}}" />
80 <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-primary" name="submitbutton" disabled/>
90 $('.mastercheck').click(function() {
91 var checked = $('.mastercheck').is(':checked');
92 $('input[type=checkbox]').each(function() {
93 $(this).prop('checked', checked);
94 $(this).trigger('change'); // Hmmm. Could be smarter about this and only trigger once for the first checkbox.
97 var mastersection = $('input[data-section-master]');
98 mastersection.click(function() {
99 var checked = $(this).is(':checked');
100 var dataid = $(this).attr('data-section-master');
101 $('input[type=checkbox][data-section=\'' + dataid + '\']').each(function() {
102 $(this).prop('checked', checked);
103 $(this).trigger('change'); // Hmmm. Could be smarter about this and only trigger once for the first checkbox.
107 $('input[type=checkbox][id^=selectactivity_]').change(function() {
108 if ($(this).is(':checked')) {
109 $('[name=submitbutton]').removeAttr('disabled');
111 // Is this the last activity checkbox to be un-checked? If so, disable the edit button.
112 var somechecked = false;
113 $('input[type=checkbox][id^=selectactivity_]').each(function() {
114 if ($(this).is(':checked')) {
121 $('[name=submitbutton]').attr('disabled', 'disabled');