Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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 qbank_managecategories/categories
19
 
20
    Template for displaying category view.
21
 
22
    Context variables required for this template:
23
    * contextid - Context id for js init.
24
    * categoriesrendered - Array representing categories data rendered.
25
    * items - Categories data.
26
    * heading - Category's heading for each context (ie: Course or Quiz).
27
    * ctxlvl - Context level for categories section - context.
28
 
29
    Example context (json):
30
    {
31
        "contextid": "18",
32
        "categoriesrendered": [{
33
            "items": [{
34
                "categoryid": "1",
35
                "questionbankurl": "question/edit.php?cmid=123",
36
                "categoryname": "Default for Miscellaneous",
37
                "idnumber": "1",
38
                "questioncount": " (1)",
39
                "categorydesc": "The default category for questions shared in context Miscellaneous",
40
                "editactionmenu": "<div class='action-menu moodle-actionmenu'>...</div>",
41
                "handle": true,
42
                "iconleft": "<i class=\"icon fa fa-arrow-left fa-fw \" title=\"Move to top level\" role=\"img\" aria-label=\"Move to top level\"></i>",
43
                "iconright": "<i class=\"icon fa fa-arrow-right fa-fw \" title=\"Make child of 'category'\" role=\"img\" aria-label=\"Make child of 'category'\"></i>",
44
                "children": ""
45
            }],
46
            "heading": "Question categories for 'Quiz: qz'",
47
            "ctxlvl": "contextlevel70"
48
        }]
49
    }
50
}}
51
<div id="categoryroot"
52
    class="editing col-11 col-md-12 mt-3 ps-0{{#showdescriptions}} showdescriptions{{/showdescriptions}}"
53
    data-contextid="{{{contextid}}}">
54
    {{#categoriesrendered}}
55
        <h3 class="context-heading">{{heading}}</h3>
56
        <div class="box py-3 boxwidthwide boxaligncenter generalbox questioncategories {{ctxlvl}}">
57
            <ul class="qbank_managecategories-categorylist"
58
                data-contextid="{{contextid}}" data-contextname="{{contextname}}" data-categoryid="{{categoryid}}">
59
                {{#items}}
60
                    {{> qbank_managecategories/category }}
61
                {{/items}}
62
            </ul>
63
        </div>
64
    {{/categoriesrendered}}
65
</div>
66
 
67
 
68
{{#js}}
69
    require(['qbank_managecategories/categoryroot'], (categoryroot) => {
70
        categoryroot.init('#categoryroot');
71
    });
72
    require(['qbank_managecategories/categorylist'], (categorylist) => {
73
        // Initialise top-level lists.
74
        const categoryLists = document.querySelectorAll('.qbank_managecategories-categorylist[data-contextid]');
75
        categoryLists.forEach(element => {
76
            categorylist.init(`.qbank_managecategories-categorylist[data-categoryid="${element.dataset.categoryid}"]`);
77
        });
78
    });
79
{{/js}}