oTree Forum >

Better to define a dictionary in a class or in a session.vars ?

#1 by utilisaction (edited )

Hey everybody, 

I implement an experiment with mutliple rounds and want to test it with bots. 
When I have 20 bots and 4 players per groups, I get 5 different groups. 
I noticed that there were some errors when defining a session variable as follows : 
`dict = self.group.session.vars[f'dictionnaire_{self.group.round_number -1}']`
It was better to do : 
`dict= self.group.session.vars[f'dictionnaire_{self.group.round_number -1}_group_{self.group.id_in_subsession}']`
so that the idyosyncratic variables for each group are different.

But in fact, I am afraid to have the same problem when implementing different subsession simultaneaously and to then be obliged to note my vars : 
`dict= self.group.session.vars[f'dictionnaire_{self.group.round_number -1}_group_{self.group.id_in_subsession}_ subsession_{subsession.id_in_session}']`

I would really like to store my dictionary in group... but am then bound to do a self.group.dictionary = json.dumps(dict)
in order to store it in 
class Group(BaseGroup) : 
   dict_prix = models.StringField(default = json.dumps({}))
   
What solution would be the cleanest ? 

Thanks for help!!!

Marguerite

Write a reply

Set forum username