oTree Forum >

Participant field not transfering as it is to the next app

#1 by m_hr3 (edited )

Hi!

    EDIT: I think I figured out another way, by saving the list of 'selected' participants in sessions and using that to create the roles again the second app.

I have two apps in a row. I determine a separate 'type' through a participant field (participant.type) for each player based on their session ID in the "creating session" of the first app. I have it in participant fields in my settings. I also assign it to a player variable so I can see it in my data.

In the second app, I would like the same 'types' to exist for the same participants. For example participant ID1 is 'SL', participant ID2 is 'IL' etc. throughout the two apps.

However, for some reason when I call "participant.type" the types get randomly re-assigned to each participant. 


Thanks a lot for any help or advice on what I might not notice, I really appreciate it.

Maria




Here's how I create the types in the first app (I need three of type 'IL' in each group):

def creating_session(subsession):
        session = subsession.session
        for player in subsession.get_players():
            group = player.group
            participant = player.participant
            group_ids = list(range(1, Constants.players_per_group+1))
            session.players_per_group = Constants.players_per_group
            players = list(group.get_players())
            print(players)
            demonstrators = list(random.sample(group_ids, 3))
            print(demonstrators)
            for player in players:
                if player.id_in_group in demonstrators:
                    participant.type = 'IL'
                    player.type = participant.type
                else:
                    participant.type = 'SL'
                    player.type = participant.type


In the second app:

def creating_session(subsession):
    session = subsession.session
    for player in subsession.get_players():
        participant = player.participant
        player.type = participant.type

Write a reply

Set forum username