summaryrefslogtreecommitdiffstats
path: root/modules-available/exams/page.inc.php
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/page.inc.php
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/page.inc.php')
-rw-r--r--modules-available/exams/page.inc.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/modules-available/exams/page.inc.php b/modules-available/exams/page.inc.php
index 3937e108..868f5927 100644
--- a/modules-available/exams/page.inc.php
+++ b/modules-available/exams/page.inc.php
@@ -458,6 +458,12 @@ class Page_Exams extends Page
}
}
+ private function getLocationLookupJson()
+ {
+ $locs = Location::getLocationsAssoc(); // Add key x so we get an object, not array
+ return json_encode(['x' => 0] + array_map(function ($item) { return $item['children']; }, $locs));
+ }
+
protected function doRender()
{
if ($this->action === "show") {
@@ -495,7 +501,7 @@ class Page_Exams extends Page
} elseif ($this->action === "add") {
Render::setTitle(Dictionary::translate('title_add-exam'));
- $data = [];
+ $data = ['locmap' => $this->getLocationLookupJson()];
$baseLecture = Request::any('lectureid', false, 'string');
$locations = null;
if ($baseLecture !== false) {
@@ -533,10 +539,12 @@ class Page_Exams extends Page
}
}
- $data = [];
- $data['exam'] = $exam;
- $data['locations'] = $this->locations;
- $data['lectures'] = $this->lectures;
+ $data = [
+ 'locmap' => $this->getLocationLookupJson(),
+ 'exam' => $exam,
+ 'locations' => $this->locations,
+ 'lectures' => $this->lectures,
+ ];
// if user has no permission to edit for this location, disable the location in the select
foreach ($data['locations'] as &$loc) {