External dynamic participant IDs and Redirect

161 views
Skip to first unread message

aline....@gmail.com

unread,
May 23, 2022, 11:40:29 AM5/23/22
to oTree help & discussion
Hi,

I have my project running on heroku. The survey provider (CINT) will provide me with participant IDs which I will have to integrate into my app and then again redirect to them at completion. The survey provider will invite participants to the survey and will provde them with a project-specific ID which will be added to my URL, as an example:


Once the participant completes the study he/she should be redirected with the initial ID to the survey provider, with the following link:

Would anyone mind sharing some specific code which I could use in order to achieve this? I have so far only included the OTREE_REST_KEY in my heroku settings, but apart from this I can't figure out how to best set this up (even after reading the code regarding Profilic App). Could anyone provide me with a hint?

Thank you,

Aline

David

unread,
May 24, 2022, 11:24:47 AM5/24/22
to oTree help & discussion
Hi Aline,

As far as I know, participant_label is the only GET parameter that oTree accepts and saves automatically. The URLs that your survey provider sends to the participants should look like this (with 'participant_label' instead of 'participation_id'):


Then the attached ID should be available in the label attribute of the participant object, so you can include it in the completion link on your last page. For example:


I hope this helps a little.

Best,
David

aline....@gmail.com

unread,
May 24, 2022, 4:39:01 PM5/24/22
to oTree help & discussion
Thank you, this is working! I have another question: I would like to implement a similar approach to automatically handle the number of participants per treatment, when a treatment is already full, participants should be redirected. I included the following:

In my settings.py:

SESSION_FIELDS = ['num_participants_finished']

In my init.py

class SorryFull(Page):
@staticmethod
def is_displayed(player):
session = player.session
return session.num_participants_finished > 100

In my template:

<a href="https://gateway.gapfish.com/routings/{{ participant.label }}/finish/quota_full">Bitte klicken Sie auf
folgenden Link.</a>

However, this is not working. Does anyone have an idea as to what could be the issue here?

Thank you!
Aline
Reply all
Reply to author
Forward
0 new messages