-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-data-collector.html
77 lines (77 loc) · 2.59 KB
/
test-data-collector.html
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
<html>
<head>
<title>Experience Sampler Data Collection Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
function saveData() {
var collectorScriptURL = document.getElementById("collectorScriptURL").value;
studyID = "TEST123";
pid = Math.floor(Math.random() * 100000000);
ptime = Math.floor(Math.random() * 100000000);
var submission = { participant_id: pid, pause_time: ptime, study_id: studyID };
document.getElementById("dataString").innerHTML = JSON.stringify(submission);
$.ajax({
type: 'POST',
url: collectorScriptURL,
data: submission,
crossDomain: true,
success: function (result) {
console.log(result);
document.getElementById("resultString").innerHTML = result;
},
error: function (request, error) {console.log(error);},
});
}
</script>
<style>
.divTable{
display: table;
width: 100%;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
}
.divTableCell, .divTableHead {
border: 1px solid #999999;
display: table-cell;
padding: 3px 10px;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
font-weight: bold;
}
.divTableFoot {
background-color: #EEE;
display: table-footer-group;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
</style>
</head>
<body>
<div><p style="font-size:1.5em;">This webpage has an embedded javascript that simulates a survey submission to your data collector script. Provide the complete URL to the data collector script in the URL textfield. The Study ID value is "TEST123". The <span style="font-weight: bold;">"Participant ID"</span> and <span style="font-weight: bold;">"Pause Time"</span> are randomly generated.</p></div>
<div class="divTable" style="width: 100%;border: 1px solid #000;" >
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell">URL:</div>
<div class="divTableCell"><input type="text" size=100 id="collectorScriptURL"> <button onclick="saveData()">Test Data Collector</button></div>
</div>
<div class="divTableRow">
<div class="divTableCell">Data:</div>
<div class="divTableCell"><span id="dataString"></span></div>
</div>
<div class="divTableRow">
<div class="divTableCell">Result:</div>
<div class="divTableCell"><span id="resultString"></span></div>
</div>
</div>
</div>
</body>
<html>