oTree Forum >

How to keep the same grouping in different apps?

#1 by Phoebe (edited )

This question may be simple, but I just don't know how to do it...since I have already used the group_by_arrival_time in the first app, and the grouping will be messed up in the second app...

Checking other discussions, I have added the following to the first app:

def before_next_page(self):
And second app:

def group_by_arrival_time_methods(self,waiting_players):
But I don't know how to make the grouping in the second app has the same ID as first app?

#2 by ccrabbe

Hi Phoebe -

I would do this by getting the first app's group_matrix at the end with subsession.get_group_matrix() and then setting it at the beginning of the second app with subsession.set_group_matrix():  


The tricky thing for you is that you won't be doing this in creating_session, so you'll need to find a place in your second app's execution at the very start before anybody starts.  You might be able to do this inside your second app's group_by_arrival_time_method, or you might just be able to use a WaitPage with wait_for_all_groups=True and an after_all_players_arrive method.



#3 by Phoebe

Hi Chris,

Thank you so much for your reply!

I have tried your methods, but still I am not sure how to pass the matrix from the first app to the second app? I have tried:

for player in subsession.get_players():
    matrix = subsession.get_group_matrix()
    players = subsession.get_players()
    for p in players:
under subsession class.

And on the second app I tried:

class Subsession(BaseSubsession):
   def group_by_arrival_time_methods(self,waiting_players):
However, it seems not working, although no error messages. Is there a simpler way to fix it, perhaps...?

Thank you so much for your help!


Write a reply

Set forum username