Manually generate .psyexp file when py already exist?

URL of experiment: https://pavlovia.org/run/supermario000/3-8-1/html/

Description of the problem:

I have written my project in coder and didn’t use viewer at all. The python file name is “crapy two screen.py”. I am able to run it in local coder view without any problem. Then I open the builder view and generate a project file called pocker.psyexp. As I think this project file only contains default content.

After that I syn my project from builder to pavlovia. The online experiment is able to display. However it looks like it is an empty project. Because it only ask for participant and then display “Saving the experiment results and closing the session. Please wait for a few moments”. And it finished.

If I want to run the project online as same as the local coder view. Should I manually write a project .psyexp file in order to match my .py file.

Please kindly give me some advice.

Thanks

HI @Edward250250, in short yes. Behind the scenes, PsychoPy’s Builder takes the components that you have used to construct your experiment visually, and outputs Python code that is used to run your study locally on your computer. To run a study online, PsychoPy can now output the JavaScript equivalent, so you can run your experiment in a web browser. PsychoPy is not able to take your Python script and run it from a web browser, it would require a translation into JavaScript that is not currently possible in PsychoPy. If you need the flexibility of coding in your experiment, you can add code components to insert code snippets at different stages of the experiment. For those code snippets to work online, will require you to translate the Python code into JavaScript. This is made easier by the new functionality of the code component, where you can select code types, and have both Python and JavaScript code windows open side by side to facilitate the code translation.

Thank you very much for your clarification. Now my next step is to translate my python code to javascript code. Can you please kindly provide a little more information of new functionality of the code component. Do you have some Python translate to Javascript examples?

One more question regarding to the file format. So the pavlovia will finally take my translated .js file and running as online study, right? The final fine name is not .py, right?

I’d really really recommend you learn to use Builder and let Builder create both files. Learning to translate python into JavaScript with only a vague idea of how things work is a recipe for disaster.

1 Like

Indeed, and as I mentioned above, using Builder with code components gives the greatest flexibility for generating your online experiments. We have set up some examples on Pavlovia, for example the Balloon Analog Risk Task. This task is built using the Builder interface, but has some code components using Python code, also with their JavaScript translations:

the code repo

the experiment in action
https://pavlovia.org/run/demos/bart/html/

For another example that uses feedback, see the Attention Network Task:

code repo

the experiment in action
https://pavlovia.org/run/demos/the-attention-network-task/html/

Thank you very much for your replay. I will try to create my project with builder and then generate both files and run it in pavlovia. Thanks a lot!

Thanks a lot for your demo examples!