summaryrefslogtreecommitdiffstats
path: root/modules-available/exams/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-06-24 14:24:00 +0200
committerSimon Rettberg2016-06-24 14:24:00 +0200
commit43281909e652d651e8d5b721b440ea5c6eaf8798 (patch)
treecd802be78717f79114de2924e6d6615cea3866ed /modules-available/exams/page.inc.php
parent[exams] Move to content group; fix timepicker; mark old exams (diff)
downloadslx-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/page.inc.php')
-rw-r--r--modules-available/exams/page.inc.php16
1 files changed, 9 insertions, 7 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);