2 This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 @template core_question/tag_condition
20 An auto-complete select box containing a list of available tags to
21 filter the quesiton bank questions by.
23 Classes required for JS:
26 Data attributes required for JS:
29 Context variables required for this template:
30 * tagoptions A list of available tags
32 Example context (json):
48 <div class="tag-condition-container" data-region="tag-condition-container-{{uniqid}}">
49 <div class="form-group">
50 <select multiple name="qtagids[]" class="form-control invisible" size="3" data-region="tag-select">
52 <option {{#selected}}selected{{/selected}} value="{{id}}">{{name}}</option>
55 {{< core/overlay_loading }}
56 {{$hiddenclass}}{{/hiddenclass}}
57 {{/ core/overlay_loading }}
64 'core/form-autocomplete'
70 var root = $('[data-region="tag-condition-container-{{uniqid}}"]');
71 var selectElement = root.find('[data-region="tag-select"]');
72 var loadingContainer = root.find('[data-region="overlay-icon-container"]');
73 var placeholderText = {{#quote}}{{#str}} filterbytags, core_question {{/str}}{{/quote}};
74 var noSelectionText = {{#quote}}{{#str}} notagfiltersapplied, core_question {{/str}}{{/quote}};
77 selectElement, // Element to enhance.
78 false, // Don't allow support for creating new tags.
79 false, // Don't allow AMD module to handle loading new tags.
80 placeholderText, // Placeholder text.
81 false, // Make search case insensitive.
82 true, // Show suggestions for tags.
83 noSelectionText // Text when no tags are selected.
85 // Hide the loading icon once the autocomplete has initialised.
86 loadingContainer.addClass('hidden');
89 // We need to trigger a form submission because of how the question bank
90 // page handles reloading the questions when an option changes.
91 selectElement.on('change', function() {
92 selectElement.closest('form').submit();