-
Notifications
You must be signed in to change notification settings - Fork 1
/
experiment.js
581 lines (516 loc) · 25 KB
/
experiment.js
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/* ************************************ */
/* Define helper functions */
/* ************************************ */
var getInstructFeedback = function() {
return '<div class = centerbox><p class = center-block-text>' + feedback_instruct_text +
'</p></div>'
}
function assessPerformance() {
var experiment_data = jsPsych.data.getTrialsOfType('single-stim-button')
var missed_count = 0
var trial_count = 0
var rt_array = []
var rt = 0
for (var i = 0; i < experiment_data.length; i++) {
rt = experiment_data[i].rt
trial_count += 1
if (rt == -1) {
missed_count += 1
} else {
rt_array.push(rt)
}
}
//calculate average rt
var avg_rt = -1
if (rt_array.length !== 0) {
avg_rt = math.median(rt_array)
}
var missed_percent = missed_count/experiment_data.length
credit_var = (missed_percent < 0.4 && avg_rt > 200)
jsPsych.data.addDataToLastTrial({"credit_var": credit_var,
"performance_var": performance_var})
}
var appendTestData = function() {
jsPsych.data.addDataToLastTrial({
num_cards_chosen: currID,
num_loss_cards: numLossCards,
gain_amount: gainAmt,
loss_amount: lossAmt,
round_points: roundPointsArray.slice(-1),
whichRound: whichRound
})
}
var getButtons = function(buttonType) {
var buttons = ""
buttons = "<div class = allbuttons>"
for (i = 0; i < 33; i++) {
buttons += "<button type = 'button' class = 'CCT-btn chooseButton' id = " + i +
" onclick = chooseButton(this.id)>" + i + "</button>"
}
return buttons
}
var getBoard = function(board_type) {
var board = ''
if (board_type == 2) {
board = "<div class = cardbox>"
for (i = 1; i < 33; i++) {
board += "<div class = square><input type='image' class = card_image id = c" + i +
" src='images/beforeChosen.png'></div>"
}
} else {
board = "<div class = cardbox2>"
for (i = 1; i < 33; i++) {
board += "<div class = square><input class = card_image type='image' id = c" + i +
" src='images/beforeChosen.png'></div>"
}
}
board += "</div>"
return board
}
var getText = function() {
return '<div class = centerbox><p class = block-text>Overall, you earned ' + totalPoints + ' points. These are the points used for your bonus from three randomly picked trials: ' +
'<ul list-text><li>' + prize1 + '</li><li>' + prize2 + '</li><li>' + prize3 + '</li></ul>' +
'</p><p class = block-text>Press <strong>enter</strong> to continue.</p></div>'
}
var turnOneCard = function(whichCard, win) {
if (win === 'loss') {
document.getElementById("c" + whichCard + "").src =
'images/loss.png';
} else {
document.getElementById("c" + whichCard + "").src =
'images/chosen.png';
}
}
function doSetTimeout(card_i, delay, points, win) {
CCT_timeouts.push(setTimeout(function() {
turnOneCard(card_i, win);
document.getElementById("current_round").innerHTML = 'Current Round Points: ' + points
}, delay));
}
function clearTimers() {
for (var i = 0; i < CCT_timeouts.length; i++) {
clearTimeout(CCT_timeouts[i]);
}
}
var instructFunction = function() {
$('#instructButton').prop('disabled', true)
$('#jspsych-instructions-next').click(function() {
for (var i = 0; i < CCT_timeouts.length; i++) {
clearTimeout(CCT_timeouts[i]);
}
})
$('#jspsych-instructions-back').click(function() {
for (var i = 0; i < CCT_timeouts.length; i++) {
clearTimeout(CCT_timeouts[i]);
}
})
var cards_to_turn = [1, 17, 18, 15, 27, 31, 8]
var total_points = 0
var points_per_card = 10
var delay = 0
for (var i = 0; i < cards_to_turn.length; i++) {
var card_i = cards_to_turn[i]
delay += 250
total_points += points_per_card
doSetTimeout(card_i, delay, total_points, 'win')
}
CCT_timeouts.push(setTimeout(function() {
document.getElementById("instruct1").innerHTML =
'<strong>Example 1: </strong>In the example below, you see 32 unknown cards. The display shows you that 1 of these cards is a loss card. It also tells you that turning over each gain card is worth 10 points to you, and that turning over the loss card will cost you 750 points. Let us suppose you decided to turn over 7 cards and then decided to stop. Please click the "See Result" button to see what happens: <font color = "red">Luckily, none of the seven cards you turned over happened to be the loss card, so your score for this round was 70. Please click the next button.</font>'
}, delay))
}
var instructFunction2 = function() {
$('#instructButton').prop('disabled', true)
var tempArray = [3, 5, 6, 7, 9, 10, 11, 12, 19, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 31, 32
]
var instructTurnCards = function() {
document.getElementById("8").src =
'images/loss.png';
document.getElementById("2").src =
'images/loss.png';
for (i = 0; i < tempArray.length; i++) {
document.getElementById("" + tempArray[i] + "").src =
'images/chosen.png';
}
}
$('#jspsych-instructions-next').click(function() {
for (var i = 0; i < CCT_timeouts.length; i++) {
clearTimeout(CCT_timeouts[i]);
}
})
$('#jspsych-instructions-back').click(function() {
for (var i = 0; i < CCT_timeouts.length; i++) {
clearTimeout(CCT_timeouts[i]);
}
})
var cards_to_turn = [1, 4, 30]
var total_points = 0
var points_per_card = 30
var delay = 0
for (var i = 0; i < cards_to_turn.length; i++) {
var card_i = cards_to_turn[i]
delay += 250
total_points += points_per_card
doSetTimeout(card_i, delay, total_points, 'win')
}
delay += 250
total_points -= 250
doSetTimeout(13, delay, total_points, 'loss')
CCT_timeouts.push(setTimeout(function() {
document.getElementById("instruct2").innerHTML =
'<strong>Example 2: </strong>In the example below, you see 32 unknown cards. The display shows you that 3 of these cards are loss cards. It also tells you that turning over each gain card is worth 30 points to you, and that turning over the loss card will cost you 250 points. Let us suppose you decided to turn over 10 cards and then decided to stop. Please click the "See Result" button to see what happens: <font color = "red">This time, the fourth card you turned over was a loss card. As you saw, the round will immediately end when you turn over the loss card. You had earned 90 points for the 3 gain cards, and then 250 points were subtracted for the loss card, so your score for this round was -160. After the loss points were subtracted from your Round Total, the computer also showed you the cards that you had not yet turned over. Please click the next button.</font>'
}, delay))
CCT_timeouts.push(setTimeout(instructTurnCards, delay + 1000))
}
var getPractice1 = function() {
whichLossCards = [17]
gainAmt = 30
lossAmt = 250
return practiceSetup1
}
var getPractice2 = function() {
whichLossCards = [2,6,31]
gainAmt = 10
lossAmt = 750
return practiceSetup2
}
var appendPayoutData = function(){
jsPsych.data.addDataToLastTrial({reward: [prize1, prize2, prize3]})
}
var chooseButton = function(clicked_id) {
$('#nextButton').prop('disabled', false)
$('.chooseButton').prop('disabled', true)
currID = parseInt(clicked_id)
var roundPoints = 0
var cards_to_turn = jsPsych.randomization.repeat(cardArray, 1).slice(0, currID)
for (var i = 0; i < cards_to_turn.length; i++) {
var card_i = cards_to_turn[i]
if (whichLossCards.indexOf(card_i) == -1) {
roundPoints += gainAmt
} else {
roundPoints -= lossAmt
break
}
}
roundPointsArray.push(roundPoints)
if ($('#feedback').length) {
document.getElementById("feedback").innerHTML =
'<strong>You chose ' + clicked_id +
' card(s)</strong>. When you click on the "Next" button, the next round starts. Please note that the loss amount, the gain amount, and the number of loss cards might have changed.'
}
}
var instructButton = function(clicked_id) {
currID = parseInt(clicked_id)
document.getElementById(clicked_id).src =
'images/chosen.png';
}
// appends text to be presented in the game
function appendTextAfter(input, search_term, new_text) {
var index = input.indexOf(search_term) + search_term.length
return input.slice(0, index) + new_text + input.slice(index)
}
// this function sets up the round params (loss amount, gain amount, which ones are loss cards, initializes the array for cards to be clicked, )
var getRound = function() {
var currID = 0
cardArray = [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
]
shuffledCardArray = jsPsych.randomization.repeat(cardArray, 1)
whichRound = whichRound + 1
randomChosenCards = []
roundParams = shuffledParamsArray.pop()
numLossCards = roundParams[0]
gainAmt = roundParams[1]
lossAmt = roundParams[2]
whichLossCards = []
for (i = 0; i < numLossCards; i++) {
whichLossCards.push(shuffledCardArray.pop())
}
gameState = gameSetup
gameState = appendTextAfter(gameState, 'Game Round: ', whichRound)
gameState = appendTextAfter(gameState, 'Loss Amount: ', lossAmt)
gameState = appendTextAfter(gameState, 'Number of Loss Cards: ', numLossCards)
gameState = appendTextAfter(gameState, 'Gain Amount: ', gainAmt)
return gameState
}
/* ************************************ */
/* Define experimental variables */
/* ************************************ */
// generic task variables
var sumInstructTime = 0 //ms
var instructTimeThresh = 0 ///in seconds
var credit_var = true
var performance_var = 0
// task specific variables
var currID = 0
var numLossCards = 1
var gainAmt = ""
var lossAmt = ""
var points = []
var whichLossCards = [17]
var CCT_timeouts = []
var numRounds = 24
var whichRound = 0
var totalPoints = 0
var roundOver = 0
var roundPointsArray = []
var prize1 = 0
var prize2 = 0
var prize3 = 0
var practiceSetup1 =
"<div class = practiceText><div class = block-text2 id = instruct1><strong>Practice 1: </strong> As mentioned, in the version of the card game you are about to play, you will not turn the cards over one by one. Rather, you will simply choose the total number of cards you would like to turn over (from 0 to 32) and then continue to the next round. If turning over any cards seems too risky to you can click the zero button, in which case your score for this round will automatically be zero. This is a practice round, and it looks just like the game you will play. Please select the number of cards you would like to turn over, given the number of loss cards and the amount that you can gain or lose if you turn over a gain or loss card, as shown below. Please note: The computer will tell you how well you did after all " + numRounds + " game rounds are over!</div></div>" +
"<div class = cct-box2>"+
"<div class = titleBigBox> <div class = titleboxLeft><div class = center-text id = game_round>Game Round: 1</div></div> <div class = titleboxLeft1><div class = center-text id = loss_amount>Loss Amount: 250</div></div> <div class = titleboxMiddle1><div class = center-text id = gain_amount>Gain Amount: 30</div></div> <div class = titlebox><div class = center-text>How many cards do you want to take? </div></div> <div class = titleboxRight1><div class = center-text id = num_loss_cards>Number of Loss Cards: 1</div></div>"+
"<div class = buttonbox><button type='button' id = nextButton class = 'CCT-btn select-button' onclick = clearTimers() disabled>Next Round</button></div>"+
getButtons()+
"</div>"+
getBoard()
var practiceSetup2 =
"<div class = practiceText><div class = block-text2 id = instruct2><strong>Practice 2: </strong> The computer will record your points for each round and will show you the total after you finish all " + numRounds + " rounds of the game. This is the second practice round. Please again select as many cards as you would like to, given the number of loss cards and the amounts that you can win or lose if you turn over a gain or loss card, as shown below.</div></div>"+
"<div class = cct-box2>"+
"<div class = titleBigBox> <div class = titleboxLeft><div class = center-text id = game_round>Game Round: 2</div></div> <div class = titleboxLeft1><div class = center-text id = loss_amount>Loss Amount: 750</div></div> <div class = titleboxMiddle1><div class = center-text id = gain_amount>Gain Amount: 10</div></div> <div class = titlebox><div class = center-text>How many cards do you want to take? </div></div> <div class = titleboxRight1><div class = center-text id = num_loss_cards>Number of Loss Cards: 3</div></div>"+
"<div class = buttonbox><button type='button' id = nextButton class = 'CCT-btn select-button' onclick = clearTimers() disabled>Next Round</button></div>"+
getButtons()+
"</div>"+
getBoard()
// this params array is organized such that the 0 index = the number of loss cards in round, the 1 index = the gain amount of each happy card, and the 2nd index = the loss amount when you turn over a sad face
var paramsArray = [
[1, 10, 250],
[1, 10, 750],
[1, 30, 250],
[1, 30, 750],
[3, 10, 250],
[3, 10, 750],
[3, 30, 250],
[3, 30, 750]
]
var cardArray = [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
]
var shuffledCardArray = jsPsych.randomization.repeat(cardArray, 1)
var shuffledParamsArray = jsPsych.randomization.repeat(paramsArray, numRounds/8)
var gameSetup =
"<div class = practiceText><div class = block-text2 id = feedback></div></div>" +
"<div class = cct-box2>"+
"<div class = titleBigBox> <div class = titleboxLeft><div class = center-text id = game_round>Game Round: </div></div> <div class = titleboxLeft1><div class = center-text id = loss_amount>Loss Amount: </div></div> <div class = titleboxMiddle1><div class = center-text id = gain_amount>Gain Amount: </div></div> <div class = titlebox><div class = center-text>How many cards do you want to take? </div></div> <div class = titleboxRight1><div class = center-text id = num_loss_cards>Number of Loss Cards: </div></div>" +
"<div class = buttonbox><button type='button' id = nextButton class = 'CCT-btn select-button' onclick = clearTimers() disabled>Next Round</button></div>"+
getButtons()+
"</div>"+
getBoard()
/* ************************************ */
/* Set up jsPsych blocks */
/* ************************************ */
//Set up post task questionnaire
var post_task_block = {
type: 'survey-text',
data: {
trial_id: "post task questions"
},
questions: ['<p class = center-block-text style = "font-size: 20px">Please summarize what you were asked to do in this task.</p>',
'<p class = center-block-text style = "font-size: 20px">Do you have any comments about this task?</p>'],
rows: [15, 15],
columns: [60,60]
};
/* define static blocks */
var feedback_instruct_text =
'Welcome to the experiment. This task will take around 15 minutes. Press <strong>enter</strong> to begin.'
var feedback_instruct_block = {
type: 'poldrack-text',
cont_key: [13],
data: {
trial_id: 'instruction'
},
text: getInstructFeedback,
timing_post_trial: 0,
timing_response: 180000
};
/// This ensures that the subject does not read through the instructions too quickly. If they do it too quickly, then we will go over the loop again.
var instruction_trials = []
var instructions_block = {
type: 'poldrack-instructions',
data: {trial_id: 'instruction'},
pages: [
'<div class = centerbox><p class = block-text><strong>Introduction and Explanation</strong>'+
'<p>-You are now going to participate in a card game. In this game, you will turn over cards to win or lose points which are worth money.</p>'+
'<p>-In each game round, you will see 32 cards on the computer screen, face down. You will decide how many of these cards to turn over. Each card is either a gain card or a loss card (there are no neutral cards). You will know how many gain cards and loss cards are in the deck of 32, and how many points you will gain or lose if you turn over a gain or loss card. What you do not know is which of the 32 cards that you see face-down are gain cards and which are loss cards. </p>'+
'<p>-You indicate the number of cards (from 0 to 32) you want to turn over by clicking on a small button. You will not see the cards turned over, but the game will select a random set of cards equal to the number you chose and "turn them over" without you seeing. For each gain card turned over, points are added to your round total and another card is turned over. This continues until a loss card is uncovered or until the number of cards you chose to turn over is reached. The first time a loss card is turned over, the loss points will be subtracted from your current point total and the round is over – even if you indicated that more cards should be turned over. The accumulated total will be your number of points for that round, and you go on to the next round. Each new round starts with a score of 0 points; that means you play each round independently of the other rounds.</p>'+
'<p>-You will play a total of ' + numRounds + ' rounds, three of which will be randomly selected at the end of the session, and you will get a bonus payment proportional to those rounds.</p>',
'<div class = centerbox><p class = block-text><strong>Unknown Cards:</strong>'+
'<p> This is what unknown cards looks like. Turn it over by clicking on it.</p>'+
"<p><input type='image' id = '133' src='images/beforeChosen.png' onclick = instructButton(this.id)>"+
'</p></div>',
'<div class = centerbox><p class = block-text>'+
'<p><strong>The Gain Card:</strong></p>'+
'<p>For every gain card you turn over, your score increases by either 10 or 30 points in different rounds.</p>'+
"<p><input type='image' src='images/chosen.png'>"+
'<p><strong>The Loss Card:</strong></p>'+
"<p><input type='image' src='images/loss.png'></p>"+
'<p>For every loss card you turn over, your score decreases by either 250 or 750 points in different rounds. Furthermore, the round immediately ends (you cannot turn over any more cards). There will be either 1 or 3 loss cards in any given round.</p>'+
'<p>The number of loss cards and the value of points that can be won or lost by turning over a gain or loss card are fixed in each round. This information will always be on display so you know what kind of round you are in.</p>'+
'</p></div>',
"<div class = practiceText><div class = block-text2 id = instruct1><strong>Example 1: </strong>In the example below, you see 32 unknown cards. The display shows you that 1 of these cards is a loss card. It also tells you that turning over each gain card is worth 10 points to you, and that turning over the loss card will cost you 750 points. Let us suppose you decided to turn over 7 cards and then decided to stop. Please click the 'See Result' button to see what happens:</div></div>"+
"<div class = cct-box2>"+
"<div class = titleBigBox> <div class = titleboxLeft><div class = center-text>Game Round: 1</div></div> <div class = titleboxLeft1><div class = center-text>Loss Amount: 750</div></div> <div class = titleboxMiddle1><div class = center-text>Gain Amount: 10</div></div> <div class = titlebox><div class = center-text>How many cards do you want to take? </div></div> <div class = titleboxRight1><div class = center-text>Number of Loss Cards: 1</div></div> <div class = titleboxRight><div class = center-text id = current_round>Current Round Points: 0</div></div>"+
"<div class = buttonbox><button type='button' class = CCT-btn id = instructButton onclick= instructFunction()>See Result</button></div></div>"+
getBoard(2),
"<div class = practiceText><div class = block-text2 id = instruct2><strong>Example 2: </strong>In the example below, you see 32 unknown cards. The display shows you that 3 of these cards are loss cards. It also tells you that turning over each gain card is worth 30 points to you, and that turning over the loss card will cost you 250 points. Let us suppose you decided to turn over 10 cards and then decided to stop. Please click the 'See Result' button to see what happens:</div></div>"+
"<div class = cct-box2>"+
"<div class = titleBigBox> <div class = titleboxLeft><div class = center-text>Game Round: 1</div></div> <div class = titleboxLeft1><div class = center-text>Loss Amount: 250</div></div> <div class = titleboxMiddle1><div class = center-text>Gain Amount: 30</div></div> <div class = titlebox><div class = center-text>How many cards do you want to take? </div></div> <div class = titleboxRight1><div class = center-text>Number of Loss Cards: 3</div></div> <div class = titleboxRight><div class = center-text id = current_round>Current Round Points: 0</div></div>"+
"<div class = buttonbox><button type='button' class = CCT-btn id = instructButton onclick= instructFunction2()>See Result</button></div></div>"+
getBoard(2),
"<div class = centerbox><p class = block-text>Unlike those examples, in the version of the card game you are about to play, you will not turn the cards over one by one. Rather, you will simply choose the total number of cards you would like to turn over (from 0 to 32) and then continue to the next round. We will complete two practice rounds to make sure this is clear. Before proceeding, please make sure you understand the examples on the last two pages.</p></div>"
],
allow_keys: false,
show_clickable_nav: true,
timing_post_trial: 1000
};
instruction_trials.push(feedback_instruct_block)
instruction_trials.push(instructions_block)
var instruction_node = {
timeline: instruction_trials,
/* This function defines stopping criteria */
loop_function: function(data) {
for (i = 0; i < data.length; i++) {
if ((data[i].trial_type == 'poldrack-instructions') && (data[i].rt != -1)) {
rt = data[i].rt
sumInstructTime = sumInstructTime + rt
}
}
if (sumInstructTime <= instructTimeThresh * 1000) {
feedback_instruct_text =
'Read through instructions too quickly. Please take your time and make sure you understand the instructions. Press <strong>enter</strong> to continue.'
return true
} else if (sumInstructTime > instructTimeThresh * 1000) {
feedback_instruct_text = 'Done with instructions. Press <strong>enter</strong> to continue.'
return false
}
}
}
var end_instructions = {
type: 'poldrack-single-stim',
stimulus: '<div class = centerbox><p class = center-block-text><strong>End of Instructions </strong></p><p class = center-block-text>Press <strong>enter</strong> when you are ready to play the game.</p></div>',
is_html: true,
data: {
trial_id: 'end_instructions'
},
choices: [13],
timing_post_trial: 0,
response_ends_trial: true,
};
var end_block = {
type: 'poldrack-text',
data: {
trial_id: 'end',
exp_id: 'columbia_card_task_cold'
},
text: '<div class = centerbox><p class = center-block-text>Finished with this task.</p><p class = center-block-text>Press <strong>enter</strong> to continue.</p></div>',
cont_key: [13],
timing_post_trial: 0,
on_finish: assessPerformance
};
var start_practice_block = {
type: 'poldrack-text',
data: {
trial_id: 'practice_intro'
},
text: '<div class = centerbox><p class = center-block-text>Hello<strong>enter</strong> to begin.</p></div>',
cont_key: [13],
timing_post_trial: 1000
};
var start_test_block = {
type: 'poldrack-text',
data: {
trial_id: 'test_intro'
},
text: '<div class = centerbox><p class = center-block-text>We will now start the test. Respond to the "X" as quickly as possible by pressing the spacebar. Press <strong>enter</strong> to begin.</p></div>',
cont_key: [13],
timing_post_trial: 1000
};
var practice_block1 = {
type: 'single-stim-button',
button_class: 'select-button',
stimulus: getPractice1,
is_html: true,
data: {
trial_id: 'stim',
exp_stage: 'practice'
},
timing_post_trial: 0,
response_ends_trial: true,
on_finish: function() {
appendTestData()
roundOver = 0
currTrial = 0
whichRound = 0
numLossCards = 3
}
};
var practice_block2 = {
type: 'single-stim-button',
button_class: 'select-button',
stimulus: getPractice2,
is_html: true,
data: {
trial_id: 'stim',
exp_stage: 'practice'
},
timing_post_trial: 0,
response_ends_trial: true,
on_finish: function() {
appendTestData()
roundOver = 0
currTrial = 0
whichRound = 0
roundPointsArray = []
}
};
var test_block = {
type: 'single-stim-button',
button_class: 'select-button',
stimulus: getRound,
data: {
trial_id: 'stim',
exp_stage: 'test'
},
timing_post_trial: 0,
on_finish: appendTestData,
response_ends_trial: true,
};
var payout_text = {
type: 'poldrack-text',
text: getText,
data: {
trial_id: 'reward'
},
cont_key: [13],
timing_post_trial: 1000,
on_finish: appendPayoutData,
};
var payoutTrial = {
type: 'call-function',
data: {
trial_id: 'calculate reward'
},
func: function() {
totalPoints = math.sum(roundPointsArray)
randomRoundPointsArray = jsPsych.randomization.repeat(roundPointsArray, 1)
prize1 = randomRoundPointsArray.pop()
prize2 = randomRoundPointsArray.pop()
prize3 = randomRoundPointsArray.pop()
performance_var = prize1 + prize2 + prize3
}
};
/* create experiment definition array */
var columbia_card_task_cold_experiment = [];
columbia_card_task_cold_experiment.push(instruction_node);
columbia_card_task_cold_experiment.push(practice_block1);
columbia_card_task_cold_experiment.push(practice_block2);
columbia_card_task_cold_experiment.push(end_instructions)
for (b = 0; b < numRounds; b++) {
columbia_card_task_cold_experiment.push(test_block);
}
columbia_card_task_cold_experiment.push(payoutTrial);
columbia_card_task_cold_experiment.push(payout_text);
columbia_card_task_cold_experiment.push(post_task_block)
columbia_card_task_cold_experiment.push(end_block);