Psychopy experiment doesn't redirect to URL

URL of experiment: behaviouralCQ [PsychoPy]

Description of the problem: Pavlovia doesn’t redirect to the URL at the end of the experiment, it just stays on the grey screen. It’s a finger press task, where participants have to learn 2 sequences. I have a code component that tells the experiment which link it should redirect to depending on the day (it’s a 3-day experiment), which looks like this:

if p n is odd, use seqSet 1 if even, use 2

seqSet = ‘’
if int(expInfo[‘participant’]) == 0:
expInfo[‘seqSet’] = ‘s0Practice’
elif int(expInfo[‘participant’]) % 2 == 0:
expInfo[‘seqSet’] = ‘s02’
else:
expInfo[‘seqSet’] = ‘s01’

completedURL = ‘’
if int(expInfo[‘participant’]) == 0:
completedURL = ‘’
elif (expInfo[‘day’]) == ‘day1’:
completedURL = ‘https://bhampsychology.eu.qualtrics.com/jfe/form/SV_bf2uvsFxoPdexBY?id='+expInfo['participant’]
elif (expInfo[‘day’]) == ‘day2’:
completedURL = ‘https://bhampsychology.eu.qualtrics.com/jfe/form/SV_55sL7k2Md4fgFGS?id='+expInfo['participant’]
elif (expInfo[‘day’]) == ‘day3’:
completedURL = ‘https://bhampsychology.eu.qualtrics.com/jfe/form/SV_cTpjTdx8o2OEyp0?id='+expInfo['participant’]

In the JS code part I have this:
seqSet = “”;
if ((Number.parseInt(expInfo[“participant”]) === 0)) {
expInfo[“seqSet”] = “s0Practice”;
} else {
if (((Number.parseInt(expInfo[“participant”]) % 2) === 0)) {
expInfo[“seqSet”] = “s02”;
} else {
expInfo[“seqSet”] = “s01”;
}
}
completedURL = “”;
if ((Number.parseInt(expInfo[“participant”]) === 0)) {
completedURL = “”;
} else {
if ((expInfo[“day”] === “day1”)) {
completedURL = (“https://bhampsychology.eu.qualtrics.com/jfe/form/SV_bf2uvsFxoPdexBY?id=” + expInfo[“participant”]);
} else {
if ((expInfo[“day”] === “day2”)) {
completedURL = (“https://bhampsychology.eu.qualtrics.com/jfe/form/SV_55sL7k2Md4fgFGS?id=” + expInfo[“participant”]);
} else {
if ((expInfo[“day”] === “day3”)) {
completedURL = (“https://bhampsychology.eu.qualtrics.com/jfe/form/SV_cTpjTdx8o2OEyp0?id=” + expInfo[“participant”]);
}
}
}
}
psychoJS.setRedirectUrls(completedURL)

In the completed URL section I have this:

My colleague has a very similar experiment and I used the same code etc for the redirect except that his works perfectly and mine doesn’t. I have tried deleting the experiment off pavlovia and creating a new one. I have made my experiment inactive on pavlovia and then synced it and I have changed the version of psychopy but that didn’t worked.

If anyone has any suggestions or can see something I have done that could be the problem I’d greatly appreciate it, thank you!

Usually, this function takes two arguments: psychoJS.setRedirectUrls(completedURL,''), but I don’t know if that makes a difference.

Did you check whether the URL is properly built in your if-statements by doing console.log(completedURL) after you defined it?

In this field you need to put a web address, not a $. Your redirect may be failing because of an error setting up the initial web address. You can’t use the code to redirect until you have an initial redirect in place.

Thank you for the reply! I tried putting two arguments in the function but it didn’t make a difference and I added the console.log(completedURL) later on in the experiment but it didn’t show up in the output when I synced the experiment to pavlovia. How can I check that it is properly built-in?

Thanks for your reply! I left the completedURL section blank and then synced it but it didn’t redirect. Before I just put in ‘http://www.google.com’ in the completedURL but it didn’t redirect either.

Running your experiment I can see that the script has the “console log” line. So if you don’t see anything in the console, the reason maybe that completedURL is still "" and you just miss this output in the console. So maybe change it to console.log("URL", completedURL) just to make sure you find it in the console, regardless of the value of completedURL.

Thanks for your suggestions! I just found the problem, ages ago I added a code component at the end of the experiment psychoJS.setRedirectUrls(redirect) so that must have been interferring with it.

1 Like