Variables passed in completion URL not being detected in second experiment

URL of experiment: FlankerAttA_1 [PsychoPy]

Description of the problem:I am calibrating the stimulus size using wakecarter’s screen scale code.
I want to then pass the x_scale and y_scale values to a second experiment using the completion URL along with the participant code.

Knowing that the completion URL is generated at the begining of the code before any variables generated during the running of the experiment would exist as described here: CompletedURL / IncompleteURL - #18 by lnnrtwttkhn
I am using the recomended command in a code component after the x_scale and y_scale variables have been populated.

psychoJS.setRedirectUrls("https://run.pavlovia.org/Anthony_Risuq/trailmakingcs-5/html?participant=+expInfo['participant']&x_scale=$x_scale&y_scale=$y_scale", "https://www.google.com" );

I get no errors when generating the javascript and I am redirected to the next experiment at the end of the first, however when it comes time for the second experiment to use the x_scale and y_scale variables I get an error message stating that it was unable to convert the variable to numerical value since it was a NaN.

If I paste the completion url directly into a browser without specifying the values of x_scale and y_scale I get the same error message at the same point. However if I directly specify the values in the url when pasting it into a browser, and without using the $ before the value then the experiment runs properly.

I tried removing the $ in the completion url but I get the same error message as originally.

All this leads me to believe that the values are not being properly sent to the second experiment.

What can I do to fix this?

Thank you.

Try

"https://run.pavlovia.org/Anthony_Risuq/trailmakingcs-5/html?participant="+expInfo['participant']+"&x_scale="+x_scale+"&y_scale="+y_scale

Hello,

That did the trick. Thank your very much.

I’m having a similar problem, so thought I’d keep it in this thread.
My Completed URL has this:

$“https://northwestern.az1.qualtrics.com/jfe/form/SV_aVKQvJK7FcOsE8C?PROLIFIC_PID=“+expInfo[‘PROLIFIC_PID’]+”&Conds=“+Conds+”&Pav=Complete

It is passing along expInfo['PROLIFIC_PID'] just fine, but the Conds variable is not being added and shows us up as “undefined” in the output URL. What is confusing is that the Conds variable is being added fine to the Pavlovia output file with this thisExp.addData('Conds',Conds), which is in a code component, Begin Routine tab, within a loop.

Any idea of what might be happening? All I want to do is add a variable I define in my study to my URL.

Thanks!

The completion URL is set at startup (after the expInfo dialogue box has been submitted).

If you want to add variables during the experiment the you need to set something in Experiment Settings and then redirect in a code component. I can’t remember the actual code off the top of my head but it’s something like PsychoJS.redirectURLs(mycompletedurl,mycancelledurl)

1 Like

Perfect, thank you! Do you know if I can modify the expInfo variables during the experiment, or are those “fixed”? For example, could I re-write expInfo['Condition'] after it’s set at startup?

You’ll need to use psychoJS.setRedirectUrls(myCompletedURL, myCancelledURL) to change the location once the experiment starts.

Thanks again!