summaryrefslogtreecommitdiffstats
path: root/modules-available/exams/baseconfig/getconfig.inc.php
blob: 7e4a70dfebc79808cd8f56d38caef2d728705a41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

/** @var ?string $uuid */
/** @var ?string $ip */

if ($uuid !== null) {
	// Leave clients in any runmode alone
	$res = Database::queryFirst('SELECT machineuuid FROM runmode WHERE machineuuid = :uuid',
		array('uuid' => $uuid), true);
	if (is_array($res))
		return;
	// Check if exam mode should apply
	$locations = ConfigHolder::get('SLX_LOCATIONS');
	if ($locations === null) {
		$locationIds = [];
	} else {
		$locationIds = explode(' ', $locations);
	}
	if (Exams::isInExamMode($locationIds, $lectureId, $autoLogin)) {
		ConfigHolder::add('SLX_EXAM', 'yes', 10000);
		if (!empty($lectureId)) {
			ConfigHolder::add('SLX_EXAM_START', $lectureId, 10000);
		}
		if (!empty($autoLogin)) {
			ConfigHolder::add('SLX_AUTOLOGIN', $autoLogin, 10000);
		}
		ConfigHolder::add('SLX_SYSTEMD_TARGET', 'exam-mode', 10000);
		ConfigHolder::add('SLX_RUNMODE_MODULE', 'exams', 10000);
		// No saver
		ConfigHolder::add('SLX_SCREEN_SAVER_TIMEOUT', '0', 1000);
	}
}