diff options
author | Simon Rettberg | 2016-08-21 17:56:00 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-08-21 17:56:00 +0200 |
commit | f19f0f2aa298d289bc7e4f2ef08affd72067900d (patch) | |
tree | bdd410dd5c66a593a55b4c371d0070437921d4db /modules-available/dozmod | |
parent | [exams] Fix exam mode detection for global location/clients without location (diff) | |
download | slx-admin-f19f0f2aa298d289bc7e4f2ef08affd72067900d.tar.gz slx-admin-f19f0f2aa298d289bc7e4f2ef08affd72067900d.tar.xz slx-admin-f19f0f2aa298d289bc7e4f2ef08affd72067900d.zip |
[dozmod] Expect the client to tell wether it is running in exam mode and compare to desired state of its location
If the client and server disagree about exam mode, the client will get a
dummy list of lectures/vms telling the user to reboot the machine. Not the
best solution but sufficient for now.
Diffstat (limited to 'modules-available/dozmod')
-rw-r--r-- | modules-available/dozmod/api.inc.php | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/modules-available/dozmod/api.inc.php b/modules-available/dozmod/api.inc.php index 83b4981d..accfe813 100644 --- a/modules-available/dozmod/api.inc.php +++ b/modules-available/dozmod/api.inc.php @@ -99,18 +99,66 @@ function xmlToLectureIds($responseXML) return $uuids; } +function sendExamModeMismatch() +{ + Header('Content-Type: text/xml; charset=utf-8'); + echo + <<<BLA + <settings> + <eintrag> + <image_name param="null"/> + <priority param="100"/> + <creator param="Ernie Esslingen"/> + <short_description param="Klausurmodus geƤndert, bitte PC neustarten"/> + <long_description param="Der Klausurmodus wurde ein- oder ausgeschaltet, bitte starten Sie den PC neu"/> + <uuid param="exam-mode-warning"/> + <virtualmachine param="exam-mode-warning"/> + <os param="debian8"/> + <virtualizer_name param="null"/> + <os_name param="null"/> + <for_location param="0"/> + <is_template param="0"/> + </eintrag> + <eintrag> + <image_name param="null"/> + <priority param="200"/> + <creator param="Ernie Esslingen"/> + <short_description param="Exam mode changed, please reboot PC"/> + <long_description param="Exam mode has been activated or deactivated since this PC was booted; please reboot the PC"/> + <uuid param="exam-mode-warning"/> + <virtualmachine param="exam-mode-warning"/> + <os param="debian8"/> + <virtualizer_name param="null"/> + <os_name param="null"/> + <for_location param="0"/> + <is_template param="0"/> + </eintrag> + </settings> +BLA; + exit(0); +} + /** Caching wrapper around _getLecturesForLocations() */ function getListForLocations($locationIds, $raw) { /* if in any of the locations there is an exam active, consider the client to be in "exam-mode" and only offer him exams (no lectures) */ $key = 'lectures_' . cache_hash($locationIds); - $examMode = false; + $examMode = Request::get('exams', 'normal-mode', 'string') !== 'normal-mode'; + $clientServerMismatch = false; if (Module::isAvailable('exams')) { - $examMode = Exams::isInExamMode($locationIds); - if ($examMode) { - $key .= '_exams'; - } + // If we have the exam mode module, we can enforce a server side check and make sure it agrees with the client + $serverExamMode = Exams::isInExamMode($locationIds); + $clientServerMismatch = ($serverExamMode !== $examMode); + $examMode = $serverExamMode; + } + // Only enforce exam mode validity check if the client requests the raw xml data + if ($raw && $clientServerMismatch) { + sendExamModeMismatch(); // does not return + } + // Proceed normally from here on + if ($examMode) { + $key .= '_exams'; } $rawKey = $key . '_raw'; if ($raw) { |