psychopy.org | Reference | Downloads | Github

Online experiment stuck on initialising

URL of experiment: https://run.pavlovia.org/Klara/baserate/html/

using PsychoPy 3.1.5
Win 10

Hi all,

I have tried to run my experiment online and it is stuck on ‘‘initialising the experiment’’ (experiment runs normally while offline). I have checked for possible file naming issues, and there are none strange symbols, spaces, etc. Google Chrome console shows this error: ‘‘Uncaught SyntaxError: missing ) after argument list’’. So I have checked experiment’s code in Coder view in PsychoPy (shortcut - Compile to script), copied it to Python Buddy and it showed error in this line (845):

update component parameters for each repeat

text_8.setText(f'Osoba {osoba} je {stereotip}.'

)
key_resp_4 = keyboard.Keyboard()
text_15.setPos((0, 0.1))

So, I guess the ‘)’ should be put in the previous line. When I corrected this, I tried to save the file and run it online again, but the same error occurs. Then I opened the experiment again, but this line is still like this as if I haven’t corrected it.

I am not sure how to fix this issue, can anyone suggest on how to fix my code?

Kind regards,
Klara

Hi @Klara_Rapan, this is an issue with how you are formatting your string in your text component. You are currently using the new Python 3 style string formatting, which will not work in JavaScript. An alternative method that is compatible across languages is :

"Osoba" + osoba + "je" + stereotip

Thank you for your answer.
I’ve tried to change it the way you suggested, but it still shows the same error.

I clicked ‘‘Compile to srcipt’’ in Builder, than changed the line, then clicked Save and Run online. Am I doing something wrong?

Hi, looks like the changes were not uploaded to the repository. You may have an error somewhere. Where are you adding the changes given above?

I was adding changes to PsychoPy coder. But when I save them, it seems lile nothing changes.

Ah ok, do you mean the actual Coder window, or in a code component? If you are using Coder to change the Python code, this will not be reflected in your JS code, because the JS is only output from Builder.

Oh ok, sorry I don’t know much about programming. Can you suggest on how to effectively change the code? :slight_smile:
I was using Coder.

Hi @Klara_Rapan, you will want to make the change using Builder. If you have a text component presenting the text, add that code to the text box, and set the text box to update on every repeat.

Btw, you may want to move your experiment files to their own folder. It looks like you are running the experiment from a shared folder, such as your desktop. This may cause your syncing etc to be slow, since there are so many files to check for changes and upload. If you do move the files, make sure you also move the .git folder, which is hidden on Windows. To view, set your folder options to allow hidden folders to be viewed.

Let me know if you have any problems.

Hello, thanks for ypur advices.
I have tried to change one of my text components the way you suggested, but this way it does not use the variables I have made in Excel file. For example, to try it I made new routine and in text component I have put something like this:
f$’ “osoba” ’ (set on every repeat)
but when I try to run the experiment offline it just shows: “osoba”. Am I typing something wrong?

Yes, it is because you have created a string, rather than using the variable name:

$"osaba" # Creates string
$osaba # Uses variable

Hello, it’s me again. Unfortunately, this is not working. I have tried to put it this way:

“Osoba”+" “+$osoba+” “+“je”+” "+ $stereotip + “.”

this text component works, but I have 3 such text components, and when I use this one:

‘U uzorku je ‘+$omjer1+’ ‘+$profesija1+’ i ‘+$omjer2+’ ‘+$profesija2+’.’

it shows this error: ‘‘must be str, not numpy.int64’’

I have also tried to put it without ‘$’ but then it just shows the word, not the Excel variable.
Can you tell me what is wrong?

Sorry for bothering

Ok, in the text component, try:

$"Osoba" + str(osoba) + "je" + str(stereotip)

The dollar sign at the beginning indicates to PsychoPy that this entry should be treated as code, so that is why we put it at the very beginning. To get rid of the error caused by adding an int to a string, we convert the int to a string before we concatenate the string. Give that a go, and let me know.

Hi @dvbridges,
I have made all the changes in my text components as you suggested. The experiment is no longer stuck on initialising, but an error occurs right before the text stimuli should appear: ReferenceError: str is not defined

I guess the code is still not compatible to JS?

Here is the link to the experiment: https://run.pavlovia.org/Klara/baserate/html/

Thanks for your help,
Klara

Ah yes, as you had a Python error I solved that, but created another with JS! Methods like str are Python string conversion methods that will not be compatible with JS. You do not need to convert numbers to strings with JS, it will do it for you. So, you could just use the original suggestion if you only want this working online.

$"Osoba" + osoba + "je" + stereotip

Everything works now. Thanks a lot!

Hi, I think I have a similar issue here… Could you help me with my code?

URL:https://run.pavlovia.org/kevinlin1997/d3/html/

Thank you!!

Hi @Kevin_Lin, your current task appears to have an issue with closing brackets, somewhere in your code component, you may need to add some closing curly brackets } to one of your statements.

Thank you so much!! It works out perfectly~!