from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random doc = """ Rot Prac vs Comp """ class Constants(BaseConstants): name_in_url = 'rotprac1' players_per_group = None num_rounds = 15 class Subsession(BaseSubsession): def creating_session(self): message = random.randint(0,1) group = self.get_groups() for g in group: if message == 0: g.red_message = "The number is even" else: g.red_message = "The number is odd" for g in group: if self.round_number != 6: g.accurate = True else: g.accurate = False class Group(BaseGroup): red_message = models.StringField() blue_decision = models.StringField() accurate = models.BooleanField() reveal = models.Stringfield() end_reveal = models.StringField() disclosure = models.Stringfield() replace_defense = models.StringField() class Player(BasePlayer): def role(self): if self.id_in_group == 1: return 'blue' response = models.StringField( widget=widgets.RadioSelectHorizontal, choices= ['Believe','Insure','Risk-Avert'] ) verification_choice = models.StringField( widget = widgets.RadioSelect, choices = ['At least 1 Red Player (cost $2)', 'Partner Red Player (cost $6)', 'I do NOT want to know'] ) end_verification_choice = models.StringField( widget = widgets.RadioSelect, choices = ['Yes (cost $2)', 'No'] ) replace = model.Stringfield( widget = widgets.RadioSelectHorizontal, choices = ['Replace (cost $8BP/$2RP)','Do not Replace'] ) trustQuestion1 = models.StringField( widget = widgets.RadioSelectHorizontal, choices = ['1 (Strongly Disagree)', '2', '3', '4', '5 (Strongly Agree)'] ) trustQuestion2 = models.StringField( widget = widgets.RadioSelectHorizontal, choices = ['1 (Strongly Disagree)', '2', '3', '4', '5 (Strongly Agree)'] ) trustQuestion3 = models.StringField( widget = widgets.RadioSelectHorizontal, choices = ['1 (Strongly Disagree)', '2', '3', '4', '5 (Strongly Agree)'] ) trustQuestion4 = models.StringField( widget = widgets.RadioSelectHorizontal, choices = ['1 (Strongly Disagree)', '2', '3', '4', '5 (Strongly Agree)'] )