Show sourcecode
The following files exists in this folder. Click to view.
admin.php
admin_login.php
api/
config.php
css/
db_setup.php
index.php
js/
results.php
tests/
index.php
93 lines UTF-8 Unix (LF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
<?php require __DIR__ . '/config.php'; ?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Start</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<h1>Välkommen!</h1>
<p>Skriv in din e-post adress för att fortsätta. Du kommer få 3 korta uppgifter.</p>
<form id="start-form">
<div class="form-group">
<label for="email">Din E-post adress</label>
<input type="email" id="email" name="email" required placeholder="namn@varmdogymnasium.se">
</div>
<div class="form-group">
<label for="group">Välj Grupp</label>
<select id="group" name="group" required>
<option value="placebo">A</option>
<option value="control">B</option>
</select>
</div>
<?php if ($DEBUG): ?>
<div class="debug-section">
<div class="form-group">
<label for="jump">Debug: Jump to test</label>
<select id="jump" name="jump">
<option value="">Normal flow</option>
<option value="tests/reaction.php">Reaction Time</option>
<option value="tests/maze.php">Maze</option>
<option value="tests/simon.php">Simon Says</option>
<option value="results.php">Results</option>
</select>
</div>
</div>
<?php endif; ?>
<button type="submit" class="btn btn-primary">Starta</button>
</form>
</div>
<script>
const DEBUG = <?= $DEBUG ? 'true' : 'false' ?>;
document.getElementById('start-form').addEventListener('submit', async function(e) {
e.preventDefault();
const email = document.getElementById('email').value.trim();
const group = document.getElementById('group').value;
if (!email) {
alert('Vänligen ange din e-postadress.');
return;
}
try {
const resp = await fetch('api/start_session.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: email,
group_type: group,
user_agent: navigator.userAgent
})
});
if (!resp.ok) throw new Error('Server error: ' + resp.status);
const data = await resp.json();
sessionStorage.setItem('participant_id', data.participant_id);
// Check for debug jump
const jumpEl = document.getElementById('jump');
if (DEBUG && jumpEl && jumpEl.value) {
window.location.href = jumpEl.value;
} else {
window.location.href = 'tests/reaction.php';
}
} catch (err) {
alert('Fel vid start av session: ' + err.message);
console.error(err);
}
});
</script>
</body>
</html>