oTree Forum >

creating_session does not work at all

#1 by lisa_carismo (edited )

Hey, I am working on my experiment for my master thesis and am almost done. However, whenever I want to use the Subsession class with creating_session to do something like assign treatments or let the player play the game multiple in multiple rounds, the creating session code is ignored!

class Subsession(BaseSubsession):
    print('subsession')
    def creating_session(Subsession):

        print("creating_session")
         for player in Subsession.get_players():
             #i want to assign treatment group for round numbers and control for odd numbers
            if player.participant.id_in_session % 2 == 0:
                 player.treatment = True
             else:
                 player.treatment = False
                 
  I have included print functions to see until where it loads. print('subsession') is executed, but print("creating_session") not any longer. I realize I have to start sessions, but it doesnt do so anyways.
  I have tried using alternative notations (for example: self, subsession:Subsession or something like that), every notation and reference for the creating_session that I found people using in the internet. However, it will absolutely not load or do antyhing stated within the "creating_session" function. I have now used work-arounds, but I fear that it will one day backfire because there is something fishy..
  
  thanks in advance for any help

#2 by gr0ssmann

creating_session must not lie within the Subsession class, but instead be a first-order, free-standing function.

#3 by lisa_carismo

ah. thanks so much! It worked.

Write a reply

Set forum username