Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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",
32
                "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/icon.png",
33
                "completionstatus": {
34
                    "string": "Manual",
35
                    "icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png"
36
                }
37
            }]
38
        }]
39
    }
40
}}
41
 
42
<fieldset class="fieldset-styled">
43
    <legend>{{#str}}bulkactivitydetail, core_completion{{/str}}</legend>
44
 
45
    <form method="post" action="editbulkcompletion.php" class="mform" id="theform">
46
        <div class="row">
47
            <div class="col">
48
                <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-sm btn-outline-primary" name="submitbutton" aria-label="{{#str}}updateactivities, completion{{/str}}" disabled/>
49
            </div>
50
        </div>
51
        <div class="row no-gutters mt-3 pt-3 border-top">
52
            <div class="col-6">
53
                <label class="custom-control ios-switch">
54
                    <input type="checkbox" class="mastercheck ios-switch-control-input form-check-input" aria-label="{{#str}}checkall, completion{{/str}}">
55
 
56
                    <span class="ios-switch-control-indicator"></span>
57
                    <span class="text ml-3 font-weight-bold">{{#str}}activitieslabel, core_completion{{/str}}</span>
58
                </label>
59
            </div>
60
            <div class="col-6 px-0">
61
                <label class="font-weight-bold">{{#str}}completion, core_completion{{/str}}</label>
62
                <span>{{{helpicon}}}</span>
63
            </div>
64
        </div>
65
 
66
        <div class="topics">
67
            {{#sections}}
68
                    <div class="mb-1">
69
                        <div class="row mb-1">
70
                            <div class="col-sm-12 align-items-center py-2 mt-4">
71
                                <label class="custom-control ios-switch my-0">
72
                                    <input type="checkbox" data-section-master="{{sectionnumber}}" class="ios-switch-control-input form-check-input" aria-label="{{#str}}checkallsection, completion, {{{name}}}{{/str}}">
73
                                    <span class="ios-switch-control-indicator"></span>
74
 
75
                                    <span class="text bold ml-3">{{{name}}}</span>
76
                                </label>
77
                            </div>
78
                        </div>
79
                        {{> core_course/activityinstance}}
80
                    </div>
81
 
82
            {{/sections}}
83
        </div>
84
        <input type="hidden" name="id" value="{{courseid}}" />
85
        <input type="hidden" name="sesskey" value="{{sesskey}}" />
86
        <div class="row no-gutters mt-3">
87
            <div class="col">
88
                <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-sm btn-outline-primary" name="submitbutton" disabled/>
89
            </div>
90
        </div>
91
    </form>
92
</fieldset>
93
 
94
{{#js}}
95
require([
96
    'jquery',
97
], function($) {
98
    $('.mastercheck').click(function() {
99
        var checked = $('.mastercheck').is(':checked');
100
        $('input[type=checkbox]').each(function() {
101
            $(this).prop('checked', checked);
102
            $(this).trigger('change'); // Hmmm. Could be smarter about this and only trigger once for the first checkbox.
103
        });
104
    });
105
    var mastersection = $('input[data-section-master]');
106
    mastersection.click(function() {
107
        var checked = $(this).is(':checked');
108
        var dataid = $(this).attr('data-section-master');
109
        $('input[type=checkbox][data-section=\'' + dataid + '\']').each(function() {
110
            $(this).prop('checked', checked);
111
            $(this).trigger('change'); // Hmmm. Could be smarter about this and only trigger once for the first checkbox.
112
        });
113
    });
114
 
115
    $('input[type=checkbox][id^=selectactivity_]').change(function() {
116
        if ($(this).is(':checked')) {
117
            $('[name=submitbutton]').removeAttr('disabled');
118
        } else {
119
            // Is this the last activity checkbox to be un-checked? If so, disable the edit button.
120
            var somechecked = false;
121
            $('input[type=checkbox][id^=selectactivity_]').each(function() {
122
                if ($(this).is(':checked')) {
123
                    somechecked = true;
124
                    return false;
125
                }
126
                return true;
127
            });
128
            if (!somechecked) {
129
                $('[name=submitbutton]').attr('disabled', 'disabled');
130
            }
131
        }
132
    });
133
});
134
{{/js}}