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
 
19
    @template tool_supporter/course_table
20
    Template which outputs a table of courses.
21
 
22
    Classes required for JS:
23
    * dataTables
24
 
25
    Context variables required for this template:
26
    * courses - array of arrays: course details to be displayed in a table.
27
 
28
Example context (json):
29
{
30
  "courses": [
31
        {
32
      "id": 8,
33
      "startdate": "27/08/2022, 11:00:00",
34
      "shortname": "Kurs level 2",
35
      "fullname": "Kurs level 2",
36
      "level_two": "",
37
      "level_one": "Top Level 2",
38
      "visible": 1
39
    },
40
    {
41
      "id": 9,
42
      "startdate": "24/12/2022, 00:00:00",
43
      "shortname": "Kurs level 2.1",
44
      "fullname": "Kurs level 2.1",
45
      "level_two": "Level 2.1",
46
      "level_one": "Top Level 2",
47
      "visible": 1
48
    },
49
    {
50
      "id": 17,
51
      "startdate": "31/12/2022, 00:00:00",
52
      "shortname": "eee",
53
      "fullname": "eee",
54
      "level_two": "Level 2.1",
55
      "level_one": "Top Level 2",
56
      "visible": 0
57
    },
58
    {
59
      "id": 19,
60
      "startdate": "01/07/2022, 09:00:00",
61
      "shortname": "Ebene 3 Kurs",
62
      "fullname": "Ebene 3 Kurs",
63
      "level_two": "Verschiedenes 1",
64
      "level_one": "Verschiedenes",
65
      "visible": 0
66
    },
67
    {
68
      "id": 21,
69
      "startdate": "22/07/2022, 09:00:00",
70
      "shortname": "FB 01 Kurs im WS 17 18",
71
      "fullname": "FB 01 Kurs im WS 17 18",
72
      "level_two": "FB 01",
73
      "level_one": "WiSe 2017/2018",
74
      "visible": 1
75
    },
76
    {
77
      "id": 30,
78
      "startdate": "05/03/2022, 10:00:00",
79
      "shortname": "test",
80
      "fullname": "test",
81
      "level_two": "",
82
      "level_one": "Verschiedenes",
83
      "visible": 0
84
    }
85
  ],
86
  "uniqueleveltwoes": [
87
    "Verschiedenes 1",
88
    "Testbereich mit (Klammern)",
89
    "Level 1.1",
90
    "Level 2.1",
91
    "FB 01",
92
    "FB 02",
93
    "FB 03"
94
  ],
95
  "uniquelevelones": [
96
    "Verschiedenes",
97
    "Top Level 1",
98
    "Top Level 2",
99
    "SoSe 2018",
100
    "WiSe 2017/2018",
101
    "Semesteruebergreifende Kurse",
102
    "HRZ / E-Learning - Weiterbildung",
103
    "WiSe 2018/19",
104
    "SoSe 2019"
105
  ],
106
  "label_level_1": "Semester",
107
  "label_level_2": "Fachbereich",
108
  "searchname": "Suchen",
109
  "refreshname": "Aktualisieren"
110
}
111
 
112
}}
113
<div data-region="course_table" class="card rui-supporter-table">
114
	<div class = "card-header">
115
		<div class="row">
116
		    <div class="col">
