MDL-58138 completion: changes after rebasing
[moodle.git] / course / templates / defaultactivitycompletion.mustache
CommitLineData
e8a71f85
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/defaultactivitycompletion
19
20 Activity completion selector.
21
22 Example context (json):
23 {
24 "courseid": "2",
25 "sesskey": "AAAAAA",
26 "modules": [{
27 "id": "10",
7f53e8aa
MG
28 "formattedname": "Assignment",
29 "canmanage": true,
30 "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/assign/pix/icon.png",
31 "completionstatus": {
32 "string": "Manual",
33 "icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png"
e8a71f85
AG
34 }
35 }]
36 }
37}}
38<div class="container-fluid">
39 <div class="row m-b-2">
5976f85c 40 <div class="col">{{#str}}bulkactivitydetail, core_completion{{/str}}</div>
e8a71f85 41 </div>
7f53e8aa 42<form method="post" action="editdefaultcompletion.php" class="mform" id="theform">
e8a71f85
AG
43 <div class="row m-b-2">
44 <div class="col">
59d9c851 45 <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-primary" name="submitbutton" aria-label="{{#str}}updateactivities, completion{{/str}}" disabled/>
e8a71f85
AG
46 </div>
47 </div>
48 <div class="top-section row m-b-1">
49 <div class="col-sm-6">
50 <input type="checkbox" class="mastercheck m-r-1" aria-label="{{#str}}checkall, completion{{/str}}">
5976f85c 51 <label class="font-weight-bold">{{#str}}activitieslabel, core_completion{{/str}}</label>
e8a71f85
AG
52 </div>
53 <div class="col-sm-6">
5976f85c 54 <label class="font-weight-bold">{{#str}}completion, core_completion{{/str}}</label>
e8a71f85
AG
55 <span>{{{helpicon}}}</span>
56 </div>
57 </div>
58 <div class="modules">
59 {{#modules}}
7f53e8aa 60 {{#canmanage}}
e8a71f85 61 <div class="module-section m-b-1">
6b3b9c1d
JD
62 <div class="row m-b-1 row-fluid">
63 <div class="col-sm-6 span6">
a64a9f9c
MG
64 <label class="accesshide" for="modtype_{{id}}">Select {{formattedname}}</label>
65 <input id="modtype_{{id}}" type="checkbox" class="m-r-1" name="modids[]" value="{{id}}" aria-label="{{#str}}checkactivity, completion, {{formattedname}}{{/str}}">
66 <img src="{{icon}}" alt=" " role="presentation" />
7f53e8aa
MG
67 <span>{{formattedname}}</span>
68 </div>
6b3b9c1d
JD
69 <div class="activity-completionstatus col-sm-6 span6">
70 <div class="col-sm-1 span1 p-l-0">
7f53e8aa 71 {{#completionstatus.icon}}
6b3b9c1d 72 {{{completionstatus.icon}}}
7f53e8aa
MG
73 {{/completionstatus.icon}}
74 {{^completionstatus.icon}}
75 <span class="m-r-3"></span>
76 {{/completionstatus.icon}}
77 </div>
6b3b9c1d 78 <div class="col-sm-11 span11 p-l-0">
7f53e8aa
MG
79 <span class="text-muted muted">{{{completionstatus.string}}}</span>
80 </div>
e8a71f85
AG
81 </div>
82 </div>
83 </div>
7f53e8aa 84 {{/canmanage}}
e8a71f85
AG
85 {{/modules}}
86 </div>
87 <input type="hidden" name="id" value="{{courseid}}" />
88 <input type="hidden" name="sesskey" value="{{sesskey}}" />
89 <div class="row">
90 <div class="col">
91 <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-primary" name="submitbutton" />
e8a71f85
AG
92 </div>
93 </div>
94</form>
95</div>
96
97{{#js}}
98require([
99 'jquery',
100], function($) {
101 $('.mastercheck').click(function() {
102 var checked = $('.mastercheck').is(':checked');
103 $('input[type=checkbox]').each(function() {
104 $(this).prop('checked', checked);
59d9c851 105 $(this).trigger('change');
e8a71f85
AG
106 });
107 });
59d9c851
JD
108
109 $('input[type=checkbox][id^=modtype_]').change(function() {
110 if ($(this).is(':checked')) {
111 $('[name=submitbutton]').removeAttr('disabled');
112 } else {
113 // Is this the last activity checkbox to be un-checked? If so, disable the edit button.
114 var somechecked = false;
115 $('input[type=checkbox][id^=modtype_]').each(function() {
116 if ($(this).is(':checked')) {
117 somechecked = true;
118 return false;
119 }
120 return true;
121 });
122 if (!somechecked) {
123 $('[name=submitbutton]').attr('disabled', 'disabled');
124 }
125 }
126 });
e8a71f85
AG
127});
128{{/js}}