-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbreak.html
314 lines (237 loc) · 12.8 KB
/
break.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0">
<title>Break</title>
<script src="jspsych-6.3.1/jspsych.js"></script>
<script src='./jspsych-6.3.1/plugins/jspsych-instructions.js'></script>
<script src='./jspsych-6.3.1/plugins/jspsych-html-slider-response.js'></script>
<script src="jatos.js"></script>
<link rel="stylesheet" href="jspsych-6.3.1/css/jspsych.css" type="text/css">
</link>
<link rel="stylesheet" href="./extra_files/custom.css" type="text/css">
</link>
</head>
<body>
<script>
//start timeline
jatos.onLoad(function () {
const calc_perf = function (data) {
let perc_corr
// Get trials that had a correct response
let correct_exists = data.filter(item => item.correct_response != null)
// Count the number of correct responses
let n_corr = correct_exists.filter(item => item.correct == true).length
perc_corr = n_corr * 100 / correct_exists.length
return perc_corr
}
let comp_to_start = []
// Whats the title of the break page? This will change if exposure is about to begin.
var page_title = 'Break'
//make a timeline
let timeline = [];
let instructions_text = []
let instruction_pages = []
// Was last finished condition an exposure one?
if (jatos.studySessionData.latestFinishedComponentPos == jatos.studySessionData.inputData.component_positions.exposure) {
// Check if all sessions done:
if (jatos.studySessionData.inputData.experiment_parameters.n_exposure_sessions == jatos.studySessionData.inputData.session_counters.exposure) {
// Calculate performance on the "same" trials
let perc_corr_same = calc_perf(
jatos.studySessionData.outputData.exposure.filter(
item => item.session == jatos.studySessionData.inputData.session_counters.exposure & item.correct_response == 'q')
)
// Now difference trials
let perc_corr_diff = calc_perf(
jatos.studySessionData.outputData.exposure.filter(
item => item.session == jatos.studySessionData.inputData.session_counters.exposure & item.correct_response == 'p')
)
// Calculate for all trials
let perc_corr_all = calc_perf(
jatos.studySessionData.outputData.exposure.filter(
item => item.session == jatos.studySessionData.inputData.session_counters.exposure
)
)
instructions_text = 'Thanks! For the last session, you were accurate on ' + Math.floor(perc_corr_same) + '% of the "same" trials and ' + Math.floor(perc_corr_diff) + '% of the "different" trials! Overall, you were ' + Math.floor(perc_corr_all) + '% accurate on all trials. <br> You have finished the "Same/Different" task. <br> <strong>Please take a break of no more than 1 minute!</strong><br>Next, you will do the similarity judgment task one more time.'
instruction_pages = [
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text + '</p>' +
'</div>',
]
comp_to_start = jatos.studySessionData.inputData.component_positions.triplet_task
} else {
// Calculate performance on the "same" trials
let perc_corr_same = calc_perf(
jatos.studySessionData.outputData.exposure.filter(
item => item.session == jatos.studySessionData.inputData.session_counters.exposure & item.correct_response == 'q')
)
let perc_corr_diff = calc_perf(
jatos.studySessionData.outputData.exposure.filter(
item => item.session == jatos.studySessionData.inputData.session_counters.exposure & item.correct_response == 'p')
)
// Calculate for all trials
let perc_corr_all = calc_perf(
jatos.studySessionData.outputData.exposure.filter(
item => item.session == jatos.studySessionData.inputData.session_counters.exposure
)
)
instructions_text = 'Thanks! For the last session, you were accurate on ' + Math.floor(perc_corr_same) + '% of the "same" trials and ' + Math.floor(perc_corr_diff) + '% of the "different" trials! Overall, you were ' + Math.floor(perc_corr_all) + '% accurate on all trials.<br> You have finished session ' + jatos.studySessionData.inputData.session_counters.exposure + ' of ' + jatos.studySessionData.inputData.experiment_parameters.n_exposure_sessions + ' of the "Same/Different" task. Please take a short break of maximum 30 seconds and then continue.'
instruction_pages = [
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text + '</p>' +
'</div>',
]
comp_to_start = jatos.studySessionData.inputData.component_positions.exposure
}
} else if (jatos.studySessionData.latestFinishedComponentPos == jatos.studySessionData.inputData.component_positions.triplet_task) {
// Check if pre-exposure happened already or not
if (jatos.studySessionData.inputData.session_counters.pre_exposure == 0) {
// Calculate performance
let perc_corr = calc_perf(jatos.studySessionData.outputData.practice)
instructions_text = 'Thanks! You were accurate on ' + Math.floor(perc_corr) + '% of the trials! <br> Those were practice trials. Now you will do the real trials! <br><br> You will do a total of ' + jatos.studySessionData.inputData.experiment_parameters.n_pre_exp_triplet_sessions + ' sessions, each with ' + jatos.studySessionData.inputData.pre_exposure_trials[0].length + ' trials.'
instruction_pages = [
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text + '</p>' +
'</div>',
]
comp_to_start = jatos.studySessionData.inputData.component_positions.triplet_task
} else if (jatos.studySessionData.inputData.session_counters.exposure == 0) {
// So we're done with pre-exposure
// debugger
// Now check if all sessions ran or not
if (jatos.studySessionData.inputData.session_counters.pre_exposure == jatos.studySessionData.inputData.experiment_parameters.n_pre_exp_triplet_sessions) {
// debugger
// Calculate performance
let perc_corr = calc_perf(jatos.studySessionData.outputData.pre_exposure.filter(item => item.session == jatos.studySessionData.inputData.session_counters.pre_exposure))
let instructions_text_1 =
'Thanks! You were accurate on ' + Math.floor(perc_corr) + '% of the trials! <br> ' +
'That was the end of the similarity task #1. ' +
'<br><b>Now we will move onto the Same/Different task.</b> ' +
'<br><b style="font-size: 150%; color: red;">Please attentively read the instructions below!</b>' +
'<br><br>For this next task, you will see these birds show up on the screen one-by-one. The task is simple: ' +
'<br>If the bird you see is exactly the same as you saw on the previous trial, <b>press the button "q"</b>. ' +
'<br>If the current bird is different than the previous one, <b>press the button "p".</b>' +
'<br><br>For example: the 2nd bird you see should be compared to the 1st one, the 3rd should be compared to the 2nd, the 4th to the 3rd, etc.'
let instructions_text_2 = '<br>Each bird will stay on the screen for at least ' +
(jatos.studySessionData.inputData.experiment_parameters.exposure_stim_min_duration / 1000) +
' seconds, but you can make your response before that too, it will still get registered.' +
'<br><br> However, if you do not respond within ' +
(jatos.studySessionData.inputData.experiment_parameters.exposure_trial_dur / 1000) +
' seconds, the trial will be considered as missed and the next trial will begin.' +
'<br>Please try to be as accurate as possible!'
let instructions_text_3 = '<br> You will do a total of ' +
jatos.studySessionData.inputData.experiment_parameters.n_exposure_sessions +
' sessions for the Same/Different task, each with up to ' +
jatos.studySessionData.inputData.exposure_trials[0].length +
' trials.' +
'<br><br>The very 1st bird you see for each of these ' +
jatos.studySessionData.inputData.experiment_parameters.n_exposure_sessions +
' sessions should be skipped. Start comparing from the 2nd bird of each session!' +
'<br><br><b>Please take a 1 minute break and then start the next task!</b>'
page_title = 'Beginning the Same/Different task!'
instruction_pages = [
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text_1 + '</p>' +
'</div>',
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text_2 + '</p>' +
'</div>',
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text_3 + '</p>' +
'</div>',
]
comp_to_start = jatos.studySessionData.inputData.component_positions.exposure
} else {
// debugger
// Calculate performance
let perc_corr = calc_perf(jatos.studySessionData.outputData.pre_exposure.filter(item => item.session == jatos.studySessionData.inputData.session_counters.pre_exposure))
instructions_text = 'Thanks! You were accurate on ' + Math.floor(perc_corr) + '% of the trials! <br> You have finished session ' + jatos.studySessionData.inputData.session_counters.pre_exposure + ' of ' + jatos.studySessionData.inputData.experiment_parameters.n_pre_exp_triplet_sessions + ' of the similarity task. Please take a short break of maximum 30 seconds and then continue.'
instruction_pages = [
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text + '</p>' +
'</div>',
]
comp_to_start = jatos.studySessionData.inputData.component_positions.triplet_task
}
} else {
// So we're done with post-exposure
// Now check if all sessions ran or not
if (jatos.studySessionData.inputData.session_counters.post_exposure == jatos.studySessionData.inputData.experiment_parameters.n_post_exp_triplet_sessions) {
// debugger
// Calculate performance
let perc_corr = calc_perf(jatos.studySessionData.outputData.post_exposure.filter(item => item.session == jatos.studySessionData.inputData.session_counters.post_exposure))
instructions_text = 'Thanks! You were accurate on ' + Math.floor(perc_corr) + '% of the trials! <br> You are finished with the experiment! <br> Please complete some debriefing questions.'
page_title = 'Finished!'
instruction_pages = [
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text + '</p>' +
'</div>',
]
comp_to_start = jatos.studySessionData.inputData.component_positions.debriefing
} else {
// debugger
// Calculate performance
let perc_corr = calc_perf(jatos.studySessionData.outputData.post_exposure.filter(item => item.session == jatos.studySessionData.inputData.session_counters.post_exposure))
instructions_text = 'Thanks! You were accurate on ' + Math.floor(perc_corr) + '% of the trials! <br> You have finished session ' + jatos.studySessionData.inputData.session_counters.post_exposure + ' of ' + jatos.studySessionData.inputData.experiment_parameters.n_post_exp_triplet_sessions + ' of the similarity task. Please take a short break of maximum 30 seconds and then continue.'
instruction_pages = [
'<div class= "header">' +
'<h1>' + page_title + '</h1>' +
'</div>' +
'<div class="instruct">' +
'<p>' + instructions_text + '</p>' +
'</div>',
]
comp_to_start = jatos.studySessionData.inputData.component_positions.triplet_task
}
}
}
var instructions = {
type: 'instructions',
pages: instruction_pages,
show_clickable_nav: true,
button_label_next: '<span style="color: black"d;> <strong> Next </stong></span>',
};
timeline.push(instructions);
jsPsych.init({
timeline: timeline,
on_finish: function (data) {
// Make JATOS remember that this session was run
jatos.studySessionData.latestFinishedComponentId = jatos.componentId;
jatos.studySessionData.latestFinishedComponentPos = jatos.componentPos;
jatos.studySessionData.latestFinishedComponentTitle = jatos.componentProperties.title;
jatos.submitResultData('[break_start_' + '---' +
JSON.stringify(jatos.studySessionData) +
'---' + '_break_end]',
function () { jatos.startComponentByPos(comp_to_start) });
// jsPsych.data.displayData();
}
});
});
</script>
</body>
</html>