-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview-results.php
109 lines (101 loc) · 2.29 KB
/
view-results.php
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
require_once("config.php");
if ($_REQUEST["p"] !== RESULTS_PASSWORD) {
header('HTTP/1.0 403 Forbidden');
die('You are not allowed to access this file.');
}
function get_ratio($d) {
$count1 = 0;
$count2 = 0;
foreach ($d as $result) {
if (!is_invalid($result)) {
if ($result['path'] == "1") {
$count1++;
}
else if ($result['path'] == "2") {
$count2++;
}
}
}
return $count1 . ":" . $count2;
}
$data = json_decode(file_get_contents(FILE_RESULTS . ".json"), true);
?>
<html>
<head>
<title>Result data</title>
<style>
body, html {
font-family: sans-serif;
margin: .66em;
background-color: #fff;
color: #444;
}
.bugged {
color: #f00;
}
table, tr, td, th {
border: 0;
}
table {
width: 100%;
border-top: 1px solid #888;
border-bottom: 1px solid #888;
}
thead th {
border-bottom: 1px solid #888;
}
td, th {
padding: .66em .33em;
text-align: center;
}
tbody tr:hover {
background-color: #ffc !important;
}
tbody tr:nth-child(odd) {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<p><a href="csv-results.php?p=<?php echo RESULTS_PASSWORD;?>">Download as CSV</a> - <?php echo count($data); ?> completed results</p>
<table cellpadding="4" cellspacing="0" border="1">
<thead>
<tr>
<th>Timestamp</th>
<th>Participant Code</th>
<th>Time taken</th>
<th>Cue</th>
<th>Age</th>
<th>Gender</th>
<th>Instrumental</th>
<th>Novel</th>
<th>IP</th>
</tr>
</thead>
<tbody>
<?php
if ($data) {
foreach ($data as $row) {
?>
<tr>
<?php
echo "<td>" . date("Y-m-d H:i:s", $row['timestamp']) . "</td>";
echo "<td>" . $row['code'] . "</td>";
echo "<td>" . round(($row['endtime'] - $row['starttime']) / 1000) . "</td>";
echo "<td>" . $row['path'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "<td>" . $row['gender'] . "</td>";
echo "<td>" . $row['instrumental'] . "</td>";
echo "<td>" . $row['novel'] . "</td>";
echo "<td>" . $row['ip'] . "</td>";
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
</body>
</html>