OS (MacOS Sierra 10.12):
PsychoPy version (1.84.2):
Hi!
I am new to Psychopy and I know nothing about coding. I have been trying to build an experiment and a lot of your answers helped me a lot so far, so thank you! However, I cannot find anything posts about counting the number of correct answers and turning them into points.
I am trying to replicate the Lockwood et al (2016) experiment about prosocial learning in which participants see two images and have to choose one in 3 seconds (pressing the âleftâ or ârightâ arrows). If they do not chose anything a âmissedâ message appears. If they choose an image, they get a fixation screen (for 2,0 s), then a message telling them if they won 0 (incorrect answer) or 100 points (correct answer) and then another fixation screen again (for 2,0, 2.5, 3,0, 3,5 or 4,0s). The conditions file has the images and the correct answer (the one that gives you 100 points) relate to each image. Here a picture of the flow of the loop.
At the end of the loop, after having shown the 16 images, I want a feedback screen telling the participants how many points they collected in the 16 rounds.
I have tried putting a code component in the trial1 routine as follows:
Begin experiment:
gainsThisRound=0
gainsTotal=0
Begin routine:
if resp.corr:
gainsThisRound=gainsThisRound+100
else:
gainsThisRound=0
End routine:
gainsTotal=gainsThisRound + gainsTotal
thisExp.addData(âgainsTotalâ, gainsTotal)
Then in the gains1 routine I put a text with $gainsTotal
If I do this, the text showing after the 16 rounds is always 0. I am quite lost here, I donât know anything about coding so I donât even know if what I wrote makes sense.
I also thought about the possibility of counting the number of correct responses and multiplying them by 100 to get the total points so I made another version where instead of the code mentioned above I put a piece of code as follows:
Code for trial1 routine:
Begin experiment:
gains = 0
Begin routine:
if practice.thisN == 0:
number_correct = 0
End routine:
if resp.corr:
number_correct = number_correct + 1
else:
number_correct = number_correct
Code for gains1 routine:
End routine:
gains = number_correct *100 #every correct answer gives you 100 points
In this routine (gains1) I put a text with $gains
But again, I only get a 0 as the count of total points.
Could you guys help me out?
Thanks!
Lara