oTree Forum >

Randomly assign participiants to one of three different apps

#1 by trevor


I know there have been multiple requests regarding the randomized assignment of participants but none of those really covered my case.

I'm seting up a poll with three different treatment groups (control, treatment 1, treatment 2) with seperat surveys (apps) for each group. I would like to assign participants randomly to one of these apps at the beginning of the poll. How do I realize this? Right now I have three session_configs, each for every treatment. I my mind I would set up a fourth app at the beginning with a welcome page from where I would assign the participants. So I would like to know:

Is this the right way to solve this?
How do I manage the separat session_configs in this case. Do I need just one or even four different session_configs?
Is there a possibility to guide the participants back to a common final page with a completion code (For conducting the survey we will use Prolific).

I appreciate any help.
Have a nice day


#2 by Rok



You can do one session config with all apps in the sequence app_sequence=["assignment", "control", "treatment1", "treatment2", "end"], and in the assignment app (can be welcome app) in the last page, use the linked function to redirect(skip) users to different apps in your sequence:

class MyPage(Page):
    def app_after_this_page(player: Player, upcoming_apps):
        if helpers.is_dropout(player):
            # skip randomly to one of next 3 apps
            return upcoming_apps[random.randint(0, 2)]

Make sure to include random at the top of the file (import random). You also need to skip from the end of the first and second of your random apps, otherwise users playing control will continue normally into treatment1 etc. (same function as above on the last page of your app, just replace the last line - you can return next desired app name instead: return "end")

Hope that helps

#3 by Rok (edited )

Oh sorry, just noticed, remove the if helpers.is_dropout(player): line. :)

#4 by trevor (edited )

Hi Rok,

thanks for your help, it works perfectly :)
Regarding your advice to skip the participants at the end of treat1 and treat2, i constructed an ending page at the end of each app in order to make it impossible to reach following app. Do you say this is also a proper way to deal with it or do i miss anything?

Thanks for your help again.

Write a reply

Set forum username