psychopy.org | Reference | Downloads | Github

Integrating two experiments on Pavlovia

Hi everyone,

I have two experiments that I’ve created in PsychoPy and both are up and running on Pavlovia in separate repositories. Let’s call them main_exp.js and side_exp.js. I want to incorporate my side_exp into my main_exp such that the participant runs the side_exp first and the main_exp second. Therefore, I want to put both experiments into one repository and integrate them somehow so that running the main_exp.js will call the side_exp.js as well, at the beginning of the script.

I have some knowledge of JS and my first idea was to import all the methods and variables from side_exp.js into main_exp.js and add the methods to the main_exp experiment queue. However, this seems tedious and it will take a while to export + import all methods and variables from side_exp.js (there’s a lot).

Is there an easier way to call the side_exp.js file and run it from the main_exp.js file? Any help is greatly appreciated.

Thanks

You can use the completed URL of the side experiment to call the main experiment, passing the participant ID. This will mean two data files and cost two credits, unless you have a licence. There are alternatives if you don’t want to collect full data from the side experiment.

Best wishes,

Wakefield

Thanks for the response. Is there a way to do this when they are both in the same repository and their data is in the same results file?

How do you select which one to run? If you can address one via a URL then they could be chained. Alternatively, you could make a copy of index.html which points at the second one.

Would you mind explaining both of these options in more detail? What do you mean by using the completed URL of the side experiment to call the main experiment? For the alternative option, do you mean that I should create a second index.html file with a different name? Will it execute both html files by default or should I specify this somehow? Sorry, I don’t know anything about html.

Thank you for your help!

If you visit a URL with a folder but no file specified the browser looks for an index file called index.html, index.php, home.htm, etc.

In Pavlovia you will see that your html folder contains index.html which references your two js files. If you have more than two js files in that folder you should be able to reference the second pair in a slightly edited and renamed version of index.html

In PsychoPy in settings online you can specify a completed URL. Look at my crib sheet for how to add the participant expInfo to a URL

Thanks for your help!