MDL-67883 core: Make core ready for MoodleNet.
[moodle.git] / course / templates / bulkactivitycompletion.mustache
CommitLineData
0b620801
AG
1{{!
2 This file is part of Moodle - http://moodle.org/
3
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.
8
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.
13
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/>.
16}}
17{{!
18 @template core_course/bulkactivitycompletion
19
20 Activity completion selector.
21
22 Example context (json):
23 {
24 "courseid": "2",
25 "sesskey": "AAAAAA",
26 "sections": [{
27 "sectionnumber": "0",
28 "name": "General",
29 "activities": [{
30 "cmid": "4",
31 "modname": "Test activity",
7f53e8aa 32 "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/icon.png",
0b620801
AG
33 "completionstatus": {
34 "string": "Manual",
7f53e8aa 35 "icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png"
0b620801
AG
36 }
37 }]
38 }]
39 }
40}}
41<div class="container-fluid">
5cac5fa4 42 <div class="row mb-2">
5976f85c 43 <div class="col">{{#str}}bulkactivitydetail, core_completion{{/str}}</div>
0b620801 44 </div>
06cdda46 45<form method="post" action="editbulkcompletion.php" class="mform" id="theform">
5cac5fa4 46 <div class="row mb-2">
0b620801 47 <div class="col">
59d9c851 48 <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-primary" name="submitbutton" aria-label="{{#str}}updateactivities, completion{{/str}}" disabled/>
0b620801
AG
49 </div>
50 </div>
5cac5fa4 51 <div class="row mb-1">
9396731e 52 <div class="col-6">
5cac5fa4 53 <input type="checkbox" class="mastercheck mr-1" aria-label="{{#str}}checkall, completion{{/str}}">
5976f85c 54 <label class="font-weight-bold">{{#str}}activitieslabel, core_completion{{/str}}</label>
0b620801 55 </div>
9396731e 56 <div class="col-6">
5976f85c 57 <label class="font-weight-bold">{{#str}}completion, core_completion{{/str}}</label>
0b620801
AG
58 <span>{{{helpicon}}}</span>
59 </div>
60 </div>
273d3106 61 <hr class="row">
0b620801 62 <div class="topics">
0b620801 63 {{#sections}}
5cac5fa4
MM
64 <div class="mb-1">
65 <div class="row mb-1 row-fluid">
0b620801 66 <div class="col-sm-12">
5cac5fa4 67 <input type="checkbox" data-section-master="{{sectionnumber}}" class="mr-1" aria-label="{{#str}}checkallsection, completion, {{{name}}}{{/str}}">
b453e4c9 68 <h3 class="d-inline-block">{{{name}}}</h3>
0b620801
AG
69 </div>
70 </div>
71 {{> core_course/activityinstance}}
72 </div>
273d3106 73 <hr class="row">
0b620801 74 {{/sections}}
0b620801
AG
75 </div>
76 <input type="hidden" name="id" value="{{courseid}}" />
77 <input type="hidden" name="sesskey" value="{{sesskey}}" />
78 <div class="row">
79 <div class="col">
59d9c851 80 <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-primary" name="submitbutton" disabled/>
0b620801
AG
81 </div>
82 </div>
83</form>
84</div>
85
86{{#js}}
87require([
88 'jquery',
89], function($) {
90 $('.mastercheck').click(function() {
91 var checked = $('.mastercheck').is(':checked');
92 $('input[type=checkbox]').each(function() {
93 $(this).prop('checked', checked);
59d9c851 94 $(this).trigger('change'); // Hmmm. Could be smarter about this and only trigger once for the first checkbox.
0b620801
AG
95 });
96 });
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);
59d9c851 103 $(this).trigger('change'); // Hmmm. Could be smarter about this and only trigger once for the first checkbox.
0b620801
AG
104 });
105 });
59d9c851
JD
106
107 $('input[type=checkbox][id^=selectactivity_]').change(function() {
108 if ($(this).is(':checked')) {
109 $('[name=submitbutton]').removeAttr('disabled');
110 } else {
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')) {
115 somechecked = true;
116 return false;
117 }
118 return true;
119 });
120 if (!somechecked) {
121 $('[name=submitbutton]').attr('disabled', 'disabled');
122 }
123 }
124 });
0b620801
AG
125});
126{{/js}}