from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'Change_Game_1' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 PROD1_DEMAND = 593 PROD2_DEMAND = 515 PROD3_DEMAND = 464 RETAIL = 57 WHOLESALE = 9 RETAILPROD1 = 57 WHOLESALEPROD1 = 9 MEANPROD1 = 400 SDPROD1 = 100 PROFITCALC = 0.002 MEANPROD2 = 500 MEANPROD3 = 600 SDPROD2 = 300 SDPROD3 = 200 MEANPROD4 = 500 MEANPROD5 = 500 MEANPROD6 = 600 MEANPROD7 = 500 MEANPROD8 = 400 MEANPROD9 = 500 MEANPROD10 = 600 MEANPROD11 = 400 MEANPROD12 = 500 SDPROD4 = 300 SDPROD5 = 200 SDPROD6 = 100 SDPROD7 = 100 SDPROD8 = 300 SDPROD9 = 100 SDPROD10 = 300 SDPROD11 = 200 SDPROD12 = 200 WHOLESALEPROD4 = 9.5 WHOLESALEPROD7 = 1.3 PROD4_DEMAND = 696 PROD5_DEMAND = 441 PROD6_DEMAND = 437 PROD7_DEMAND = 422 PROD8_DEMAND = 628 PROD9_DEMAND = 378 PROD10_DEMAND = 710 PROD11_DEMAND = 427 PROD12_DEMAND = 439 PROD1_DEMAND2 = 308 PROD2_DEMAND2 = 641 PROD3_DEMAND2 = 263 PROD4_DEMAND2 = 592 PROD5_DEMAND2 = 686 PROD6_DEMAND2 = 467 PROD7_DEMAND2 = 258 PROD8_DEMAND2 = 539 PROD9_DEMAND2 = 586 PROD10_DEMAND2 = 570 PROD11_DEMAND2 = 372 PROD12_DEMAND2 = 640 class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): #import random #for player in subsession.get_players(): # player.treatment = random.choice([1,2,3]) import random # Define the choices and their corresponding probabilities choices = [1, 2, 3] weights = [0, 0, 1] # Choose a random number based on the specified probabilities for player in subsession.get_players(): player.treatment = random.choices(choices, weights, k=1)[0] class Group(BaseGroup): pass class Player(BasePlayer): gender = models.StringField(blank=True, label='If comfortable, please write your gender below.') student_status = models.StringField(choices=[['Yes', 'Yes'], ['No', 'No']], label='Are you presently either a Junior or Senior undergraduate or graduate student studying Supply Chain Management or another related field?', widget=widgets.RadioSelectHorizontal) Q2_1 = models.IntegerField(initial=0, label='How much would you like to order of product 13? ', max=1500, min=1) Q2_2 = models.IntegerField(blank=True, initial=0, label='How much would you like to order of product 14? ', max=1500, min=1) Q2_3 = models.IntegerField(initial=0, label='How much would you like to order of product 15? ', max=1500, min=1) Prod1_Order = models.IntegerField() Prod2_Profit = models.IntegerField() Prod2_Order = models.IntegerField() Prod3_Order = models.IntegerField() Prod3_Profit = models.IntegerField() my_field = models.IntegerField() TotalProfit = models.IntegerField() Payout = models.FloatField() Prod1_Profit = models.IntegerField() Consent = models.IntegerField(choices=[[1, 'Yes']], label='By clicking yes below, you are consenting to participating in this experiment.', widget=widgets.RadioSelectHorizontal) treatment = models.IntegerField(initial=0) Q2_4 = models.IntegerField(initial=0, label='How much would you like to order of product 16? ', max=1500, min=1) Q2_5 = models.IntegerField(initial=0, label='How much would you like to order of product 17? ', max=1500, min=1) Q2_6 = models.IntegerField(initial=0, label='How much would you like to order of product 18? ', max=1500, min=1) Q2_7 = models.IntegerField(initial=0, label='How much would you like to order of product 19? ', max=1500, min=0) Q2_8 = models.IntegerField(initial=0, label='How much would you like to order of product 20? ', max=1500, min=1) Q2_9 = models.IntegerField(initial=0, label='How much would you like to order of product 21? ', max=1500, min=0) Q2_10 = models.IntegerField(initial=0, label='How much would you like to order of product 22? ', max=1500, min=0) Q2_11 = models.IntegerField(initial=0, label='How much would you like to order of product 23? ', max=1500, min=0) Q2_12 = models.IntegerField(initial=0, label='How much would you like to order of product 24? ', max=1500, min=0) Prod4_Order = models.IntegerField() Prod5_Order = models.IntegerField() Prod6_Order = models.IntegerField() Prod7_Order = models.IntegerField() Prod8_Order = models.IntegerField() Prod9_Order = models.IntegerField() Prod10_Order = models.IntegerField() Prod11_Order = models.IntegerField() Prod12_Order = models.IntegerField() Prod4_Profit = models.IntegerField() Prod5_Profit = models.IntegerField() Prod6_Profit = models.IntegerField() Prod7_Profit = models.IntegerField() Prod8_Profit = models.IntegerField() Prod9_Profit = models.IntegerField() Prod10_Profit = models.IntegerField() Prod11_Profit = models.IntegerField() Prod12_Profit = models.IntegerField() P1_1 = models.IntegerField(label='How much would you like to order of product 1?') P1_2 = models.IntegerField(label='How much would you like to order of product 2? ') P1_3 = models.IntegerField(label='How much would you like to order of product 3? ') PR1_Update = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], label='Would you like to update your order for product 1 for the change fee listed above?', widget=widgets.RadioSelect) PR2_Update = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], label='Would you like to update your order for product 2 for the change fee listed above?', widget=widgets.RadioSelect) PR3_Update = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], label='Would you like to update your order for product 3 for the change fee listed above?', widget=widgets.RadioSelect) P2_1 = models.IntegerField(initial=0, label='How much would you like to order of product 1? ', max=250, min=1) P2_2 = models.IntegerField(initial=0, label='How much would you like to order of product 2? ', max=250, min=1) P2_3 = models.IntegerField(initial=0, label='How much would you like to order of product 3? ', max=250, min=1) PR1_Order = models.IntegerField() PR2_Order = models.IntegerField() PR3_Order = models.IntegerField() PR1_Profit = models.IntegerField() PR2_Profit = models.IntegerField() PR3_Profit = models.IntegerField() P1_Mean = models.IntegerField(blank=True, choices=[[1, 'Mean']], initial=0, label=' ', widget=widgets.RadioSelect) P1_Std = models.IntegerField(blank=True, choices=[[1, 'Standard Deviation']], initial=0, label=' ', widget=widgets.RadioSelect) P1_PP = models.IntegerField(blank=True, choices=[[1, 'Purchase Price']], initial=0, label=' ', widget=widgets.RadioSelect) P2_Mean = models.IntegerField(blank=True, choices=[[1, 'Mean']], initial=0, label=' ', widget=widgets.RadioSelect) P2_Std = models.IntegerField(blank=True, choices=[[1, 'Standard Deviation']], initial=0, label=' ', widget=widgets.RadioSelect) P2_PP = models.IntegerField(blank=True, choices=[[1, 'Purchase Price']], initial=0, label=' ', widget=widgets.RadioSelect) P3_Mean = models.IntegerField(blank=True, choices=[[1, 'Mean']], initial=0, label=' ', widget=widgets.RadioSelect) P3_Std = models.IntegerField(blank=True, choices=[[1, 'Standard Deviation']], initial=0, label=' ', widget=widgets.RadioSelect) P3_PP = models.IntegerField(blank=True, choices=[[1, 'Purchase Price']], initial=0, label=' ', widget=widgets.RadioSelect) DidChange = models.LongStringField(label='Did you change any of your ordering quantities after the update? Why? ') MeanLikerd = models.IntegerField(choices=[[1, 'Not at all important'], [2, 'Low importance'], [3, 'Slightly important'], [4, 'Neutral'], [5, 'Moderately important'], [6, 'Very important'], [7, 'Extremely important']], label='MEAN', widget=widgets.RadioSelect) STDLikerd = models.IntegerField(choices=[[1, 'Not at all important'], [2, 'Low importance'], [3, 'Slightly important'], [4, 'Neutral'], [5, 'Moderately important'], [6, 'Very important'], [7, 'Extremely important']], label='STANDARD DEVIATION', widget=widgets.RadioSelect) PPLikerd = models.IntegerField(choices=[[1, 'Not at all important'], [2, 'Low importance'], [3, 'Slightly important'], [4, 'Neutral'], [5, 'Moderately important'], [6, 'Very important'], [7, 'Extremely important']], label='PURCHASE PRICE', widget=widgets.RadioSelect) MeanAwareness = models.IntegerField(choices=[[1, 'Not at all aware'], [2, 'Slightly aware'], [3, 'Somewhat aware'], [4, 'Moderately aware'], [5, 'Extremely aware']], label='MEAN', widget=widgets.RadioSelect) STDAWARENESS = models.IntegerField(choices=[[1, 'Not at all aware'], [2, 'Slightly aware'], [3, 'Somewhat aware'], [4, 'Moderately aware'], [5, 'Extremely aware']], label='STANDARD DEVIATION', widget=widgets.RadioSelect) PPAware = models.IntegerField(choices=[[1, 'Not at all aware'], [2, 'Slightly aware'], [3, 'Somewhat aware'], [4, 'Moderately aware'], [5, 'Extremely aware']], label='PURCHASE PRICE', widget=widgets.RadioSelect) totalearned = models.CurrencyField() Age = models.IntegerField(blank=True, label='What is your age?') VenmoPIN = models.StringField(blank=True, label='To be paid, please make up a 4 digit PIN. Use this PIN to request your earned amount using the Venmo QR code on this page (in the "What\'s this for?" area, write your PIN number). ') NoVenmo = models.StringField(blank=True, label='No Venmo? Please give your cashapp handle, paypal information, or your favorite charity to donate your earnings to!') RiskAssessment = models.IntegerField(choices=[[1, 'Fully unwilling to take risks'], [2, 'Unwilling to take risks'], [3, 'Somewhat unwilling to take risks'], [4, 'Neutral'], [5, 'Somewhat prepared to take risks'], [6, 'Prepared to take risks'], [7, 'Fully prepared to take risks']], label=' Are you generally a person who is fully prepared to take risks or do you try to avoid taking risks?') Q1_1 = models.IntegerField(label='How much would you like to order of product 1? ') Q1_2 = models.IntegerField(label='How much would you like to order of product 2? ') Q1_3 = models.IntegerField(label='How much would you like to order of product 3? ') Q1_4 = models.IntegerField(label='How much would you like to order of product 4? ') Q1_5 = models.IntegerField(label='How much would you like to order of product 5? ') Q1_6 = models.IntegerField(label='How much would you like to order of product 6? ') Q1_7 = models.IntegerField(label='How much would you like to order of product 7? ') Q1_8 = models.IntegerField(label='How much would you like to order of product 8? ') Q1_9 = models.IntegerField(label='How much would you like to order of product 9? ') Q1_10 = models.IntegerField(label='How much would you like to order of product 10? ') Q1_11 = models.IntegerField(label='How much would you like to order of product 11? ') Q1_12 = models.IntegerField(label='How much would you like to order of product 12? ') Prod1_Profit2 = models.IntegerField() Prod2_Profit2 = models.IntegerField() Prod3_Profit2 = models.IntegerField() Prod4_Profit2 = models.IntegerField() Prod5_Profit2 = models.IntegerField() Prod6_Profit2 = models.IntegerField() Prod7_Profit2 = models.IntegerField() Prod8_Profit2 = models.IntegerField() Prod9_Profit2 = models.IntegerField() Prod10_Profit2 = models.IntegerField() Prod11_Profit2 = models.IntegerField() Prod12_Profit2 = models.IntegerField() class PracticeIntro(Page): form_model = 'player' class PR1NewOrder(Page): form_model = 'player' form_fields = ['P2_1'] class PR2NewOrder(Page): form_model = 'player' form_fields = ['P2_2'] class PR3NewOrder(Page): form_model = 'player' form_fields = ['P2_3'] class PRResults(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): player.PR1_Profit = min(player.P2_1, 111) * 15 - player.P2_1 * 3 - 10 player.PR2_Profit = min(player.P2_2, 83) * 15 - player.P2_2 * 4 - round(7.5) player.PR3_Profit = min(player.P2_3, 109) * 15 - round(player.P2_3 * 3.5) - 15 return dict(player=player) class MovetoGame(Page): form_model = 'player' class Game_Intro(Page): form_model = 'player' class Initial_orders(Page): form_model = 'player' form_fields = ['Q1_1', 'Q1_2', 'Q1_3', 'Q1_4', 'Q1_5', 'Q1_6', 'Q1_7', 'Q1_8', 'Q1_9', 'Q1_10', 'Q1_11', 'Q1_12'] class Transition(Page): form_model = 'player' class Product1NewOrder(Page): form_model = 'player' form_fields = ['Q2_1'] class Product2NewOrder(Page): form_model = 'player' form_fields = ['Q2_2'] class Product3NewOrder(Page): form_model = 'player' form_fields = ['Q2_3'] class Product4NewOrder(Page): form_model = 'player' form_fields = ['Q2_4'] class Product5NewOrder(Page): form_model = 'player' form_fields = ['Q2_5'] class Product6NewOrder(Page): form_model = 'player' form_fields = ['Q2_6'] class Product7NewOrder(Page): form_model = 'player' form_fields = ['Q2_7'] class Product8NewOrder(Page): form_model = 'player' form_fields = ['Q2_8'] class Product9NewOrder(Page): form_model = 'player' form_fields = ['Q2_9'] class Product10NewOrder(Page): form_model = 'player' form_fields = ['Q2_10'] class Product11NewOrder(Page): form_model = 'player' form_fields = ['Q2_11'] class Product12NewOrder(Page): form_model = 'player' form_fields = ['Q2_12'] class ProductResults(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): player.Prod1_Profit = min(player.Q2_1, C.PROD1_DEMAND) * C.RETAIL - player.Q2_1 * C.WHOLESALE player.Prod2_Profit = min(player.Q2_2, C.PROD2_DEMAND) * C.RETAIL - player.Q2_2 * C.WHOLESALE player.Prod3_Profit = min(player.Q2_3, C.PROD3_DEMAND) * C.RETAIL - player.Q2_3 * C.WHOLESALE player.Prod4_Profit = min(player.Q2_4, C.PROD4_DEMAND) * C.RETAIL - round(player.Q2_4 * 9.5) player.Prod5_Profit = min(player.Q2_5, C.PROD5_DEMAND) * C.RETAIL - player.Q2_5 * C.WHOLESALE player.Prod6_Profit = min(player.Q2_6, C.PROD6_DEMAND) * C.RETAIL - player.Q2_6 * C.WHOLESALE player.Prod7_Profit = min(player.Q2_7, C.PROD7_DEMAND) * C.RETAIL - round(player.Q2_7 * 1.3) player.Prod8_Profit = min(player.Q2_8, C.PROD8_DEMAND) * C.RETAIL - player.Q2_8 * C.WHOLESALE player.Prod9_Profit = min(player.Q2_9, C.PROD9_DEMAND) * C.RETAIL - player.Q2_9 * C.WHOLESALE player.Prod10_Profit = min(player.Q2_10, C.PROD10_DEMAND) * C.RETAIL - player.Q2_10 * C.WHOLESALE player.Prod11_Profit = min(player.Q2_11, C.PROD11_DEMAND) * C.RETAIL - player.Q2_11 * C.WHOLESALE player.Prod12_Profit = min(player.Q2_12, C.PROD12_DEMAND) * C.RETAIL - player.Q2_12 * C.WHOLESALE player.Prod1_Profit2 = min(player.Q1_1, C.PROD1_DEMAND2) * C.RETAIL - player.Q1_1 * C.WHOLESALE player.Prod2_Profit2 = min(player.Q1_2, C.PROD2_DEMAND2) * C.RETAIL - player.Q1_2 * C.WHOLESALE player.Prod3_Profit2 = min(player.Q1_3, C.PROD3_DEMAND2) * C.RETAIL - player.Q1_3 * C.WHOLESALE player.Prod4_Profit2 = min(player.Q1_4, C.PROD4_DEMAND2) * C.RETAIL - player.Q1_4 * C.WHOLESALE player.Prod5_Profit2 = min(player.Q1_5, C.PROD5_DEMAND2) * C.RETAIL - player.Q1_5 * C.WHOLESALE player.Prod6_Profit2 = min(player.Q1_6, C.PROD6_DEMAND2) * C.RETAIL - player.Q1_6 * C.WHOLESALE player.Prod7_Profit2 = min(player.Q1_7, C.PROD7_DEMAND2) * C.RETAIL - player.Q1_7 * C.WHOLESALE player.Prod8_Profit2 = min(player.Q1_8, C.PROD8_DEMAND2) * C.RETAIL - player.Q1_8 * C.WHOLESALE player.Prod9_Profit2 = min(player.Q1_9, C.PROD9_DEMAND2) * C.RETAIL - player.Q1_9 * C.WHOLESALE player.Prod10_Profit2 = min(player.Q1_10, C.PROD10_DEMAND2) * C.RETAIL - player.Q1_10 * C.WHOLESALE player.Prod11_Profit2 = min(player.Q1_11, C.PROD11_DEMAND2) * C.RETAIL - player.Q1_11 * C.WHOLESALE player.Prod12_Profit2 = min(player.Q1_12, C.PROD12_DEMAND2) * C.RETAIL - player.Q1_12 * C.WHOLESALE return dict(player=player) @staticmethod def before_next_page(player: Player, timeout_happened): player.TotalProfit=player.Prod1_Profit+player.Prod2_Profit+player.Prod3_Profit+player.Prod4_Profit+player.Prod5_Profit+player.Prod6_Profit+player.Prod7_Profit+player.Prod8_Profit+player.Prod9_Profit+player.Prod10_Profit+player.Prod11_Profit+player.Prod12_Profit+player.Prod1_Profit2+player.Prod2_Profit2+player.Prod3_Profit2+player.Prod4_Profit2+player.Prod5_Profit2+player.Prod6_Profit2+player.Prod7_Profit2+player.Prod8_Profit2+player.Prod9_Profit2+player.Prod10_Profit2+player.Prod11_Profit2+player.Prod12_Profit2 player.payoff=player.TotalProfit/150000 class Likert2(Page): form_model = 'player' form_fields = ['MeanAwareness', 'STDAWARENESS', 'PPAware'] class Qualitative(Page): form_model = 'player' form_fields = ['RiskAssessment'] class Payoff(Page): form_model = 'player' class End(Page): form_model = 'player' class Consent(Page): form_model = 'player' form_fields = ['gender', 'Age', 'student_status', 'Consent'] @staticmethod def before_next_page(player: Player, timeout_happened): if player.treatment == 1: player.change_fee = 400 elif player.treatment == 2: player.change_fee = 200 else: player.change_fee = 0 page_sequence = [PracticeIntro, PR1NewOrder, PR2NewOrder, PR3NewOrder, PRResults, MovetoGame, Game_Intro, Initial_orders, Transition, Product1NewOrder, Product2NewOrder, Product3NewOrder, Product4NewOrder, Product5NewOrder, Product6NewOrder, Product7NewOrder, Product8NewOrder, Product9NewOrder, Product10NewOrder, Product11NewOrder, Product12NewOrder, ProductResults, Likert2, Qualitative, Payoff, End, Consent]