summaryrefslogtreecommitdiffstats
path: root/modules-available/exams/templates/page-add-edit-exam.html
diff options
context:
space:
mode:
authorSimon Rettberg2020-08-06 13:23:03 +0200
committerSimon Rettberg2020-08-06 13:23:30 +0200
commit67a0551f8fb94f0089d27fc7259a713f1bed7a63 (patch)
tree3dc1adc7aefd1ffe4d8d02ebf803da6ebf145025 /modules-available/exams/templates/page-add-edit-exam.html
parent[minilinux] Fix gpg key display (diff)
downloadslx-admin-67a0551f8fb94f0089d27fc7259a713f1bed7a63.tar.gz
slx-admin-67a0551f8fb94f0089d27fc7259a713f1bed7a63.tar.xz
slx-admin-67a0551f8fb94f0089d27fc7259a713f1bed7a63.zip
[exams] Make warnings for locations work with trees
Diffstat (limited to 'modules-available/exams/templates/page-add-edit-exam.html')
-rw-r--r--modules-available/exams/templates/page-add-edit-exam.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules-available/exams/templates/page-add-edit-exam.html b/modules-available/exams/templates/page-add-edit-exam.html
index 5946874c..43ac46dc 100644
--- a/modules-available/exams/templates/page-add-edit-exam.html
+++ b/modules-available/exams/templates/page-add-edit-exam.html
@@ -170,6 +170,7 @@ document.addEventListener("DOMContentLoaded", function () {
moment.locale(LANG);
var slxMoment = moment;
+ var locmap = {{{locmap}}};
var dateSettings = {
format: 'yyyy-mm-dd',
@@ -277,6 +278,17 @@ document.addEventListener("DOMContentLoaded", function () {
})();
showHeading();
};
+
+ var expandLocs = function(locs) {
+ var ret = locs.map(function(n) { return parseInt(n) });
+ for (var i = 0; i < locs.length; ++i) {
+ if ($.isArray(locmap[locs[i]])) {
+ ret.push(...locmap[locs[i]].filter(function (v, i, s) { return ret.indexOf(v) === -1 }));
+ }
+ }
+ return ret;
+ };
+
var updateLocationsInfo = function() {
(function() {
var selectedLocs = $locations.val();
@@ -289,6 +301,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (!$.isArray(selectedLocs)) {
selectedLocs = [selectedLocs];
}
+ selectedLocs = expandLocs(selectedLocs);
+ lecLocs = expandLocs(lecLocs);
for (var i = 0; i < selectedLocs.length; ++i) {
if (lecLocs.indexOf(selectedLocs[i]) === -1) {
$locationWarning.find('.locname').text($locations.find('option[value="' + selectedLocs[i] + '"]').text());