from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Grouping(WaitPage): group_by_arrival_time = True class Instructions(Page): pass class Description(Page): form_model = 'player' form_fields = ['age', 'gender', 'education', 'bodymass'] def is_displayed(self): return self.player.id_in_group != 3 def before_next_page(self): if self.player.id_in_group < 3: self.participant.vars['age'] = self.player.age self.participant.vars['gender'] = self.player.gender self.participant.vars['bodymass'] = self.player.bodymass class Image(Page): form_model = 'player' form_fields = ['include'] def is_displayed(self): return self.player.id_in_group != 3 def vars_for_template(self): image = self.participant.vars['images'] return {'img_to_show': image} def before_next_page(self): if self.player.id_in_group < 3: self.participant.vars['include'] = self.player.include class Wait_For_Partner(WaitPage): def after_all_players_arrive(self): print('in after_all_players_arrive') for p in self.group.get_players(): if p.id_in_group < 3: p.r1 = p.participant.vars['age'] p.r2 = p.participant.vars['gender'] p.r3 = p.participant.vars['bodymass'] if p.include == "Yes": p.image_shown = p.participant.vars['images'] class Rating(Page): form_model = 'player' form_fields = ['choice'] def is_displayed(self): return self.player.id_in_group == 3 class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): def is_displayed(self): return self.player.id_in_group != 3 def vars_for_template(self): if self.player.id_in_group < 3: image = self.participant.vars['images'] return {'img_to_show': image} class ResultsRater(Page): def is_displayed(self): return self.player.id_in_group == 3 # first APP in which all the players give a description; second APP in which multiple ratings round and every time # get a rating person. count if description wins. page_sequence = [ Grouping, Instructions, Description, Image, Wait_For_Partner, Rating, ResultsWaitPage, Results, ResultsRater ]