Copy and paste text from Experimental Display? - How to allow subjects to obtain unique IDs for payment

Simple Question:
When using an online platform (be it prolific of mTurk), payment for participants is usually handled by displaying a unique identifier at the end of the study, which the subject can copy and then paste and submit at the recruiting platform’s site.

However, it does not seem to be possible to copy or select on-screen text when running off Pavlovia.

so how do people solve this problem?

I usually customize the pop-up message that appears when the data has been saved on the server at the end of the experiment. You could come up with a random, low-frequency word, put it in the exit message and ask them to copy and paste it back in the MTurk page.

function quitPsychoJS(message, isCompleted) {
  psychoJS.quit({message: 'The experiment is now complete. Thank you for your participation! Please copy-and-paste the following password into Mechanical Turk so that we can confirm your participation: XXXX.\nOnce you do that, you can close this page.', isCompleted: isCompleted});

  return Scheduler.Event.QUIT;
1 Like

You shouldn’t need to make the participant do any copy/pasting. It can all be handled by URL query strings. In the url TO pavlovia from the recruiter you can insert the participant ID into the url. And you can set PsychoPy to use a completion url at the end of the study that (optionally) sends the same number back to the recruiter.

Have a look at the instructions here and let me know if anything isn’t clear:

1 Like

Hello @rob-linguistics13. Thanks for this. Sorry to be a bit dim here.
How exactly does this work? I copied your code into an ‘end of experiment’ tab of one of my code components and then simply added quitPsychoJS(); after this, but that does not seem to do anything

Hi @Marc_Buehner, sorry the delayed response. Since the string of code I have posted is automatically generated once you commit changes from the Builder, you can’t modify in the Builder itself. The only way to do that is to modify the js file directly on github (which the developers rightfully discourage so as to prevent problems on your experiment).

1 Like

Hi @rob-linguistics13. One more question: How can I set line breaks in the pop-up window text?
I have the following, which does not break up.



psychoJS.quit({message: ‘The experiment is now complete.\n\n\Thank you for your participation!\n
Please copy-and-paste the following password into Mechanical Turk so that we can confirm your participation:\n
Once you do that, you can close this page. \n\n{0}’.format(uniqueID), isCompleted: isCompleted});

Yeah, I have been trying to do that too, but I couldn’t figure out a solution just yet. The \n command is useless, so you may want to remove it to prevent subjects from being confused about its meaning.

you guys figured out a solution?

I need subjects to copy code from the end of the exp and paste to mturk

Hi @Xinzhu-Fang,

As far as I can tell this thread features a whole bunch of solutions, though the copy-paste approach is recommended against. Could you tell us what you’re missing?

Best, Thomas

my solution now is to generate code (subject id) on mturk and create pavlovia link including with subject id prefilled

1 Like