CompletedURL / IncompleteURL

Did you forget the ? before subjectID

This works great for me - thanks! I have one question though: can I also use a variable that was generated later in the experiment and not in the dialogue box and if so how would I do that?

If I use a variable called “randomID” like this:

$“https://myUni.qualtrics.com/studyIdentityHere?randomID=” + randomID

or this:

$“https://myUni.qualtrics.com/studyIdentityHere?randomID=” + expInfo[randomID]

it doesn’t work. The url is appended with “undefined”

I can add it to my result file with psychoJS.experiment.addData(‘randomID’, randomID) though, that is working just fine. So accessing the variable during the experiment is not a problem.

1 Like

`“https://myUni.qualtrics.com/studyIdentityHere?randomID=” + $randomID

This is the same way you format a text component.

1 Like

Thanks @doerte for the question! I have a similar issue:

I would like to generate the completedURL depending on the responses in the task. For example, forward all participants with a certain accuracy level to either urlA or urlB. Basically, something like this:

if accuracy >= 0.5:
    my_url = “https://myUni.qualtrics.com/studyIdentityHere?ID=” + "good"
elif accuracy < 0.5:
    my_url = “https://myUni.qualtrics.com/studyIdentityHere?ID=” + "bad"

Then, in the experiment settings, I would set completedURL to $my_url.

Does not work for me though. Like @doerte, I think it’s due to the fact that my_url is only created towards the end of the experiment? Any hints? Thanks!

How about setting my_url to just “good” or “bad” and then using

"https://myUni.qualtrics.com/studyIdentityHere?ID=" + $my_url

?

Yes, I could try that but just realized I was unspecific. In my case I would set two completely different URLs. More like:

if accuracy >= 0.5:
    my_url = “/completely_unique_url_A”
elif accuracy < 0.5:
    my_url = “/totally_different_url_B”

and then set completedURL in the experiment settings to $my_url.

So the URLs are completely different and I can’t just append a variable like an ID.

1 Like

Thanks for your idea. Unfortunately that didn’t work for me, because in the js the variable was still created after the redirect link was set. I just moved the generation of the random code to an earlier point in the .js directly. That fixed the problem for me. This of course wouldn’t work for something as @lnnrtwttkhn is looking for where the URL actually depends on the performance in the task.

1 Like

So did it need to be in a Begin Experiment block?

No, that’s where I had it initially. But this was still “too late” as the redirect link is established very early on in the .js file. I manually edited the .js after doing everything else in Builder first.

Thanks for the clarification – so basically it can only take expInfo variables, not ones created during the experiment.

Yes, the issue is that the call to redirect to this URL is pre-scheduled at the top of the study and, at that point, your variable doesn’t exist.

There is a function in psychojs setRedirectUrls that you could use though in a code component. I think you’d just need to add something like this to your study after you’ve chosen the URL the redirect should point to:

PsychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)

Note that this function doesn’t perform the redirect. It simply determines where to go later, whenever the study ends

4 Likes

Just a minor comment: It should be
psychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)

starting with a small letter. I tried and after I changed this everything works like a charm now, so thank you @jon for this solution!

1 Like

Hi Jon,

Since I do not have access to Qualtrics, I want to redirect the participants to a google form at the end of my Pavlovia experiment. I followed the above method and put this in the completionURL tab of online experiment in PsyhoPy:
$“https://forms.gle/ahzUGUhLjK81Gdif9” + expInfo[‘Participant’]

When I try to run this on Pavlovia, I get this message : Dynamic Link Not Found.
(The URL works fine as long as the + expInfo[‘Participant’] is not added.)

Please tell me if I am doing anything wrong here?

You are missing the ?varname= at the end of the static part of the URL

Hi,

I am sorry to ask this but what exactly is the ‘varname’ here? Is it the field in the google forms that refers to the subject’s identity?

I set the completionURL to this:
$“https://forms.gle/ahzUGUhLjK81Gdif9?subjectID=” + expInfo[‘Participant’],
where subject ID is a field in google form and participant a field in the Pavlovia dialog box. The link works just fine now. But, how do I trace this participant id as a subject’s identity in my google form response sheet?

Off the top of my head, I’m not sure whether Google forms can read URL variables. You’ll need to Google that to check.

So it looks like the google forms cannot read URL variables. In that case, is there any other way to work around the issue of matching identities in pavlovia and google forms?
For example, asking the participants to fill their IDs in forms assigned to them in pavlovia (if that happens) or collecting mail ids on both platforms?

These are just some things on top off my head. Could you please suggest a more streamlined solution?

@Surabhi_Lodha maybe you have already found a solution but you could potentially ask participants to generate a code themselves according to a set of rules, it is usually like 6 elements long like initials of your mother, month of your brother’s birthday, last letter of your name etc. I am sure you would find a template for that online. You could ask participants to generate that code in Pavlovia and save it in that data, and then ask participants to generate it again in your Google forms so that you can link the data

@dvbridges could you please explain in which cases the incomplete URL actually kicks in. I tried to test it by running my experiment and then at the first instruction screen I just pressed Esc but the re-direct doesn’t happen. When I close the tab it just asks whether I want to leave the page which I confirm and the tab closes. Any ideas? Thanks

Press escape twice (the first just exits full screen) or have a core quit statement (appropriately translated)!in a code component

1 Like

Thank you for that. Pressing ‘escape’ twice is something that participants would never do, so I think it is a poor trigger for the incomplete URL to be honest.

For the sake of completeness, I am posting my solution for how to define the URLs here as the solution from your crib sheet did not work for me @wakecarter. I am using a code component to run at the beginning of the experiment. Otherwise, giving several information to the link did not work for me. Hence I created it as a string as a code component and defined the links manually.

myCompletedURL = `https://bangorhumanscience.fra1.qualtrics.com/jfe/form/xyz?Prolific_PID=${expInfo["id"]}&ComboIndex=${expInfo["ComboIndex"]}`;
myCancelledURL = `https://bangorhumanscience.fra1.qualtrics.com/jfe/form/xyz?Prolific_PID=${expInfo["id"]}`;
psychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)

Am I right in thinking that there is no way using PsychoJS to disable the exit from the full screen upon pressing escape?

The only way then to give participants an early out with a re-direct then is to tell them to press a specific key, e.g. ‘q’ to exit which I got working with the snippet below. Am I right in thinking that this would need to be checked every frame in an experiment?

 if (psychoJS.eventManager.getKeys({keyList:['q']}).length > 0) {
    message = "You ended the experiment early. Please press 'OK' to close the session."
    quitPsychoJS(message, false);
}

but doing the same with escape no matter whether escape is enabled or disabled in the builder settings does not work.

What I have figured out just now is to disable the escape key, and check in every frame of a given routine whether we are still in full screen mode or not. If not, then it will assume that the participant is leaving and it will re-direct to the incomplete URL :slight_smile: Happy days!

if (document.fullscreenElement === null) {
    message = "You ended the experiment early. Please press 'OK' to close the session."
    quitPsychoJS(message, false);
}
2 Likes