from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'competition1' PLAYERS_PER_GROUP = None # TASKS = ['VP', 'VPR', 'VT', 'MP', 'MPR', 'MT'] NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def make_field2(label): return models.IntegerField( choices=[ [1, "1 - Strongly Disagree"], [2, "2"], [3, "3"], [4, "4 - Neither Agree Nor Disagree"], [5, "5"], [6, "6"], [7, "7 - Strongly Agree"] ], label=label, widget=widgets.RadioSelect, ) class Player(BasePlayer): treat = models.IntegerField() matrix_answer = models.IntegerField(initial=0) verbal_prac_correct = models.IntegerField(initial=0) verbal_prac_count = models.IntegerField(initial=0) verbal_pr_abs = models.IntegerField() verbal_pr_rank = models.IntegerField(choices=[1, 2, 3, 4,5,6,7,8,9,10], widget=widgets.RadioSelectHorizontal) verbal_pr_correct = models.IntegerField(initial=0) verbal_pr_count = models.IntegerField(initial=0) verbal_t_abs = models.IntegerField() verbal_t_rank = models.IntegerField(choices=[1, 2, 3, 4,5,6,7,8,9,10], widget=widgets.RadioSelectHorizontal) verbal_t_correct = models.IntegerField(initial=0) verbal_t_count = models.IntegerField(initial=0) final_abs = models.IntegerField() final_rank = models.IntegerField(choices=[1, 2, 3, 4,5,6,7,8,9,10], widget=widgets.RadioSelectHorizontal) math_prac_correct = models.IntegerField(initial=0) math_prac_count = models.IntegerField(initial=0) math_pr_abs = models.IntegerField() math_pr_rank = models.IntegerField(choices=[1, 2, 3, 4, 5, 6, 7, 8,9,10], widget=widgets.RadioSelectHorizontal) math_pr_correct = models.IntegerField(initial=0) math_pr_count = models.IntegerField(initial=0) math_t_abs = models.IntegerField() math_t_rank = models.IntegerField(choices=[1, 2, 3, 4,5,6,7,8,9,10], widget=widgets.RadioSelectHorizontal) math_t_correct = models.IntegerField(initial=0) math_t_count = models.IntegerField(initial=0) # demographic Age = models.IntegerField(min=0, max=100, label="please provide the answer of '3+4'") Gender = models.IntegerField( choices=[ [0, 'Female'], [1, 'Male '], ], label="What is your gender identification?", widget=widgets.RadioSelectHorizontal, ) Ethnicity = models.IntegerField( choices=[ [1, 'Asian'], [2, 'Black '], [3, 'Hispanic-Latino'], [4, 'Native American'], [5, 'White'], [6, 'Other'], ], label="What is your ethnicity?", widget=widgets.RadioSelect, ) Native = models.StringField(label="What is your native language?") Student = models.IntegerField( choices=[ [0, 'Yes'], [1, 'No'] ], label="Are you currently a student?", widget=widgets.RadioSelectHorizontal, ) Degree = models.IntegerField( choices=[ [1, "Less than high school degree"], [2, "High school graduate (high school diploma or equivalent including GED)"], [3, "Some college but no degree"], [4, "Associate degree in college (2-year)"], [5, "Bachelor’s degree in college (4-year)"], [6, "Master’s degree"], [7, "Doctoral degree (Ph.D.)"], [8, "Professional degree (e.g., JD, MD, etc.)"], ], label="What is the highest level of school you have completed or the highest degree you have received?", widget=widgets.RadioSelect, ) Major = models.StringField(label="What is/was your major(s)", blank=True) Industry = models.IntegerField( choices=[ [1, "Administrative and Support Services"], [2, "Agriculture, Forestry, Fishing, and Hunting"], [3, "Construction"], [4, "Educational Services"], [5, "Finance and Insurance"], [6, "Government"], [7, "Health Care and Social Assistance "], [8, "Information"], [9, "Management of Companies and Enterprises "], [10, "Manufacturing"], [11, "Mining, Quarrying, and Oil and Gas Extraction"], [12, "Other Services (Except Public Administration)"], [13, "Professional, Scientific, and Technical Services"], [14, "Real Estate and Rental and Leasing"], [15, "Retail"], [16, "Transportation and Warehousing"], [17, "Utilities"], [18, "Wholesale"], [19, "Others/None of the Above"], ], label="If you are not a student, what industry do you work in?", blank = True ) Working_years = models.IntegerField(label="How many years of working experience do you have?") Marital = models.IntegerField( choices=[ [0, 'Never married '], [1, 'Now married'], [2, 'Widowed '], [3, 'Divorced '], [4, 'Separated '], ], label="What is your marital status?", widget=widgets.RadioSelect, ) Income = models.IntegerField( choices=[ [0, 'Less than $10,000 '], [1, '$10,000 to $20,000'], [2, '$20,000 to $30,000 '], [3, '$30,000 to $40,000 '], [4, '$40,000 to $50,000 '], [5, '$50,000 to $60,000'], [6, '$60,000 to $70,000'], [7, '$70,000 to $80,000'], [8, '$80,000 to $90,000'], [9, '$90,000 to $100,000'], [10, '$100,000 to $200,00'], [11, 'Over $200,000'], ], label="What was your total income last year? ", widget=widgets.RadioSelect, ) # main Coin = models.IntegerField(min=0, max=10, label="You guess the number of heads side up is: " ) Wish = make_field2('I believe the truth is what I would like the truth to be.') Magic = make_field2('If I imagine a good result, the result is more likely to be better.') Anticipatory = make_field2('I tend to imagine a good result because it makes me happy.') No_reason = make_field2('I have no reason to imagine a bad result.') Think_bad = make_field2('I tend to imagine a bad result because it prepares me for failure.') # Ability = make_field2('I have high ability in the task.') Perform = make_field2('I perform well in the task.') Attention = make_field2('Please choose "Strongly Disagree".') Competitive = models.IntegerField( choices=[ [1, 'not competitive at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, 'extremely competitive'], ], label="How competitive do you consider yourself to be?" , widget=widgets.RadioSelectHorizontal, ) Bring_best = models.IntegerField( choices=[ [1, 'not at all like me'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, 'exactly like me'], ], label="Competition brings the best out of me" , widget=widgets.RadioSelectHorizontal, ) Competitive_evn = models.IntegerField( choices=[ [1, 'not competitive at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, 'extremely competitive'], ], label="How competitive is your workplace and/or school?" , widget=widgets.RadioSelectHorizontal, ) Competitive_expose = models.IntegerField( choices=[ [1, ' not exposed to competitions at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, 'exposed to competitions all the time'], ], label="How much are you exposed to the competitive environments overall?" , widget=widgets.RadioSelectHorizontal, ) Will_compete = models.IntegerField( choices=[ [1, 'Not willing to compete at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, 'Very willing to compete'], ], label="How willing are you to compete?" , widget=widgets.RadioSelectHorizontal, ) Will_risk = models.IntegerField( choices=[ [1, 'Not willing to take risks at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, 'Very willing to take risks'], ], label="Are you a person who is usually willing to take risks, or are you " "trying to avoid taking risks. " , widget=widgets.RadioSelectHorizontal, ) Compete_importance = models.IntegerField( choices=[ [1, 'Not important at all'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, 'Very important'], ], label="Do you think it is important to be competitive to succeed in today's society?" , widget=widgets.RadioSelectHorizontal, ) Option = models.IntegerField( choices=[ [1, 'Option 1: Piece rate'], [2, 'Option 2: Competition'], ], widget=widgets.RadioSelectHorizontal, label=" Which option would you choose?" # label="Imagine the following hypothetical scenario. You participate in the verbal task you have just done " # "and you are paid for your performance. You have 1 minutes to solve as many matrices as you can. " # "Here are two salary options: Option 1: Piece rate: you receive $0.01 for each correctly solved " # "matrix; Option 2: Competition: you compete against 3 other people. If you perform better than all " # "three, you receive $0.04 per correctly solved matrix, otherwise you receive nothing. Your three " # "opponents will be randomly selected among the other participants. Which option would you choose? " ) How_change_verbal = models.LongStringField(label="How did changing the rules from non-competitive to competition " "change your effort and performance in the verbal task? Why?") How_change_math = models.LongStringField(label="How did changing the rules from non-competitive to competition " "change your effort and performance in the math task? Why?") Help_or_hurt = models.IntegerField( choices=[ [0, 'helped me'], [1, 'hurt me'], ], label="Competition:" , widget=widgets.RadioSelectHorizontal, ) Try = models.IntegerField( choices=[ [0, 'non-competitive rounds'], [1, 'competitive rounds'], ], label="I tried more in:" , widget=widgets.RadioSelectHorizontal, ) Give_up = models.IntegerField( choices=[ [0, 'never '], [1, 'more in non-competitive rounds'], [2, 'more in competitive rounds '], [3, 'in both type of rounds'], ], label="I gave up:" , widget=widgets.RadioSelectHorizontal, ) classify_verbal = models.IntegerField( choices=[ [0, 'very poor '], [1, ''], [2, ' '], [3, ''], [4, ''], [5, ''], [6, ''], [7, 'excellent'], ], label="On a scale from 1 (very poor) to 7 (excellent), how would you classify your verbal skills?" , widget=widgets.RadioSelectHorizontal, ) classify_math = models.IntegerField( choices=[ [0, 'very poor '], [1, ''], [2, ' '], [3, ''], [4, ''], [5, ''], [6, ''], [7, 'excellent'], ], label="On a scale from 1 (very poor) to 7 (excellent), how would you classify your math skills?" , widget=widgets.RadioSelectHorizontal, ) Good_at_verbal = models.IntegerField( choices=[ [0, 'women '], [1, 'men'], ], label="In your opinion, who would be better in verbal tasks on average, men or women?" , widget=widgets.RadioSelectHorizontal, ) Good_at_math = models.IntegerField( choices=[ [0, 'women '], [1, 'men'], ], label="In your opinion, who would be better in math tasks on average, men or women?" , widget=widgets.RadioSelectHorizontal, ) any_unclear=models.LongStringField(label="Was anything unclear in the instructions or survey questions? ") # left_side_amount = models.IntegerField(initial=0.40) # switching_point = models.IntegerField() is_mobile = models.BooleanField() invest_choice = models.IntegerField( choices=[ [0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10'], ], label="your investment choice is:" #, widget=widgets.RadioSelectHorizontal, ) is_success = models.BooleanField() invest_result=models.IntegerField(label="your investment result is:") # FUNCTIONS class MobileCheck(Page): form_model = 'player' form_fields = ['is_mobile'] def error_message(player: Player, values): if values['is_mobile']: return "Sorry, this experiment does not allow mobile browsers." class verbalInstructions(Page): pass @staticmethod def app_after_this_page(player, upcoming_apps): print('upcoming_apps is', upcoming_apps) if player.treat == 2: return "competition2" class verbal_prac(Page): form_model = 'player' timeout_seconds = 3 timer_text = ' ' def live_method(player, data): print(data) player.verbal_prac_correct = data['count_right'] print(player.verbal_prac_correct) player.verbal_prac_count = data['matrix_count'] print(player.verbal_prac_count) # class verbal_prac_Feedback(Page): # pass # @staticmethod # def is_displayed(player: Player): # participant = player.participant # return player.round_number == participant.task_rounds['verbal'] class verbal_pr_predict(Page): form_model = 'player' form_fields = ['verbal_pr_abs', 'verbal_pr_rank'] class verbal_pr(Page): form_model = 'player' timeout_seconds = 3 timer_text = ' ' def live_method(player, data): print(data) player.verbal_pr_correct = data['count_right'] print(player.verbal_pr_correct) player.verbal_pr_count = data['matrix_count'] print(player.verbal_pr_count) # class verbal_pr_Feedback(Page): # pass # @staticmethod # def is_displayed(player: Player): # participant = player.participant # return player.round_number == participant.task_rounds['verbal'] class verbal_t_predict(Page): form_model = 'player' form_fields = ['verbal_t_abs', 'verbal_t_rank'] class verbal_t(Page): form_model = 'player' timeout_seconds = 3 timer_text = ' ' def live_method(player, data): print(data) player.verbal_t_correct = data['count_right'] print(player.verbal_t_correct) player.verbal_t_count = data['matrix_count'] print(player.verbal_t_count) class mathInstructions(Page): pass class math_prac(Page): form_model = 'player' form_fields = ['matrix_answer'] timeout_seconds = 3 timer_text = ' ' def live_method(player, data): print(data) player.math_prac_correct = data['count_right'] print(player.math_prac_correct) player.math_prac_count = data['matrix_count'] print(player.math_prac_count) class math_pr_predict(Page): form_model = 'player' form_fields = ['math_pr_abs', 'math_pr_rank'] class math_pr(Page): form_model = 'player' form_fields = ['matrix_answer'] timeout_seconds = 3 timer_text = ' ' def live_method(player, data): print(data) player.math_pr_correct = data['count_right'] print(player.math_pr_correct) player.math_pr_count = data['matrix_count'] print(player.math_pr_count) class math_t_predict(Page): form_model = 'player' form_fields = ['math_t_abs', 'math_t_rank'] class math_t(Page): form_model = 'player' form_fields = ['matrix_answer'] timeout_seconds = 3 timer_text = ' ' def live_method(player, data): print(data) player.math_t_correct = data['count_right'] print(player.math_t_correct) player.math_t_count = data['matrix_count'] print(player.math_t_count) class final_predict(Page): form_model = 'player' form_fields = ['final_abs', 'final_rank'] class survey1(Page): form_model = 'player' form_fields = ['Age', 'Gender','Degree'] class thankyou(Page): pass class survey2(Page): form_model = 'player' form_fields = ['Coin', 'Wish', 'Magic', 'Anticipatory', 'No_reason', 'Think_bad', 'Attention', 'Perform', 'Bring_best', 'Option', 'Competitive','Competitive_evn','Competitive_expose', 'Will_compete', 'Will_risk', 'Compete_importance', 'Help_or_hurt', 'Try', 'Give_up','classify_verbal','classify_math', 'Good_at_verbal', 'Good_at_math', 'How_change_verbal', 'How_change_math','any_unclear'] class survey4(Page): form_model = 'player' form_fields = ['invest_choice'] class survey4_result(Page): form_model = 'player' # form_fields = ['invest_result'] @staticmethod def vars_for_template(player): import random player.is_success = random.choice([True, False]) if player.is_success: player.invest_result = player.invest_choice*2 +(10-player.invest_choice) else: player.invest_result = 10-player.invest_choice page_sequence = [survey1, thankyou] # page_sequence = [survey4, survey4_result]