-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
85 lines (83 loc) · 2.92 KB
/
test.php
File metadata and controls
85 lines (83 loc) · 2.92 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
include 'serverScripts/commonStuff.php'; # libraries? what are those?
$testingEnabled = false;
$testEnabled = false;
try {
$db = getDB();
$testingEnabled = (intval($db->querySingle("
SELECT \"Value\"
FROM Settings
WHERE \"Key\" = 'testing_enabled'
")) == 1);
if (isset($_POST["test"])) {
$testID = $_POST["test"];
$testEnabled = (intval($db->querySingle("
SELECT \"TestEnabled\"
FROM Tests
WHERE \"ID\" = $testID;
")) == 1);
}
} catch (Exception $e) {
http_response_code(500);
die($e->getMessage());
}
if (($_SERVER['REQUEST_METHOD'] != 'POST')
|| !isset($_POST["test"])
|| !isset($_POST["firstname"])
|| !isset($_POST["lastname"])
|| !isset($_POST["group"])
|| !$testingEnabled
|| !$testEnabled) {
http_response_code(303);
header('Location: /'); die();
} #define("LOADTYPE", "index");
#include 'tests/'.$_POST["testmodule"];
$test = $_POST["test"];
$questionCount = $db->querySingle("SELECT COUNT(*) FROM TestQuestions WHERE TestID = ".$test);
$answerForm = $db->querySingle("SELECT AnswerForm FROM Tests WHERE ID = ".$test);
$pageScript = $db->querySingle("SELECT PageScript FROM Tests WHERE ID = ".$test);
$answerHandlingScript = $db->querySingle("SELECT AnswerHandlingScript FROM Tests WHERE ID = ".$test);
$guide = $db->querySingle("SELECT Guide FROM Tests WHERE ID = ".$test);
$readableName = $db->querySingle("SELECT ReadableName FROM Tests WHERE ID = ".$test);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Тест: <?php echo $readableName; ?></title>
<script type="text/javascript" src="/clientScripts/jquery.js"></script>
<script>
<?php
echo "questionCount = ".$questionCount.";\n";
echo "\t\t\ttest = \"".$_POST["test"]."\";\n";
echo "\t\t\tfirstName = \"".$_POST["firstname"]."\";\n";
echo "\t\t\tlastName = \"".$_POST["lastname"]."\";\n";
echo "\t\t\tgroup = \"".$_POST["group"]."\";\n";
echo "\t\t\tanswerForm = \"".addcslashes($answerForm, '"\\')."\";";
?>
questionIndex = -1;
<?php if (isset($pageScript)) echo $pageScript; ?>
function answerHandler(){
<?php echo $answerHandlingScript."\n"; ?>
}
</script>
<script type="text/javascript" src="/clientScripts/ajaxQuestion.js"></script>
<link rel="stylesheet" type="text/css" href="/styles/main.css"/>
</head>
<body>
<div class="bg"></div>
<a class="button" id="goHome" href="/" style="position: fixed"><img src="/icons/home.svg" alt="На главную" height="32px"/></a>
<div class="centerADiv">
<?php
echo "<h3 id=\"questiontitle\">Инструкция</h3>";
echo "<div id=\"questiontext\">".$guide."</div>";
?>
<form id="question">
<div id="answerForm" style="display: none">
<?php echo $answerForm; ?>
</div>
<input class="button" type="submit" id="submit" value="Ясно"/>
</form>
</div>
</body>
</html>