Point counter in online experiments

Hi all,

I’m creating an experiment for my research project and am so close to completing it and uploading it online. However, I have a problem which I can seem to fix so would really appreciate some help. I am using Builder to do this, but with quite a few code components.

In my experiment, participants are shown a picture of a lake, then have to press either ‘a’ or ‘b’ and if they choose the correct one then they “catch a fish” and are presented with a picture of this fish, but if not they are shown an empty fishing rod.

I am trying to add a “fish counter” that is present at the bottom of the screen throughout the trials (with 6 different fish as all 6 lakes have different kinds of fish in them), which is working in psychopy, but not in pavlovia. Below is a screenshot of how this appears in psychopy, but the numbers stay at 0 when I put the study online.

This is the code I am using at the moment…

In ‘Begin Experiment’:

#set no. of fish collected to 0
fish1_pointsA = 0
fish2_pointsA = 0
fish3_pointsA = 0
fish4_pointsA = 0
fish5_pointsA = 0
fish6_pointsA = 0

In “Begin Routine” of my outcome routine (where the corresponding fish image is presented):

if corroutcome_imageA.image == 'stimuli/fish1.png':
    fish1_pointsA += 1
elif corroutcome_imageA.image == 'stimuli/fish2.png':
    fish2_pointsA += 1
elif corroutcome_imageA.image == 'stimuli/fish3.png':
    fish3_pointsA += 1
elif corroutcome_imageA.image == 'stimuli/fish4.png':
    fish4_pointsA += 1
elif corroutcome_imageA.image == 'stimuli/fish5.png':
    fish5_pointsA += 1
elif corroutcome_imageA.image == 'stimuli/fish6.png':
    fish6_pointsA += 1

I then have a text component in my trial outcome routine below each fish image which, the text of which is “$fish1_pointsA” etc. for the remaining fish.

I have also tried replacing “1” with a variable which corresponds to a column in my conditions file with all rows in that column (besides the header) containing the value “1”.

I’m not sure what else I can try to get this working online, so I would really appreciate some advice

Thanks,
Sofie

What is this? Are you using a variable to set the image for this component. If so, you could use the variable instead.

Thanks for your reply! It has completely solved my issue so thank you so so much, I can’t tell you how much I appreciate this!!

It was actually a very simple fix as you suggested, but I’ll detail it below in case anyone else has a similar problem, especially since it actually worked on PsychoPy (but not Pavlovia) which confused me for a while.

So in the routine I’ve got an image component called “corroutcome_imageA” which is set to be image $Corroutcome according to the conditions file. This is a screenshot of the conditions file:

I replaced ‘corroutcome_imageA.image’ (which referenced the component in my routine), with ‘Corroutcome’ (which referenced my variable in the conditions file) and it now works!

The final code in the “Begin Routine” tab is:

if Corroutcome == 'stimuli/fish1.png':
    fish1_pointsA += 1
elif Corroutcome == 'stimuli/fish2.png':
    fish2_pointsA += 1
elif Corroutcome == 'stimuli/fish3.png':
    fish3_pointsA += 1
elif Corroutcome == 'stimuli/fish4.png':
    fish4_pointsA += 1
elif Corroutcome == 'stimuli/fish5.png':
    fish5_pointsA += 1
elif Corroutcome == 'stimuli/fish6.png':
    fish6_pointsA += 1

Thanks again, and Merry Christmas/ happy new year!
Sofie

1 Like