from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Elaine Rhee' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'NIT_1_Base' players_per_group = 4 num_rounds = 50 base_payment = c(5) showup_fee = 13 divider_both_enter = 3 payoff_exit = 0 oneshot_game = 10 #number of rounds for quarter game: 1round*10games class Subsession(BaseSubsession): def creating_session(self): if self.round_number <= Constants.oneshot_game: self.group_randomly() elif self.round_number > Constants.oneshot_game and (self.round_number-Constants.oneshot_game) % 4 == 1: self.group_randomly() elif self.round_number > Constants.oneshot_game and (self.round_number-Constants.oneshot_game) % 4 == 2: self.group_like_round(self.round_number - 1) elif self.round_number > Constants.oneshot_game and (self.round_number-Constants.oneshot_game) % 4 == 3: self.group_like_round(self.round_number - 2) elif self.round_number > Constants.oneshot_game and (self.round_number-Constants.oneshot_game) % 4 == 0: self.group_like_round(self.round_number - 3) if self.round_number == Constants.num_rounds: paying_game = random.randint(1, 20) #change 6 to 20 self.session.vars['paying_game'] = paying_game class Group(BaseGroup): pass class Player(BasePlayer): def set_random_number(selfs): return random.randint(1,5) quiz1 = models.IntegerField(label='Q1. How many points did you make in this round?', choices=[ [1, '5'], [2, '5/3 = 1.67'], [3, '2'], [4, '2/3 = 0.67'], [5, '0'] ]) # answer is 2 quiz2 = models.IntegerField(label='Q2. How many points did your teammate make in this round?', choices=[ [1, '5'], [2, '5/3 = 1.67'], [3, '2'], [4, '2/3 = 0.67'], [5, '0'], ]) # answer is 4 quiz3 = models.IntegerField(label='Q3. How much money did you make in this game?', choices=[ [1, '20'], [2, '10'], [3, '0'] ]) # answer is 1 random_number = models.IntegerField() teammate_random_number = models.IntegerField() point = models.FloatField() total_point = models.FloatField() teammate_total_point = models.FloatField() oppteam_total_point = models.FloatField() individual_comp_result = models.StringField() team_comp_result = models.StringField() enter1 = models.BooleanField(label='Choose your action when your random number is 1', choices=[ [True, 'A'], [False, 'B'] ]) enter2 = models.BooleanField(label='Choose your action when your random number is 2', choices=[ [True, 'A'], [False, 'B'] ]) enter3 = models.BooleanField(label='Choose your action when your random number is 3', choices=[ [True, 'A'], [False, 'B'] ]) enter4 = models.BooleanField(label='Choose your action when your random number is 4', choices=[ [True, 'A'], [False, 'B'] ]) enter5 = models.BooleanField(label='Choose your action when your random number is 5', choices=[ [True, 'A'], [False, 'B'] ]) teammate_enter1 = models.BooleanField() teammate_enter2 = models.BooleanField() teammate_enter3 = models.BooleanField() teammate_enter4 = models.BooleanField() teammate_enter5 = models.BooleanField() enter = models.BooleanField() teammate_enter = models.BooleanField() star = models.StringField() teammate_star = models.StringField() oppteam_star = models.StringField() payment = models.CurrencyField() # actual payment given out female = models.IntegerField(label='What is your gender', choices=[ [1, 'Female'], [0, 'Male'], [2, 'Other'] ]) plan = models.LongStringField(label='How did you decide to choose "A" or "B" when playing the game?') experimentFlow = models.StringField(label='How was the experiment? Was it hard to follow?') instructionHard = models.StringField(label='Were the instructions easy to understand?')