From 43281909e652d651e8d5b721b440ea5c6eaf8798 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Fri, 24 Jun 2016 14:24:00 +0200
Subject: [exams] Indent location by tree depth; fix ordering of locations in
vis.js
---
modules-available/exams/page.inc.php | 16 +++++++++-------
.../exams/templates/page-add-edit-exam.html | 2 +-
modules-available/exams/templates/page-exams.html | 13 ++++++++++---
modules-available/locations/inc/location.inc.php | 2 ++
4 files changed, 22 insertions(+), 11 deletions(-)
(limited to 'modules-available')
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 @@
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 @@