Many people come to this forum because their experiment works fine locally but doesn’t work online. The reason is that the Python code needs to be translated to Javascript and the auto translate that was added to PsychoPy in January 2020 primarily translates the grammar rather than the individual functions.
If you want to run PsychoPy online I highly recommend that you:
Write your experiment in Builder using version 2023.1.3 (or later).
Study my crib sheet to familiarise yourself with the aspects that need manual translation or additional definitions.
Where possible try to write the experiment so it works both locally and online. Some errors are easier to spot locally.
Make suggestions to the crib sheet if you have a fix that can help others.
Older versions:
Best wishes,
Wakefield
Wakefield Morys-Carter MA (he/him) Senior Psychology Demonstrator and Teaching Fellow
Oxford Brookes University Treasurer and Membership Secretary
Association of Technical Staff in Psychology (ATSiP)
I think it is super useful. I wish I had seen it before coding my first online experiment!
I would also add that it is possible to test the online version on your local computer e.g. by means of IIS in Windows. And if you use Visual Studio Code, then there is an extension, which makes the process even easier: IIS Express.
I have tried that but something still seems to be unfortunately messy - it does not count the audio stimuli - please, see the picture below - the right bottom corner in blue:
If I may show you all my code and I ask you to comment on it:
BEGIN EXPERIMENT TAB:
Idx = 0
BEGIN ROUTINE TAB:
msg = “{}/{}”.format(Idx, zacvik.nTotal);
END ROUTINE TAB: Idx+=1
I would be really grateful if you could help me out.
Don’t
Use Python string formatting “my var = %s” % myVar
Do
Use string concatenation with type conversion “my var = “ + str(myVar)
Use str(int(myVar)) if you are getting .0 added to values that should be integers.
JavaScript is usually clever enough to turn numbers into strings without needing to use the equivalents of Python’s str() function (which I think are String() or .toString()). So try just dropping that from the code:
msg = Idx + '/' + zacvik.nTotal;
But as Wakefield notes, using the auto-translate feature from Python -> JavaScript will often go a long way to helping.