-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.html
235 lines (211 loc) · 10 KB
/
setup.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!doctype html>
<html>
<!--
You can easily run the oMST without this file.
Typically, JATOS studies just run in order, going through whatever tasks you have setup.
This file lets you define an "order" variable that other tasks can respect to queue up
various different tasks or task orders. You'll see at the end of the experiment code bits
about seeing if this variable exists and, if so, to use it to queue up the next task.
Otherwise, this file can be useful as a splash screen or to pre-define some variables,
such as the kind of response (button vs. keyboard) to use, what set to use, etc. You'll
find that the main experiment code looks in several places (e.g., here, Properties in the
experiment or in the Batch from JATOS) to let you flexibly override defaults.
-->
<head>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="jatos.js"></script>
<link rel="stylesheet" href="css/pure-release-0.6.0/pure-min.css">
<link rel="stylesheet" href="css/jspsych.css"></link>
<style>
.jspsych-display-element {
font-size: 200%;
}
.jspsych-btn {
font-size: 125%;
}
</style>
</head>
<body>
<p style="text-align: center; font-size: 200%; vertical-align: middle;">
Welcome to the experiment!
<br><br><strong> Do not hit your browser's back button or the experiment will terminate</strong>
<br><br>
<button id="continueButton" class="jspsych-btn" style="justify-content: center" disabled>Continue</button>
</body>
<script type="text/javascript">
function getID() {
// Try to get a reasonable ID code for this person. You can use the URL with a "sid" parameter or
// specify one in the jatos studySessionData. If not, it'll use the JATOS workerId.
// URL > studySession > workerID
var sid=jatos.urlQueryParameters.sid;
if (sid == undefined) {
sid=jatos.studySessionData['sid'];
}
if (typeof sid == 'undefined') {
if (typeof jatos.workerId !== 'undefined') { // At least try the workerID
sid = jatos.workerId;
}
else { sid=1234; }
}
return sid
}
jatos.onLoad(function () {
// Useful for debugging. There are a number of options for keeping track of your subject's ID code.
// JATOS will create their own, but you may have one come in via a URL parameter if you're using
// something like SONA or Qualtrics. It might not be "sid" -- it's just what I use.
//console.log('In setup, URL sid= ' + jatos.urlQueryParameters.sid);
// We use JATOS' Batch Session to store the number of runs that have been
// completed and we use this to divvy up the actual counterbalance condition
// It's a simple, but effective enough scheme for this. Here, we'll use it
// to just determine which stimulus set gets used.
if (!jatos.batchSession.defined("/nruns")) { // If we don't have this field yet, make it
jatos.batchSession.set("nruns", 0);
}
var nruns = jatos.batchSession.get("nruns");
if (typeof nruns === 'undefined') { // Just catch in case of errors
var nruns=0;
}
var cond = nruns % 2; // We'll give ourselves just conditions here for 2 stimulus sets
// But, we'll also let you set JATOS' properties to force a particular condition
if (jatos.componentJsonInput && typeof jatos.componentJsonInput['force_cond'] !== 'undefined') {
cond=jatos.componentJsonInput['force_cond'];
console.log('condition forced via JSON component to ' + cond);
}
var order=[5,6]; // Default order skips consent and demographics and does study/test -- will add "end" later
var include_consent=0;
var include_demographics=0;
var include_idcode=0;
var include_pcon=0;
// Useful little tags for the experiment and condition that will go into your log files
var exptag='oMST'
var condtag='Unk'
// Setup things for your various counter-balances. Here, we only have 2 (which set is used)
switch (cond) {
case 0: // Stimulus set 1
jatos.studySessionData['set_omst']=1;
condtag='oMST-1';
break;
case 1: // Stimulus set 2
jatos.studySessionData['set_omst']=2;
condtag='oMST-2';
break;
}
// Various manual overrides of that
let sid=getID(); // Come up with a nice ID number for this person
var urlsid=0; // Always log this as a backup
if (typeof jatos.urlQueryParameters.sid !== 'undefined') {
urlsid = jatos.urlQueryParameters.sid;
}
console.log('order: ' + order + ' cond: ' + cond + ' sid: ' + sid);
// Go stick relevant information in the studySessionData. Experiment code reads this for the defaults.
// You can use the various force_XXX options shown in the code to override this (e.g., put a force_set in the
// JATOS component properties for a task)
jatos.studySessionData['sid']=sid;
jatos.studySessionData["order"] = order; // this is that order of tasks shown, not the order of trials in a task
jatos.studySessionData["cond"] = cond;
jatos.studySessionData["taskindex"] = 0;
jatos.studySessionData['exptag'] = exptag;
jatos.studySessionData['condtag'] = condtag;
console.log(include_consent,include_demographics,include_idcode,include_pcon,order)
// Now, take any possible things we'd see in the JSON input and convert them to studySessionData so
// that the individual tasks have a consistent spot to find them.
if (jatos.studyJsonInput && typeof jatos.studyJsonInput['resp_mode'] !== 'undefined') {
jatos.studySessionData['resp_mode']=jatos.studyJsonInput['resp_mode'];
}
if (jatos.studyJsonInput && typeof jatos.studyJsonInput['selfpaced'] !== 'undefined') {
jatos.studySessionData['selfpaced']=jatos.studyJsonInput['selfpaced'];
}
if (typeof jatos.studyJsonInput['set_omst'] !== 'undefined') {
jatos.studySessionData['set_omst']=jatos.studyJsonInput['set_omst'];
}
if (typeof jatos.studyJsonInput['include_demographics'] !== 'undefined') {
include_demographics=jatos.studyJsonInput['include_demographics'];
//console.log('study json include demog' + include_demographics);
}
if (typeof jatos.studyJsonInput['include_consent'] !== 'undefined') {
include_consent=jatos.studyJsonInput['include_consent'];
}
if (typeof jatos.studyJsonInput['include_idcode'] !== 'undefined') {
include_idcode=jatos.studyJsonInput['include_idcode'];
}
if (typeof jatos.studyJsonInput['include_pcon'] !== 'undefined') {
include_pcon=jatos.studyJsonInput['include_pcon'];
}
if (typeof jatos.studyJsonInput['include_icon'] !== 'undefined') {
include_pcon=jatos.studyJsonInput['include_icon'];
}
if (jatos.studyJsonInput) { console.log('jatos.studyJsonInput: ', jatos.studyJsonInput)}
console.log(include_consent,include_demographics,include_idcode,include_pcon,order)
console.log(jatos.studyJsonInput);
//console.log(jatos.batchProperties.title);
// Now, let any batch-level bits override those
if (jatos.batchJsonInput) { console.log('jatos.batchJsonInput: ', jatos.batchJsonInput)}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['resp_mode'] !== 'undefined' ) {
jatos.studySessionData['resp_mode']=jatos.batchJsonInput['resp_mode'];
}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['set_omst'] !== 'undefined' ) {
jatos.studySessionData['set_omst']=jatos.batchJsonInput['set_omst'];
}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['selfpaced'] !== 'undefined' ) {
jatos.studySessionData['selfpaced']=jatos.batchJsonInput['selfpaced'];
}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['include_demographics'] !== 'undefined' ) {
include_demographics=jatos.batchJsonInput['include_demographics'];
console.log('include_demographics batch' + include_demographics);
}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['include_consent'] !== 'undefined' ) {
include_consent=jatos.batchJsonInput['include_consent'];
}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['include_idcode'] !== 'undefined' ) {
include_idcode=jatos.batchJsonInput['include_idcode'];
}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['include_pcon'] !== 'undefined' ) {
include_pcon=jatos.batchJsonInput['include_pcon'];
}
if (jatos.batchJsonInput && typeof jatos.batchJsonInput['include_icon'] !== 'undefined' ) {
include_pcon=jatos.batchJsonInput['include_icon'];
}
console.log(include_consent,include_demographics,include_pcon,order)
if (typeof jatos.urlQueryParameters.set_mst !== 'undefined') {
jatos.studySessionData['set_omst'] = jatos.urlQueryParameters.set_omst;
}
if (include_pcon) { order.unshift(8); }
if (include_demographics) { order.unshift(4); }
if (include_consent) {order.unshift(3); }
if (include_idcode) {order.unshift(2); }
//if (include_pcon) {order.push(6); }
order.push(7); // Add the "end", which is #7 currently
if (jatos.studySessionData['set_omst'] == -1) { // randomize the set and subset
jatos.studySessionData['set_omst'] = Math.floor(Math.random() * 6) + 1;
jatos.studySessionData['subset'] = Math.floor(Math.random() * 3) + 1;
console.log('Stimulus set randomized to ',jatos.studySessionData['set_omst'],jatos.studySessionData['subset'])
}
jatos.studySessionData["order"] = order;
console.log('Worker ID/sid=' + sid + ' URLSID='+urlsid+' omst set='+jatos.studySessionData["set_omst"] );
console.log('order: ' + order);
//console.log('set: ' + jatos.urlQueryParameters.set_mst);
console.log('full: ' + jatos.urlQueryParameters)
console.log("includes: " + include_demographics + include_consent + include_idcode)
var d= new Date();
jatos.appendResultData({
task: "setup-oMST",
subject: sid,
urlsid: urlsid,
selfpaced: jatos.studySessionData['selfpaced'],
respmode: jatos.studySessionData['resp_mode'],
oMSTSet: jatos.studySessionData["set_omst"],
lang: jatos.studySessionData["lang"],
date: d.toString()
});
$('#continueButton').prop('disabled', false);
});
$('#continueButton').click(function () {
var nruns = jatos.batchSession.get("nruns");
jatos.batchSession.set("nruns", nruns+1);
var order=jatos.studySessionData["order"];
var d = new Date();
jatos.studySessionData['datecode']=d.toLocaleDateString();
jatos.startComponentByPos(order[0],jatos.studySessionData);
});
</script>
</html>