from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): btn_item_1 = models.IntegerField(label="Your answer:") btn_item_2 = models.IntegerField(label="Your answer:") btn_item_3 = models.IntegerField(label="Your answer:") btn_item_4 = models.IntegerField(label="Your answer:") schwartz_item_1 = models.IntegerField(label="Your answer:") schwartz_item_2 = models.IntegerField(label="Your answer:") schwartz_item_3 = models.IntegerField(label="Your answer:") ### detrmine overall bonus and save to participant variable ### cannot do that in results as people could change the bonus ## by refreshing the pages as I have to call the function in pages.py def get_Bonus(self): self.participant.vars['final_bonus'] = random.choice(self.participant.vars['final_bonus_list']) print('The randomly drawn bonus from all rounds for this participant is', self.participant.vars['final_bonus'])