-
Notifications
You must be signed in to change notification settings - Fork 2
/
resultsTime.php
173 lines (128 loc) · 3.34 KB
/
resultsTime.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<html>
<head>
<title>Gidget Study Results</title>
<script type='text/javascript' src='lib/jquery.js'></script>
<script type='text/javascript' src='runtime.js'></script>
<script type='text/javascript' src='experiment.js'></script>
<script type='text/javascript'>
var results = {
<?php
// Report all errors
error_reporting(-1);
function endsWith($haystack,$needle,$case=true) {
if($case){return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);}
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
}
$myDirectory = opendir("results/");
// get each entry
$indexCount = 0;
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
$indexCount++;
}
// close directory
closedir($myDirectory);
$entries = array();
for($index=0; $index < $indexCount; $index++) {
if(endsWith("$dirArray[$index]", ".json")) {
$data = "";
$filename = $dirArray[$index];
$id = substr($filename, 0, strlen($filename) - 5);
$file_handle = fopen("results/$filename", "r");
if($file_handle === FALSE)
exit("Couldn't open $filename");
while (!feof($file_handle)) {
$line = fgets($file_handle);
$data = $data . $line;
}
fclose($file_handle);
$entries[$id] = $data;
}
}
foreach ( $entries as $id => $data )
echo "'$id' : $data,\n";
?>
}
function add(text) {
$('#results').append(text + ",");
}
function line() {
$('#results').append("\n");
}
function levelsCompleted(row) {
var count = 0;
for(var level in row.levelMetadata) {
if(row.levelMetadata.hasOwnProperty(level)) {
var data = row.levelMetadata[level];
if(data.passed === true)
count++;
}
}
return count;
}
function countSteps(row, kind) {
var count = 0;
for(var level in row.levelMetadata) {
if(row.levelMetadata.hasOwnProperty(level)) {
var data = row.levelMetadata[level];
for(var i = 0; i < data.stepLog.length; i++) {
if(data.stepLog[i].kind === kind)
count++;
}
}
}
return count;
}
function getTimeX(row, kind) {
var myString = "";
for(var level in row.levelMetadata) {
if(row.levelMetadata.hasOwnProperty(level)) {
var data = row.levelMetadata[level];
for(var i = 0; i < data.stepLog.length; i++) {
if(data.stepLog[i].kind === kind)
myString += "," + kind;
}
}
}
return myString;
}
function getTime(row) {
var myString = "";
var calc;
var first = true;
var count = 0;
for(var level in row.levelMetadata) {
if(row.levelMetadata.hasOwnProperty(level)) {
var data = row.levelMetadata[level];
if (first)
{myString += "=" + data.endTime + "-"+ data.startTime + ""; first = false;}
else
{myString += ",=" + data.endTime + "-"+ data.startTime + "";}
count++;
}
}
for (var i = 18-count; i > 0; i--)
{
myString += ",";
}
return myString;
//return calc;
}
$(document).ready(function() {
$('#results').append("mturkcode,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,final\n");
var id, row;
for(id in results) {
if(results.hasOwnProperty(id)) {
var row = results[id];
add(row.code);
add(getTime(row));
line();
}
}
});
</script>
</head>
<body>
<pre id='results'></pre>
</body>
</html>