oTree Forum >

Multiple app and random allocation to groups

#1 by Anwesha

Hi there,

Hope you are well. I have three quick questions. It's not exactly about codes. I am just trying to understand if I understand otree correctly, being very new to it.

1. My first question is about random allocation to groyos. I have used this code:
class Subsession(BaseSubsession):
    def creating_session(subsession):
        subsession.group_randomly()
        
I am getting a message in PyCharm that says that "Usually first parameter of a method is named 'self'". I am not sure what this means. Does that mean my code is incorrect?

2. My second question is about distinction between players and participants. I have two apps - one with the real experiment and the other on survey. I have read that players in apps change their positions. So, when I get the final data in excel format, does that mean that data on decisions of player 1 will not correspond to player 1's survey data? In my codes, I have always used player and not participant, hence my question.

3. My third question is a bit silly perhaps but when I was testing my experiment with 70 participants, the group numbers were coming to be 93, 71. I am a bit surprised as to why the group numbers are greather than number of participants.

#2 by Fanist

Hi Anwesha, here are some answers from my knowledge:

1. I guess there are some issues for your code, maybe you should check at https://otree.readthedocs.io/en/latest/treatments.html?highlight=random%20app#balanced-treatment-groups

But for the message for PyCharm, I guess it is just because Pycharm do not recognize code from oTree but from Django, which makes PyCharm give some incorrect suggestions.

2. No, you can get the data you want. When you open the exp through "otree devserver", you can preview data structure in the app, and you can check the data in every round there. 

3. No idea

#3 by Anwesha (edited )

Hi Fanist, 

Thanks you so much. Quick follow up queestion. So basically what I have done is this:
class Subsession(BaseSubsession):
    def creating_session(subsession):
        import itertools
        pressures = itertools.cycle([True, False])
        for player in subsession.get_players():
            player.time_pressure = next(pressures)
        subsession.group_randomly()
        
Is this the correct approach?

Write a reply

Set forum username