-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiment.py
563 lines (519 loc) · 27.8 KB
/
experiment.py
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
from functions import *
from functions import single_selection_screen
from parameters import *
import csv
import random
### START
# Display welcome text
display_text(win, welcome_text)
wait_for_spacebar()
display_question_with_input(win, 'Wpisz swoje imię by inni uczestnicy mogli Cie rozpoznać.\n\n Po wpisaniu wciśnij ENTER by potwierdzić')
while not understood:
# display instructions
display_text(win, instructions1)
wait_for_spacebar()
display_text(win, instructions2)
wait_for_spacebar()
display_fixation_cross(win,iti,jitter)
investment_text = f'Masz w tej chwili {max_investment_p:.1f}\n\n\nIle chciałabyś/byś zainwestować?\n\n\nWciśnij ENTER by potwierdzić'
investment_p, rt = tg_invest(win, prompt_text=investment_text, min_investment=min_investment_p, max_investment=max_investment_p)
investment_return = 3 * investment_p
display_text(win, instructions3)
wait_for_spacebar()
display_text(win,f'Inwestycja została pomnożona trzykrotnie i wynosi {investment_return:.1f}\n\n\nPoczekaj aż Twój powiernik podejmie decyzje')
# Generate a random float between 3 and 8 seconds
delay = random.uniform(5, 10)
# Wait for the random delay
core.wait(delay)
display_text(win, instructions4)
wait_for_spacebar()
display_fixation_cross(win,cross_feedback,jitter)
return_p = tg_return(win, return_text=return_text_p, investment=investment_p, multiplier=1.5)
feedback_jitter = random.uniform(-jitter, jitter)
core.wait(feedback_time+feedback_jitter)
display_text(win, instructions5)
instructions_input = wait_for_input()
if instructions_input == "Space bar pressed":
understood = True
elif instructions_input == "Enter key pressed":
understood = False
# appraisal start
if appraisal:
### appraisal start
# Display text on the left side
display_text(win, esm_start_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# open a file to store esm data
with open(esm_file_path, mode='w', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
writer.writerow(["participant", "esm", 'question', 'answer', 'previous_condition']) # Write the header row
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different feelings
random.shuffle(feelings)
for feeling in feelings:
choice= single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'before', feeling, choice, 'none']) # Write the iteration number and data
random.shuffle(feelings2)
for feeling in feelings2:
choice = single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'before', feeling, choice, 'none']) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_end_text)
# Keep the window open till spacebar pressed by the experimentator
wait_for_spacebar()
# open a file to store esm data
with open(tg_file_path, mode='w', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
writer.writerow(["participant", "condition", 'investment', 'investment_return','multiplier','return', 'RT','delay', 'jitter_iti', 'jitter_feedback_before', 'jitter_feedback_after','block_total']) # Write the header row
# tg block 1
# Loop through the specified number of iterations
# Display block start name
display_text(win, text_block1and3)
wait_for_spacebar()
core.wait(3)
with open(tg_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
if start_condition == "fair":
multiplier = 1.3
min_return = 1.0
max_return = 1.5
elif start_condition == "unfair":
multiplier = 0.3
min_return = 0.0
max_return = 0.3
else:
raise ValueError("Mode must be 'fair' or 'unfair'.")
block1_total = 0
for i in range(TG_trials):
# Display the investment prompt
jitter_iti = display_fixation_cross(win, iti, jitter)
investment_text = f'Masz w tej chwili {max_investment_p:.1f}\n\n\nIle chciałabyś/byś zainwestować?\n\n\nWciśnij ENTER by potwierdzić'
investment_p, rt = tg_invest(win, prompt_text=investment_text, min_investment=min_investment_p, max_investment=max_investment_p)
# Calculate the return, clamping it to the specified range
investment_return = 3*investment_p
display_text(win,f'Inwestycja została pomnożona trzykrotnie i wynosi {investment_return:.1f}\n\n\nPoczekaj aż Twój powiernik podejmie decyzje')
# Generate a random float between 3 and 8 seconds
delay = random.uniform(5, 10)
# Wait for the random delay
core.wait(delay)
# Adjust the multiplier based on the investment compared to the previous one
if previous_investment is not None:
if investment_p < previous_investment:
multiplier += 0.1 # Increase multiplier
elif investment_p > previous_investment:
multiplier -= 0.1 # Decrease multiplier
# Display the return breakdown
jitter_feedback_before = display_fixation_cross(win, cross_feedback, jitter)
return_p = tg_return(win, return_text=return_text_p, investment=investment_p, multiplier=multiplier)
jitter_feedback_after = random.uniform(-jitter, jitter)
core.wait(feedback_time + feedback_jitter)
block1_total = block1_total + return_p
# Store the current investment for comparison in the next iteration
previous_investment = investment_p
writer.writerow([participant_number, start_condition , investment_p, investment_return, multiplier,return_p, rt, delay, jitter_iti, jitter_feedback_before, jitter_feedback_after, block1_total]) # Write the header row
display_text(win, f'W tej części udało Ci się zarobić {block1_total:.1f}\n\n Wciśnij spacje by kontynować')
wait_for_spacebar()
# appraisal 1
if appraisal:
### appraisal
# Display text on the left side
display_text(win, esm_start_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different feelings
random.shuffle(feelings)
for feeling in feelings:
choice= single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'first', feeling, choice, start_condition]) # Write the iteration number and data
random.shuffle(feelings2)
for feeling in feelings2:
choice = single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'first', feeling, choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_others_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(others_opinions)
for opinion in others_opinions:
choice= single_selection_screen(win, words_7, others_text, opinion)
writer.writerow([participant_number, 'first', opinion, choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_interaction_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(interaction_opinions)
for interaction in interaction_opinions:
choice = single_selection_screen(win, words_5, interaction_text, interaction)
writer.writerow([participant_number, 'first', interaction, choice, start_condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[0])
writer.writerow([participant_number, 'first', interaction_opinions_person[0], choice, start_condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[1])
writer.writerow([participant_number, 'first', interaction_opinions_person[1], choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_activity_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(activity_opinions)
for activity in activity_opinions:
choice = single_selection_screen(win, words_7, activity_text, activity)
writer.writerow([participant_number, 'first', activity, choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_end_text)
# Keep the window open till spacebar pressed by the experimentator
wait_for_spacebar()
# Display block start name
display_text(win, text_block2and4)
wait_for_spacebar()
core.wait(3)
# tg block 2
block2_total = 0
with open(tg_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
if start_condition == "fair":
multiplier = 0.3
min_return = 0.0
max_return = 0.3
condition = 'unfair'
elif start_condition == "unfair":
multiplier = 1.3
min_return = 1.0
max_return = 1.5
condition = 'fair'
else:
raise ValueError("Mode must be 'fair' or 'unfair'.")
for i in range(TG_trials):
# Display the investment prompt
jitter_iti = display_fixation_cross(win, iti, jitter)
investment_text = f'Masz w tej chwili {max_investment_p:.1f}\n\n\nIle chciałabyś/byś zainwestować?\n\n\nWciśnij ENTER by potwierdzić'
investment_p, rt = tg_invest(win, prompt_text=investment_text, min_investment=min_investment_p, max_investment=max_investment_p)
# Calculate the return, clamping it to the specified range
investment_return = 3*investment_p
display_text(win,f'Inwestycja została pomnożona trzykrotnie i wynosi {investment_return:.1f}\n\n\nPoczekaj aż Twój powiernik podejmie decyzje')
# Generate a random float between 3 and 8 seconds
delay = random.uniform(5, 10)
# Wait for the random delay
core.wait(delay)
# Adjust the multiplier based on the investment compared to the previous one
if previous_investment is not None:
if investment_p < previous_investment:
multiplier += 0.1 # Increase multiplier
elif investment_p > previous_investment:
multiplier -= 0.1 # Decrease multiplier
# Display the return breakdown
jitter_feedback_before = display_fixation_cross(win, iti, jitter)
return_p = tg_return(win, return_text=return_text_p, investment=investment_p, multiplier=multiplier)
jitter_feedback_after = random.uniform(-jitter, jitter)
core.wait(feedback_time + feedback_jitter)
block2_total = block2_total + return_p
# Store the current investment for comparison in the next iteration
previous_investment = investment_p
writer.writerow([participant_number, condition , investment_p, investment_return, multiplier,return_p, rt, delay, jitter_iti, jitter_feedback_before, jitter_feedback_after, block2_total]) # Write the header row
display_text(win, f'W tej części udało Ci się zarobić {block2_total:.1f}\n\n Wciśnij spacje by kontynować')
wait_for_spacebar()
if appraisal:
### appraisal 2
# Display text on the left side
display_text(win, esm_start_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different feelings
random.shuffle(feelings)
for feeling in feelings:
choice= single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'second', feeling, choice, condition]) # Write the iteration number and data
random.shuffle(feelings2)
for feeling in feelings2:
choice = single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'second', feeling, choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_others_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(others_opinions)
for opinion in others_opinions:
choice= single_selection_screen(win, words_7, others_text, opinion)
writer.writerow([participant_number, 'second', opinion, choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_interaction_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(interaction_opinions)
for interaction in interaction_opinions:
choice = single_selection_screen(win, words_5, interaction_text, interaction)
writer.writerow([participant_number, 'second', interaction, choice, condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[0])
writer.writerow([participant_number, 'second', interaction_opinions_person[0], choice, condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[1])
writer.writerow([participant_number, 'second', interaction_opinions_person[1], choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_activity_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(activity_opinions)
for activity in activity_opinions:
choice = single_selection_screen(win, words_7, activity_text, activity)
writer.writerow([participant_number, 'second', activity, choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_end_text)
# Keep the window open till spacebar pressed by the experimentator
wait_for_spacebar()
# Display block start name
display_text(win, text_block1and3)
wait_for_spacebar()
core.wait(3)
# tg block 3
block3_total = 0
with open(tg_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
if start_condition == "fair":
multiplier = 1.3
min_return = 1.0
max_return = 1.5
elif start_condition == "unfair":
multiplier = 0.3
min_return = 0.0
max_return = 0.3
else:
raise ValueError("Mode must be 'fair' or 'unfair'.")
for i in range(TG_trials):
# Display the investment prompt
jitter_iti = display_fixation_cross(win, iti, jitter)
investment_text = f'Masz w tej chwili {max_investment_p:.1f}\n\n\nIlę chciałabyś/byś zainwestować?\n\n\nWciśnij ENTER by potwierdzić'
investment_p, rt = tg_invest(win, prompt_text=investment_text, min_investment=min_investment_p, max_investment=max_investment_p)
# Calculate the return, clamping it to the specified range
investment_return = 3*investment_p
display_text(win,f'Inwestycja została pomnożona trzykrotnie i wynosi {investment_return:.1f}\n\n\nPoczekaj aż Twój powiernik podejmie decyzje')
# Generate a random float between 3 and 8 seconds
delay = random.uniform(5, 10)
# Wait for the random delay
core.wait(delay)
# Adjust the multiplier based on the investment compared to the previous one
if previous_investment is not None:
if investment_p < previous_investment:
multiplier += 0.1 # Increase multiplier
elif investment_p > previous_investment:
multiplier -= 0.1 # Decrease multiplier
# Display the return breakdown
jitter_feedback_before = display_fixation_cross(win, iti, jitter)
return_p = tg_return(win, return_text=return_text_p, investment=investment_p, multiplier=multiplier)
jitter_feedback_after = random.uniform(-jitter, jitter)
core.wait(feedback_time + feedback_jitter)
block3_total = block3_total + return_p
# Store the current investment for comparison in the next iteration
previous_investment = investment_p
writer.writerow([participant_number, start_condition , investment_p, investment_return, multiplier,return_p, rt, delay, jitter_iti, jitter_feedback_before, jitter_feedback_after, block3_total]) # Write the header row
display_text(win, f'W tej części udało Ci się zarobić {block3_total:.1f}\n\n Wciśnij spacje by kontynować')
wait_for_spacebar()
# appraisal 3
if appraisal:
### appraisal 3
# Display text on the left side
display_text(win, esm_start_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different feelings
random.shuffle(feelings)
for feeling in feelings:
choice= single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'third', feeling, choice, start_condition]) # Write the iteration number and data
random.shuffle(feelings2)
choice = single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'third', feeling, choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_others_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(others_opinions)
for opinion in others_opinions:
choice= single_selection_screen(win, words_7, others_text, opinion)
writer.writerow([participant_number, 'third', opinion, choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_interaction_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(interaction_opinions)
for interaction in interaction_opinions:
choice = single_selection_screen(win, words_5, interaction_text, interaction)
writer.writerow([participant_number, 'third', interaction, choice, start_condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[0])
writer.writerow([participant_number, 'third', interaction_opinions_person[0], choice, start_condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[1])
writer.writerow([participant_number, 'third', interaction_opinions_person[1], choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_activity_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(activity_opinions)
for activity in activity_opinions:
choice = single_selection_screen(win, words_7, activity_text, activity)
writer.writerow([participant_number, 'third', activity, choice, start_condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_end_text)
# Keep the window open till spacebar pressed by the experimentator
wait_for_spacebar()
# Display block start name
display_text(win, text_block2and4)
wait_for_spacebar()
core.wait(3)
# tg block 4
block4_total = 0
with open(tg_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
if start_condition == "fair":
multiplier = 0.3
min_return = 0.0
max_return = 0.3
condition = 'unfair'
elif start_condition == "unfair":
multiplier = 1.3
min_return = 1.0
max_return = 1.5
condition = 'fair'
else:
raise ValueError("Mode must be 'fair' or 'unfair'.")
for i in range(TG_trials):
# Display the investment prompt
jitter_iti = display_fixation_cross(win, iti, jitter)
investment_text = f'Masz w tej chwili {max_investment_p:.1f}\n\n\nIle chciałabyś/byś zainwestować?\n\n\nWciśnij ENTER by potwierdzić'
investment_p, rt = tg_invest(win, prompt_text=investment_text, min_investment=min_investment_p, max_investment=max_investment_p)
# Calculate the return, clamping it to the specified range
investment_return = 3*investment_p
display_text(win,f'Inwestycja została pomnożona trzykrotnie i wynosi {investment_return:.1f}\n\n\nPoczekaj aż Twój powiernik podejmie decyzje')
# Generate a random float between 3 and 8 seconds
delay = random.uniform(5, 10)
# Wait for the random delay
core.wait(delay)
# Adjust the multiplier based on the investment compared to the previous one
if previous_investment is not None:
if investment_p < previous_investment:
multiplier += 0.1 # Increase multiplier
elif investment_p > previous_investment:
multiplier -= 0.1 # Decrease multiplier
# Display the return breakdown
jitter_feedback_before = display_fixation_cross(win, iti, jitter)
return_p = tg_return(win, return_text=return_text_p, investment=investment_p, multiplier=multiplier)
jitter_feedback_after = random.uniform(-jitter, jitter)
core.wait(feedback_time + feedback_jitter)
block4_total = block4_total + return_p
# Store the current investment for comparison in the next iteration
previous_investment = investment_p
writer.writerow([participant_number, condition , investment_p, investment_return, multiplier,return_p, max_investment_p, rt, delay, jitter_iti, jitter_feedback_before, jitter_feedback_after, block4_total]) # Write the header row
display_text(win, f'W tej części udało Ci się zarobić {block4_total:.1f}\n\n Wciśnij spacje by kontynować')
wait_for_spacebar()
# appraisal 4
if appraisal:
### appraisal 3
# Display text on the left side
display_text(win, esm_start_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different feelings
random.shuffle(feelings)
for feeling in feelings:
choice= single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'fourth', feeling, choice, condition]) # Write the iteration number and data
random.shuffle(feelings2)
for feeling in feelings2:
choice = single_selection_screen(win, words_7, feeling_text, feeling)
writer.writerow([participant_number, 'fourth', feeling, choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_others_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(others_opinions)
for opinion in others_opinions:
choice= single_selection_screen(win, words_7, others_text, opinion)
writer.writerow([participant_number, 'fourth', opinion, choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_interaction_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(interaction_opinions)
for interaction in interaction_opinions:
choice = single_selection_screen(win, words_5, interaction_text, interaction)
writer.writerow([participant_number, 'fourth', interaction, choice, condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[0])
writer.writerow([participant_number, 'fourth', interaction_opinions_person[0], choice, condition]) # Write the iteration number and data
choice = single_selection_screen(win, words_person, '', interaction_opinions_person[1])
writer.writerow([participant_number, 'fourth', interaction_opinions_person[1], choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_activity_text)
# Keep the window open for a few seconds
wait_for_spacebar()
# Append rows to the file during the loop
with open(esm_file_path, mode='a', newline='', encoding = 'utf-8') as file:
writer = csv.writer(file)
# loop over different opinions
random.shuffle(activity_opinions)
for activity in activity_opinions:
choice = single_selection_screen(win, words_7, activity_text, activity)
writer.writerow([participant_number, 'fourth', activity, choice, condition]) # Write the iteration number and data
# Display text on the left side
display_text(win, esm_end_text)
# Keep the window open till spacebar pressed by the experimentator
wait_for_spacebar()
total = block1_total + block2_total + block3_total + block4_total
display_text(win, f'W całym eksperymencie udało Ci się zarobić {total:.1f}\n\n Wciśnij spacje by kontynować')
wait_for_spacebar()
# Display welcome text
display_text(win, end_text)
wait_for_spacebar()