ReferenceError: doingResponse_4 is not defined

URL of experiment: https://pavlovia.org/run/UODPsychology/tomdexperiment-v1-1/html/

Description of the problem:
Hi,
I’m a bit of a coding novice and a relative newbie to PsychoPy! Just wondered if anyone could help with this. One of my students has written a Corsi Block Tapping Test in Psychopy and has asked me to host it on Pavlovia. The script works fine on my computer but as soon as I host it online and access it from the URL I get the above error.
Can anybody explain in layman’s terms how I would go about fixing this please? Any advice would be most welcome!
Cheers
Rich

Hi There,

This means that when the experiment is run online it can’t find the variable ‘doingResponse_4’

Could you tell us a bit more about what this component is in your experiment? (e.g. is it a key press or a variable? also if you are able to share the URL to the project with us that can help us see what you are seeing :slight_smile: from your experiment page click > View code> settings (cog on left panel) > permissions > set to public > share that URL with us

Thanks,
Becca

Thanks so much Becca! As far as I can see it refers to a mouse click, and it’s in Practice_Trial… I checked out the Code Component for it and changed the Code Type from ‘Both’ to ‘Auto->JS’ and that has got rid of that error. However I get another one about * ReferenceError: nextSwitch_4 is not defined now. Anyway, I’ve followed your advice and made the URL publicly accessible, I told you I was a noob haha!
Many thanks and best wishes
Rich

I’ve got a feeling it’s something to do with this, does anyone know if there is a way to force the values across?

This shows you that there is an error in python script. Therefore, your python script cannot be auto-translated to JS.

Try to delete one line after the other to identify the line that causes the syntax error. Any specific reason why you import the libraries scipy and numpy? If you plan to run the experiment online, you do not need to import these (see here).

CU Jens

Thanks very much for the reply Jens, I’ve removed the import Scipy and Numpy as you suggested, and i’ve also followed your advice regarded deleting each line until the syntax error disappeared. That’s narrowed it down to this section:

for label, block in blocks_4.items():
block.pos = random(2)*0.8-0.4
blockCoords_4.append(block.pos)
dist_4 = scipy.spatial.distance.pdist(blockCoords_4)
block.color = ‘white’

Any advice from here at all? Coding definitely isn’t my strong suit so any help you can give would be very much appreciated! Thanks for your time :slight_smile:
Rich

@RichClarke

if you add three `, then your code will be properly formated. Perhaps it is just an intendation error which one can not tell at the moment.

A python for loop usually looks like

fruits = ["apple", "banana", "cherry"]
for x in fruits:
  print(x) 

You have

for label, block in blocks_4.items():

which is incorrect.

CU Jens

Thanks for the extra advice Jens, sorry if this is a dumb question but what would I enter instead. I can see that blocks_4 refers to this in the script:

blocks_4 = {}
blocks_4[‘blk1_4’]=blk1_4
blocks_4[‘blk2_4’]=blk2_4
blocks_4[‘blk3_4’]=blk3_4
blocks_4[‘blk4_4’]=blk4_4
blocks_4[‘blk5_4’]=blk5_4
blocks_4[‘blk6_4’]=blk6_4
blocks_4[‘blk7_4’]=blk7_4
blocks_4[‘blk8_4’]=blk8_4
blocks_4[‘blk9_4’]=blk9_4

So would i do something like: blocks_4 = [“blk1_4”, “blk2_4” etc etc]

Rich

@RichClarke

Hello Rich,

yes, this is the way to define a list in python.

CU Jens