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/defaultactivitycompletion
19
 
20
    Activity completion selector.
21
 
22
    Example context (json):
23
    {
24
        "courseid": "2",
25
        "sesskey": "AAAAAA",
26
        "modules": [{
27
            "id": "10",
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"
34
            }
35
        }]
36
    }
37
}}
38
 
39
<fieldset class="fieldset-styled">
40
    <legend>{{#str}}bulkactivitydetail, core_completion{{/str}}</legend>
41
 
42
    <form method="post" action="editdefaultcompletion.php" class="mform mt-3 pt-3 border-top" id="theform">
43
 
44
        <div class="row">
45
            <div class="col">
46
                <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-sm btn-outline-primary" name="submitbutton" aria-label="{{#str}}updateactivities, completion{{/str}}" disabled/>
47
            </div>
48
        </div>
49
 
50
        <div class="row mb-1">
51
            <div class="col-6">
52
                <label class="custom-control ios-switch">
53
                    <input type="checkbox" class="mastercheck ios-switch-control-input form-check-input" aria-label="{{#str}}checkall, completion{{/str}}">
54
                    <span class="ios-switch-control-indicator"></span>
55
                    <strong class="text ml-3">{{#str}}activitieslabel, core_completion{{/str}}</strong>
56
                </label>
57
            </div>
58
            <div class="col-6 px-0">
59
                <label class="font-weight-bold">{{#str}}completion, core_completion{{/str}}</label>
60
                <span>{{{helpicon}}}</span>
61
            </div>
62
        </div>
63
 
64
        <div class="modules">
65
            {{#modules}}
66
                {{#canmanage}}
67
                <div class="mb-1">
68
                    <div class="row no-gutters my-2 py-2 border-bottom">
69
                        <div class="col-6 align-items-center d-inline-flex">
70
                            <label class="custom-control ios-switch">
71
                                <input id="modtype_{{id}}" type="checkbox" class="ios-switch-control-input form-check-input" name="modids[]" value="{{id}}" aria-label="{{#str}}checkactivity, completion, {{{formattedname}}}{{/str}}">
72
                                <span class="ios-switch-control-indicator"></span>
73
                            </label>
74
                            <img class="iconlarge activityicon mr-2" src="{{icon}}" alt=" " role="presentation" />
75
                            <span>{{{formattedname}}}</span>
76
                        </div>
77
                        <div class="activity-completionstatus col-6">
78
                            <div class="d-inline-flex align-items-center">
79
                                {{#completionstatus.icon}}
80
                                    {{{completionstatus.icon}}}
81
                                {{/completionstatus.icon}}
82
                                {{^completionstatus.icon}}
83
                                    <span class="mr-3"></span>
84
                                {{/completionstatus.icon}}
85
                                <span class="text-muted muted ml-2">{{{completionstatus.string}}}</span>
86
                            </div>
87
                        </div>
88
                    </div>
89
                </div>
90
                {{/canmanage}}
91
            {{/modules}}
92
        </div>
93
        <input type="hidden" name="id" value="{{courseid}}" />
94
        <input type="hidden" name="sesskey" value="{{sesskey}}" />
95
        <div class="row no-gutters mt-3">
96
            <div class="col">
97
                <input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-sm btn-outline-primary" name="submitbutton" disabled/>
98
            </div>
99
        </div>
100
    </form>
101
 
102
</fieldset>
103
 
104
{{#js}}
105
require([
106
    'jquery',
107
], function($) {
108
    $('.mastercheck').click(function() {
109
        var checked = $('.mastercheck').is(':checked');
110
        $('input[type=checkbox]').each(function() {
111
            $(this).prop('checked', checked);
112
            $(this).trigger('change');
113
        });
114
    });
115
 
116
    $('input[type=checkbox][id^=modtype_]').change(function() {
117
        if ($(this).is(':checked')) {
118
            $('[name=submitbutton]').removeAttr('disabled');
119
        } else {
120
            // Is this the last activity checkbox to be un-checked? If so, disable the edit button.
121
            var somechecked = false;
122
            $('input[type=checkbox][id^=modtype_]').each(function() {
123
                if ($(this).is(':checked')) {
124
                    somechecked = true;
125
                    return false;
126
                }
127
                return true;
128
            });
129
            if (!somechecked) {
130
                $('[name=submitbutton]').attr('disabled', 'disabled');
131
            }
132
        }
133
    });
134
});
135
{{/js}}