#1
by
cerenay
(edited )
Hi,
I am trying to do simplest balanced treatment assignment based on two conditions and the variables return to None in all my tries. I use the same code that I used thousands of times before but I am thinkig maybe I am a bit rusty so not sure what is happening, really appreciate the help!
class Subsession(BaseSubsession):
def creating_session(subsession):
scenario_cycle = itertools.cycle(["S1", "S2", "S3", "S4", "S5", "S6"])
treatment_cycle = itertools.cycle(["T1", "T2", "T3"])
for player in subsession.get_players():
player.assigned_scenario = next(scenario_cycle)
player.assigned_treatment = next(treatment_cycle)
class Player(BasePlayer):
assigned_scenario = models.StringField()
assigned_info_treatment = models.StringField()
#2
by
BonnEconLab
It works if you move `def creating_session(subsession)` to the top level, that is, outside `class Subsession(BaseSubsession)`. (BTW, you use `assigned_treatment` in `creating_session` but `assigned_info_treatment` in `Player`.)