#1 by Christoph
Hi everybody,
I am currently working on a project in otree 3.4.0 (unfortunately, I am required to stick to that version). I often use itertools.cycle to iterate over treatments and assign treatments.
I iterate over the different treatment options when creating a session (which seems to work just fine):
def creating_session(self):
if self.round_number == 1:
self.session.vars['treatment_iterator'] = itertools.cycle(treatment_options)
And then assign treatments to each group on a WaitPage via next():
def after_all_players_arrive(self):
try:
# Check if there have been any drop-outs whose treatments should be reassigned
treatment = self.session.vars['dropout_treatments'].pop()
except IndexError: # If there is an IndexError, dropout_treatments is empty -> take next treatment from list
treatment = next(self.session.vars['treatment_iterator'])
However, treatment here always takes the same value, i.e. all groups end up being assigned to the same treatment. I used the same setup (although for individual choice experiments) before and never had any problems, but that was in otree 5. Is there a potential reason why this might not work in otree 3?
Thanks for any suggestions