diff options
author | Simon Rettberg | 2016-06-24 14:24:00 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-06-24 14:24:00 +0200 |
commit | 43281909e652d651e8d5b721b440ea5c6eaf8798 (patch) | |
tree | cd802be78717f79114de2924e6d6615cea3866ed /modules-available/exams | |
parent | [exams] Move to content group; fix timepicker; mark old exams (diff) | |
download | slx-admin-43281909e652d651e8d5b721b440ea5c6eaf8798.tar.gz slx-admin-43281909e652d651e8d5b721b440ea5c6eaf8798.tar.xz slx-admin-43281909e652d651e8d5b721b440ea5c6eaf8798.zip |
[exams] Indent location by tree depth; fix ordering of locations in vis.js
Diffstat (limited to 'modules-available/exams')
-rw-r--r-- | modules-available/exams/page.inc.php | 16 | ||||
-rw-r--r-- | modules-available/exams/templates/page-add-edit-exam.html | 2 | ||||
-rw-r--r-- | modules-available/exams/templates/page-exams.html | 13 |
3 files changed, 20 insertions, 11 deletions
diff --git a/modules-available/exams/page.inc.php b/modules-available/exams/page.inc.php index 56ab50f7..94973a4d 100644 --- a/modules-available/exams/page.inc.php +++ b/modules-available/exams/page.inc.php @@ -13,14 +13,15 @@ class Page_Exams extends Page protected function readLocations($examid = null) { if ($examid == null) { - $tmp = Database::simpleQuery("SELECT locationid, locationname FROM location;", []); + $active = 0; } else { - $tmp = Database::simpleQuery("SELECT locationid, locationname, " . - "EXISTS(SELECT * FROM exams NATURAL JOIN exams_x_location WHERE locationid = x.locationid AND examid= :examid) AS selected FROM location x", compact('examid')); - } - while ($loc = $tmp->fetch(PDO::FETCH_ASSOC)) { - $this->locations[] = $loc; + $tmp = Database::simpleQuery("SELECT locationid FROM exams_x_location WHERE examid= :examid", compact('examid')); + $active = array(); + while ($row = $tmp->fetch(PDO::FETCH_ASSOC)) { + $active[] = (int)$row['locationid']; + } } + $this->locations = Location::getLocations($active); } protected function readExams() @@ -99,7 +100,8 @@ class Page_Exams extends Page foreach ($this->locations as $l) { $out[] = [ 'id' => $l['locationid'], - 'content' => $l['locationname'] + 'content' => $l['locationpad'] . ' ' . $l['locationname'], + 'sortIndex' => $l['sortIndex'], ]; } return json_encode($out); diff --git a/modules-available/exams/templates/page-add-edit-exam.html b/modules-available/exams/templates/page-add-edit-exam.html index 98683a54..3cc38cfb 100644 --- a/modules-available/exams/templates/page-add-edit-exam.html +++ b/modules-available/exams/templates/page-add-edit-exam.html @@ -10,7 +10,7 @@ <label for="locations">{{lang_location}}</label> <select id="locations" multiple name="locations[]"> {{#locations}} - <option value="{{locationid}}" {{#selected}}selected{{/selected}}> {{locationname}}</option> + <option value="{{locationid}}" {{#selected}}selected{{/selected}}>{{locationpad}} {{locationname}}</option> {{/locations}} </select> </div> diff --git a/modules-available/exams/templates/page-exams.html b/modules-available/exams/templates/page-exams.html index d0be479d..45ec0b50 100644 --- a/modules-available/exams/templates/page-exams.html +++ b/modules-available/exams/templates/page-exams.html @@ -43,8 +43,14 @@ <script type="application/javascript"><!-- -function customOrder(a, b) { - return 1000; // just in order of appeareance +function itemOrderFun(a, b) { + return a.content.localeCompare(b.content); +} + +function groupOrderFun(a, b) { + var s = a.sortIndex - b.sortIndex; + if (s != 0) return s; + return itemOrderFun(a, b); } document.addEventListener("DOMContentLoaded", function () { @@ -67,7 +73,8 @@ document.addEventListener("DOMContentLoaded", function () { 'max' : {{vis_max_date}}, 'zoomMin': 6 * 3600 * 1000, 'zoomMax': 2 * 86400 * 1000, - 'order' : customOrder, + 'order' : itemOrderFun, + 'groupOrder' : groupOrderFun, 'locale' : language, 'moment' : function(date) { return vis.moment(date).utc(); } }; |