117
          <h4 class="card-title">{{#str}}courses{{/str}}
118
          <button class="ml-4 btn btn-xs p-1 btn-secondary" id="btn_refresh_courses">{{#pix}} a/refresh, core, {{refreshname}} {{/pix}}</button>
119
          </h4>
120
        </div>
121
		</div>
122
	</div>
123
 
124
    <div id="course_table_filtering" style="visibility: hidden;">
125
        <div class="btn-toolbar ml-3 mt-1" role="toolbar">
126
            <div class="btn-group" role="group">
127
                <select id="course_table_column_chooser" class="form-control custom-select mr-1">
128
                    <!-- Additional Options will be added later with javascript -->
129
                    <option selected value="-1">{{#str}}all{{/str}}</option>
130
                </select>
131
            </div>
132
            <div class="btn-group" role="group" style="width: 55%">
133
                <input type="text" id="course_table_search_input" class="form-control form-control-sm" placeholder={{searchname}}>
134
            </div>
135
            <button type="button" class="btn btn-sm btn-danger" id="courses_clear_filters" style="visibility: hidden">&times; {{#str}}removeall, filters{{/str}}</button>
136
        </div>
137
 
138
        <!-- Filtering for course table -->
139
        <div id ="course_filtering" data-region = "course_filtering">
140
           <ul class="nav nav-tabs nav-justified">
141
             <!-- Filter course list by selecting first level category-->
142
             <li class="nav-item dropdown" {{^showlevel1}}hidden{{/showlevel1}}>
143
               <a class = "nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown">{{label_level_1}}<span class="caret"></span></a>
144
 
145
               <ul class="dropdown-menu" id="courses_levelonedropdown">
146
                 {{#uniquelevelones}}
147
                    <li class = "dropdown-item" style="padding: 0 0 0 1.5rem"> <!-- padding: top, right, bottom, left -->
148
                        <label><input type="checkbox" value="{{{.}}}" name="courses_levelonecheckbox"> {{{.}}}</label>
149
                    </li>
150
                 {{/uniquelevelones}}
151
               </ul>
152
             </li>
153
            <!-- Filter course list by selecting second level category -->
154
             <li class="nav-item dropdown" {{^showlevel2}}hidden{{/showlevel2}}>
155
               <a class = "nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown">{{label_level_2}}<span class="caret"></span></a>
156
               <ul class="dropdown-menu" id="courses_leveltwodropdown">
157
                 {{#uniqueleveltwoes}}
158
                    <li class = "dropdown-item" style="padding: 0 0 0 1.5rem"> <!-- padding: top, right, bottom, left -->
159
                        <label><input type="checkbox" value="{{{.}}}" name="courses_leveltwocheckbox"> {{{.}}}</label>
160
                    </li>
161
                 {{/uniqueleveltwoes}}
162
               </ul>
163
             </li>
164
               <!-- Filter course list by selecting third level category -->
165
               <li class="nav-item dropdown" {{^showlevel3}}hidden{{/showlevel3}}>
166
                   <a class = "nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown">{{label_level_3}}<span class="caret"></span></a>
167
                   <ul class="dropdown-menu" id="courses_levelthreedropdown">
168
                       {{#uniquelevelthrees}}
169
                           <li class = "dropdown-item" style="padding: 0 0 0 1.5rem"> <!-- padding: top, right, bottom, left -->
170
                               <label><input type="checkbox" value="{{{.}}}" name="courses_levelthreecheckbox"> {{{.}}}</label>
171
                           </li>
172
                       {{/uniquelevelthrees}}
173
                   </ul>
174
               </li>
175
               <!-- Filter course list by selecting fourth level category -->
176
               <li class="nav-item dropdown" {{^showlevel4}}hidden{{/showlevel4}}>
177
                   <a class = "nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown">{{label_level_4}}<span class="caret"></span></a>
178
                   <ul class="dropdown-menu" id="courses_levelfourdropdown">
179
                       {{#uniquelevelfours}}
180
                           <li class = "dropdown-item" style="padding: 0 0 0 1.5rem"> <!-- padding: top, right, bottom, left -->
181
                               <label><input type="checkbox" value="{{{.}}}" name="courses_levelfourcheckbox"> {{{.}}}</label>
182
                           </li>
183
                       {{/uniquelevelfours}}
184
                   </ul>
185
               </li>
186
               <!-- Filter course list by selecting fifth level category -->
187
               <li class="nav-item dropdown" {{^showlevel5}}hidden{{/showlevel5}}>
188
                   <a class = "nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown">{{label_level_5}}<span class="caret"></span></a>
189
                   <ul class="dropdown-menu" id="courses_levelfivedropdown">
190
                       {{#uniquelevelfives}}
191
                           <li class = "dropdown-item" style="padding: 0 0 0 1.5rem"> <!-- padding: top, right, bottom, left -->
192
                               <label><input type="checkbox" value="{{{.}}}" name="courses_levelfivecheckbox"> {{{.}}}</label>
193
                           </li>
194
                       {{/uniquelevelfives}}
195
                   </ul>
196
               </li>
197
          </ul>
198
        </div>
199
    </div>
200
 
201
	<div class = "table table-responsive">
202
	  <table id = "courseTable" class="stripe hover row-border">
203
	    <thead>
204
	      <tr>
205
              <th>ID</th>
206
              <th>{{#str}}shortnamecourse{{/str}}</th>
207
              <th>{{#str}}fullnamecourse{{/str}}</th>
208
              <th {{^showlevel1}}hidden{{/showlevel1}}>{{label_level_1}}</th>
209
              <th {{^showlevel2}}hidden{{/showlevel2}}>{{label_level_2}}</th>
210
              <th {{^showlevel3}}hidden{{/showlevel3}}>{{label_level_3}}</th>
211
              <th {{^showlevel4}}hidden{{/showlevel4}}>{{label_level_4}}</th>
212
              <th {{^showlevel5}}hidden{{/showlevel5}}>{{label_level_5}}</th>
213
              <th>{{#str}}startdate{{/str}}</th>
214
              <th>{{#str}}visible{{/str}}</th>
215
	      </tr>
216
	    </thead>
217
	    <tbody>
218
	    </tbody>
219
	  </table>
220
	</div>
221
 
222
	<span class="loading-icon text-center" id="courseTable-loadingIcon">{{#pix}} i/loading, core, {{#str}} loading {{/str}} {{/pix}}</span>
223
</div>
224
 
225
{{#js}}
226
require(['tool_supporter/load_information', 'jquery', 'core/ajax', 'core/notification', 'core/templates',
227
         'tool_supporter/datatables', 'tool_supporter/table_filter'],
228
    function(loadInformation, $, ajax, notification, templates, datatables, tableFilter) {
229
 
230
        var columns1 = [
231
            {data: 'id', "searchable": true, name: 'ID'},
232
            {data: 'shortname', "searchable": true, name: '{{#str}}shortnamecourse{{/str}}',
233
                "visible": {{#showshortname}}true{{/showshortname}}{{^showshortname}}false{{/showshortname}}},
234
            {data: 'fullname', name: '{{#str}}fullnamecourse{{/str}}',
235
                "visible": {{#showfullname}}true{{/showfullname}}{{^showfullname}}false{{/showfullname}}},
236
            {data: 'level_one', name: '{{label_level_1}}',
237
                "visible": {{#showlevel1}}true{{/showlevel1}}{{^showlevel1}}false{{/showlevel1}}},
238
            {data: 'level_two', name: '{{label_level_2}}',
239
                "visible": {{#showlevel2}}true{{/showlevel2}}{{^showlevel2}}false{{/showlevel2}}},
240
            {data: 'level_three', name: '{{label_level_3}}',
241
                "visible": {{#showlevel3}}true{{/showlevel3}}{{^showlevel3}}false{{/showlevel3}}},
242
            {data: 'level_four', name: '{{label_level_4}}',
243
                "visible": {{#showlevel4}}true{{/showlevel4}}{{^showlevel4}}false{{/showlevel4}}},
244
            {data: 'level_five', name: '{{label_level_5}}',
245
                "visible": {{#showlevel5}}true{{/showlevel5}}{{^showlevel5}}false{{/showlevel5}}},
246
            {data: 'startdate', name: '{{#str}}startdate{{/str}}',
247
                "visible": {{#showstartdate}}true{{/showstartdate}}{{^showstartdate}}false{{/showstartdate}}},
248
            {data: 'visible', name: '{{#str}}visible{{/str}}',
249
                "visible": {{#showvisible}}true{{/showvisible}}{{^showvisible}}false{{/showvisible}}}
250
                       ];
251
 
252
        // Convert the table to dataTable and apply Filtering.
253
        datatables.dataTableAjax('#courseTable', 'tool_supporter_get_courses', {}, 'courses', columns1);
254
 
255
        // Refresh this table.
256
        loadInformation.clickOnRefresh('#courseTable', 'tool_supporter_get_courses', {}, 'courses', columns1);
257
 
258
        // Load detailed information about the clicked course.
259
        loadInformation.clickOnCourse('#courseTable');
260
 
261
        // Search the table.
262
        tableFilter.searchTable('#courseTable', '#course_table_column_chooser', '#course_table_search_input', columns1);
263
 
264
        // Clear filters when button is clicked.
265
        tableFilter.coursesClearFilters('#courseTable');
266
  });
267
{{/js}}