From f2cf42e8ec36ee74bfd7abae0e554c458a03973a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 20 Apr 2018 15:10:27 +0200 Subject: [exams/runmode] Properly disable exam mode for runmodes --- .../exams/baseconfig/getconfig.inc.php | 38 ++++++++++++++-------- .../runmode/baseconfig/getconfig.inc.php | 13 +++----- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/modules-available/exams/baseconfig/getconfig.inc.php b/modules-available/exams/baseconfig/getconfig.inc.php index e5dd01c9..10aa1d84 100644 --- a/modules-available/exams/baseconfig/getconfig.inc.php +++ b/modules-available/exams/baseconfig/getconfig.inc.php @@ -1,18 +1,28 @@ 0) { - ConfigHolder::add('SLX_EXAM_START', $lectureId, 10000); +$foofoo = function($machineUuid) { + // Leave clients in any runmode alone + $res = Database::queryFirst('SELECT machineuuid FROM runmode WHERE machineuuid = :uuid', + array('uuid' => $machineUuid), true); + if (is_array($res)) + return; + // Check if exam mode should apply + $locations = ConfigHolder::get('SLX_LOCATIONS'); + if ($locations === false) { + $locationIds = []; + } else { + $locationIds = explode(' ', $locations); } - if (strlen($autoLogin) > 0) { - ConfigHolder::add('SLX_AUTOLOGIN', $autoLogin, 10000); + if (Exams::isInExamMode($locationIds, $lectureId, $autoLogin)) { + ConfigHolder::add('SLX_EXAM', 'yes', 10000); + if (strlen($lectureId) > 0) { + ConfigHolder::add('SLX_EXAM_START', $lectureId, 10000); + } + if (strlen($autoLogin) > 0) { + ConfigHolder::add('SLX_AUTOLOGIN', $autoLogin, 10000); + } + ConfigHolder::add('SLX_SYSTEMD_TARGET', 'exam-mode', 10000); } - ConfigHolder::add('SLX_SYSTEMD_TARGET', 'exam-mode', 10000); -} +}; + +$foofoo($uuid); \ No newline at end of file diff --git a/modules-available/runmode/baseconfig/getconfig.inc.php b/modules-available/runmode/baseconfig/getconfig.inc.php index 2d622fc7..214a974c 100644 --- a/modules-available/runmode/baseconfig/getconfig.inc.php +++ b/modules-available/runmode/baseconfig/getconfig.inc.php @@ -6,21 +6,16 @@ $foofoo = function($machineUuid) { if ($res === false) return; $config = RunMode::getModuleConfig($res['module']); - if ($config === false || $config->configHook === false) + if ($config === false) return; if (!Module::isAvailable($res['module'])) return; // Not really possible because getModuleConfig would have failed but we should make sure - call_user_func($config->configHook, $machineUuid, $res['modeid'], $res['modedata']); + if ($config->configHook !== false) { + call_user_func($config->configHook, $machineUuid, $res['modeid'], $res['modedata']); + } if ($config->systemdDefaultTarget !== false) { ConfigHolder::add('SLX_SYSTEMD_TARGET', $config->systemdDefaultTarget, 10000); } - // Disable exam mode - not sure if this is generally a good idea; for now, all modes we can think of would - // not make sense that way so do this for now - if (ConfigHolder::get('SLX_EXAM') !== false) { - ConfigHolder::add('SLX_EXAM', '', 100001); - ConfigHolder::add('SLX_EXAM_START', '', 100001); - ConfigHolder::add('SLX_AUTOLOGIN', '', 100001); - } }; $foofoo($uuid); \ No newline at end of file -- cgit v1.2.3-55-g7522