OS (MacOS Monterey):
PsychoPy version (version 2022 2.5):
Standard Standalone? (YES)
What are you trying to achieve?:
Just terminate an online PsychoPy experiment to a URL. My test program has a text screen displayed for 3 seconds, and then launches a webbrowser to http://www.formula1.com. This is just a test as there are a couple of students that are having difficulty terminating their psychopy online experiment to another pavlovia survey when the experiment is complete.
What did you try to make it work?:
See test screen shots attached. Made brief psychopy experiment, uploaded to pavlovia, run in pavlovia I get a 404 error now (was getting a 403 error until I updated PsychoPy to 2022 2.5). It runs offline no problem (displays text for 3 seconds and then opens F1 in chrome).
Any help would be greatly appreciated.
Colin
Don’t try to do this in End Experiment. The easiest option would be to add a final routine and put the code in Begin Routine there – probably needing to “Click Leave to Continue”.
The alternative is to redirect the completion URL (which is usually better if this involves ending the experiment)
Hi Wakefield, thanks for coming back to me so quickly. Is there any chance you could do that test yourself when you get a minute please, just to rule out a bug. I’ve tried this (many times) and it will run offlline, but not online and Andrew has tried it here too and is getting the same result. We’re both on Macs, so I thinking this could be a reason? thanks, colin
Hi Colin,
I’m on my phone since I often have other priorities when on my laptop.
I know that End Experiment code can conflict with the smooth exit of a PsychoPy experiment, so I would strongly recommend that you try a different approach and then ask for help with that.
You may need to use an incognito tab to view the latest version.
Is there a reason why you aren’t just using the Completed URL in Experiment Settings? If it needs to be dynamic then you could use CompletedURL / IncompleteURL - #23 by jon
thanks again for coming back to me Wakefiled, I really appreciate it! The reason I’m not using Completed URL in experiment settings is because I couldn’t get that to work originally (see screenshot)…I’ll have another go at it tomorrow. Thanks again, Colin
That should work fine. Check for any conflicting End Experiment code.
That’s my point Wakefield, it doesn’t I’m afraid.
Does $"https://www.formula1.com/"
work as the Completed URL?
I’ve just tested this in something else I was looking at and it works in 2023.1.0 (and when running as 2022.2.5)
https://run.pavlovia.org/Wake/clock
Press space to end the clock
Thanks Wakefield, your link is working great! Unfortunately I can’t get this to work - obviously I’m doing something wrong. I’ve been at this hours, Could you share a solution project please? I’m thinking it’s a Mac thing, but more than likely a Colin thing! I’ll try again tomorrow on a Windows. Cheers.
Hi Colin,
Please could you add me to the repository and I’ll take a look. There’s no point sharing my solution, because I didn’t do anything special.
Cheers,
Wakefield
Hi Wakefiled,
Thanks for taking a look. I’d removed the tests yesterday but made two more this morning and added you to them in the repository. One is F1a, and this use the URL in PsychoPy Online, and the the second one it a routine with code at begin routine. Both not launching, so any help would be greatly appreciated! Cheers, Colin
I just looked at f1a and it didn’t have any JS files so I clicked Sync to create them. Please could you unprotect the master branch so I can push the changes (Settings / Repository / Protected Branches in Gitlab)
I’ve unprotected both there Wakefield, thanks.
f1a is now working. f1b needs to be set to piloting by you to test. I didn’t make any changes to f1a and added the code routine to the flow for f1b.
Hi Wakefield. I’ve set F1b to piloting and it’s stuck in “initializing…”.
F1a is indeed now working. I can’t understand why it works now without any intervention. I need to figure this out as I have students stuck in the same situation. Did you say there was no js files and you needed to sync them? Is there a step we’re missing? When I click the Sync button in PsychoPy I’ve been getting the following error…
Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/builder.py”, line 1369, in onPavloviaSync
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/builder.py”, line 804, in fileExport
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/scripts/psyexpCompile.py”, line 71, in generateScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/scripts/psyexpCompile.py”, line 245, in compileScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/scripts/psyexpCompile.py”, line 217, in _makeTarget
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/experiment/_experiment.py”, line 286, in writeScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/experiment/components/settings/init.py”, line 857, in writeInitCodeJS
IsADirectoryError: [Errno 21] Is a directory: ‘/Users/colinburke/Desktop/Test-url-settings/index.html’
Why I’m testing a URL launch from PsychoPy is we have students that have an experiment already made in PsychoPy that is running on Pavlovia. They have a Pavlovia survey that needs to run after the Experiment on Pavlovia. Therefore in theory, all they need to do is to put the URL for their Pavlovia Survey into the COG->Online->Competed URL box and it should work. So we have downloaded the Folder from Github that contains the original experiment, opened the psyexp, edited one of the images in the folder, put in the Completed URL link, save, uploaded as a new project and it runs fine (we can see the edited image)…except it will not go to the URL at the end so the particpants can complete the questionnaire. So as a quick test I made the F1 experiments in the COG and code to see why, and this is where I’m stuck.
Cheers for all your help, I really appreciate it!
Sync it again now.
It was stuck on initialising because you had import webbrowser in an Auto code component. I’ve put it in a Python only component.
I’ve also tried putting the URL code into End Routine of a single routine. I’m not sure what would happen in a real experiment, but the key is that it opens in the same window. You could try opening in _blank instead.
Have you seen my troubleshooting guide?
https://psychopy.org/online/psychoJSCodingDebugging.html
Best wishes,
Wakefield