How to prevent the same participant from quitting and then restarting a task in pavlovia

Hello,

I have a couple of studies in Pavlovia, and I’ve noticed that participants will go through SONA, then complete the consent form in qualtrics, start the study in pavlovia, and then quit the study, and then come back and do it again later. I have been having to drop these participants from my study since they have already seen the stimuli and some of the answers from feedback. Is there a way to prevent this from happening?

Thanks,
Brooke

Hello again,

yes this is possible as long as the participants have a unique ID coming from SONA/Qualtrics, which I assume they do, otherwise, you wouldn’t have noticed :smiley:

What you basically need to do is write participants’ IDs to a permanent record, check if they are already on the record and if so, quit the experiment. This can be done using pavlovias #shelf feature, which allows you to create and manipulate such a record.

So, if you want to do this:

  1. Go to your dashboard → shelf, add a new record called “participants” (if you do this for multiple studies, you need to give the records unique names and adapt the code below for each of them accordingly) as a list, and set the scope to the belonging experiment.
  2. Copy the following code to some “Begin experiment” code tab.
participants = await psychoJS.shelf.getListValue({key: ["participants"]})

if(participants.includes(expInfo["id"])){
    psychoJS.quit({
    message: "You already started this experiment before and can not start it again.",
    isCompleted: false
    })
    }else{
    await psychoJS.shelf.appendListValue({key: ["participants"], elements: expInfo["id"]})
    }

This code assumes that your ID variable is id and part of expInfo (i.e., the start-up dialog). It aborts the experiment if the id of the participant is already on the record. The message is, of course, arbitrary.

If you want this method to be aware of participants that already started the experiment before you implement this code you have to “manually” give the record a list of all previous IDs in this format ["1", "2", "3"].

2 Likes

Thanks so much! Does this look correct? Putting participants in the key components section, selecting my experiment, and then setting type to list?

Yes :+1:

So in qualtrics, at the end of the survey termination link I have ?participant=${e://Field/id} at the end of my link, I believe this is transferring my variable ID back to participant.
Would I then have:

if(participants.includes(expInfo["participant"])){
   psychoJS.quit({
   message: "You already started this experiment before and can not start it again.",
   isCompleted: false
   })
   }else{
   await psychoJS.shelf.appendListValue({key: ["participants"], elements: expInfo["participant"]})
   }```