From f19f0f2aa298d289bc7e4f2ef08affd72067900d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sun, 21 Aug 2016 17:56:00 +0200 Subject: [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. --- modules-available/dozmod/api.inc.php | 58 ++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'modules-available/dozmod/api.inc.php') 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; + 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) { -- cgit v1.2.3-55-g7522