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 = 'Stage3' players_per_group = 2 num_rounds = 1 time_waiting = 60 puzzle_pay = 3 class Subsession(BaseSubsession): number_of_groups = models.IntegerField() def creating_session(self): groups = self.get_groups() self.number_of_groups = len(self.get_groups()) class Group(BaseGroup): def set_payoffs(self): players = self.get_players() for p in players: p.s2payoff = p.participant.SEC_PAY sender = self.get_player_by_role('Sender') if sender.puzzle1 == "PLACE": if sender.puzzle2 == "3279": sender.s3payoff = Constants.puzzle_pay partner = sender.get_others_in_group() for o in partner: o.s3payoff = sender.s3payoff for p in players: p.payoff = p.s2payoff + p.s3payoff def check_partner_status(self): print("CHECKED STATUS",self) one = self.get_player_by_id(1) two = self.get_player_by_id(2) if one.participant.PARTNER_ALIVE == False or two.participant.PARTNER_ALIVE == False: one.participant.PARTNER_ALIVE = False two.participant.PARTNER_ALIVE = False class Player(BasePlayer): role = models.StringField() partner_alive = models.BooleanField(initial= True) def role(self): if (self.group.id_in_subsession % 2) == 0: if self.id_in_group == 1: return 'Sender' else: return 'Receiver' else: if self.id_in_group == 2: return 'Sender' else: return 'Receiver' puzzle1 = models.StringField(blank=True) puzzle2 = models.StringField(blank=True) s2payoff = models.CurrencyField(initial= 0) s3payoff = models.CurrencyField(initial= 0) Question1 = models.IntegerField( choices = [ [1, "Not at all well"], [2, "Slightly well"], [3, "Somewhat well"], [4, "Very well"], [5, "Extremely well"]], widget=widgets.RadioSelect, blank=False ) Question2 = models.IntegerField( choices = [ [1, "Not at all satisfied"], [2, "Slightly satisfied"], [3, "Somewhat satisfied"], [4, "Very satisfied"], [5, "Extremely satisfied"]], widget=widgets.RadioSelect, blank=False ) Question3 = models.IntegerField( choices = [ [1, "Not at all frustrated"], [2, "Slightly frustrated"], [3, "Somewhat frustrated"], [4, "Very frustrated"], [5, "Extremely frustrated"]], widget=widgets.RadioSelect, blank=False ) OpenEnd = models.LongStringField(blank = True) OpenQ3=models.LongStringField(blank=True) Gender = models.IntegerField( choices = [ [1, "Male"], [2, "Female"], [3, "Other"]], widget=widgets.RadioSelect, blank=False ) Age = models.IntegerField() Ethnicity = models.IntegerField( choices = [ [1, "White"], [2, "Black"], [3, "Hispanic"], [4, "Asian"], [5, "American Indian or Alaska Native"], [6, "Native Hawiian or Pacific Islander"], [7, "Multiple Ethnicity"], [8, "Other"]], widget=widgets.RadioSelect, blank=False ) Education = models.IntegerField( choices = [ [1, "Less than high school"], [2, "High school graduate"], [3, "Current college student"], [4, "2 year college degree"], [5, "4 year college degree"], [6, "Professional or Masters degree"], [7, "Doctoral degree"]], widget=widgets.RadioSelect, blank=False )