from otree.api import * c = cu doc = '' class Constants(BaseConstants): name_in_url = 'Game_Tutorial' players_per_group = None num_rounds = 1 tutorial_num_players = 3 tutorial_num_turns = 5 tutorial_multiplication_factor = 2 tutorial_endowment = cu(100) tutorial_interest = '10%' tutorial_time_limit = '3 minutes' tutorial_p3_forecast_template = 'Game_Tutorial/tutorial_p3_forecast.html' tutorial_resources_template = 'Game_Tutorial/tutorial_resources.html' tutorial_harmed_template = 'Game_Tutorial/tutorial_harmed.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def tutorial_q3_error_message(player, value): if value != (9): return('This answer is not correct. Hint: What number is in bold font?') def tutorial_q4_error_message(player, value): if value != (10): return('This answer is not correct. Hint: What number is in bold font?') def tutorial_q5_error_message(player, value): if value != (50): return('This answer is not correct. Hint: Place your cursor over the "Community Resource" bar that corresponds to you (blue bar).') def tutorial_q6_error_message(player, value): if value != (60): return('This answer is not correct. Hint1: Place your cursor over the "Chance of Being Harmed" bar that corresponds to you (blue bar on the right). Hint2: Leave the percent sign (%) out of your answer.') def tutorial_q7_error_message(player, value): if value != (6): return('This answer is not correct. Hint: How many houses have been struck by lightning?') def tutorial_q8_error_message(player, value): if value != (4): return('This answer is not correct. Hint: How many umbrellas are there?') def tutorial_q9_error_message(player, value): if value != (15): return('This answer is not correct. Hint: How many umbrellas are there in total?') def tutorial_q10_error_message(player, value): if value != (5): return('This answer is not correct. Hint: How many umbrellas are there per row?') def tutorial_q11_error_message(player, value): if value != (2): return('This answer is not correct. Hint: How many more lightning bolts are there than umbrellas?') def tutorial_q12_error_message(player, value): if value != (0): return('This answer is not correct. Hint: How many umbrellas have NOT been grayed out?') def tutorial_q13_error_message(player, value): if value != (3): return('This answer is not correct. Hint: What is 2 + 1?') def tutorial_q14_error_message(player, value): if value != (47): return('This answer is not correct. Hint: What is 50 - 3?') def tutorial_q7b_error_message(player, value): if value != (17): return('This answer is not correct. Hint: In total, how many houses were struck by lightning?') def tutorial_q12b_error_message(player, value): if value != (1): return('This answer is not correct. Hint: How many of your (red) houses have NOT been grayed out?') class Player(BasePlayer): tutorial_q3 = models.CurrencyField(label='What is the current value of the community shield?') tutorial_q5 = models.CurrencyField(label='How many resources do you have left?') tutorial_q6 = models.IntegerField(label="What is your chance of being harmed by this turn's disaster (%)?") tutorial_q7 = models.CurrencyField(label='What is your expected damage this turn?') tutorial_q8 = models.CurrencyField(label='If you contribute 2 points, how many points will you add to the shield?') tutorial_q9 = models.CurrencyField(label='If the starting value of the shield was 9 points, you added 4 shield points (contributed 2 points), Player 2 added 0 shield points (contributed 0 points), and Player 3 added 2 shield points (contributed 1 point), what is the new value of the shield?') tutorial_q10 = models.CurrencyField(label='With 15 total shield points and 3 community members, how many shield points do you individually receive?') tutorial_q11 = models.CurrencyField(label='If your community was expected to receive 17 points of damage but had a shield worth 15 points, what is the expected net damage to your community?') tutorial_q12 = models.CurrencyField(label='In this example, how many shield points will be added back into the community shield at the start of next turn?') tutorial_q13 = models.CurrencyField(label='If you contributed 2 points and received 1 point of damage, what is your total loss for the turn?') tutorial_q4 = models.IntegerField(label="What is the severity of this turn's disaster?") tutorial_q14 = models.CurrencyField(label='If you started the turn with 50 points and had a loss of 3 points, how many resources will you have at the start of the next turn?') tutorial_q7b = models.CurrencyField(label="In this example, what is your community's total expected damage?") tutorial_q12b = models.CurrencyField(label="In this example, how many of the community's 2 points of net damage were randomly allocated to you?") tutorial_q3_error_message = tutorial_q3_error_message tutorial_q4_error_message = tutorial_q4_error_message tutorial_q5_error_message = tutorial_q5_error_message tutorial_q6_error_message = tutorial_q6_error_message tutorial_q7_error_message = tutorial_q7_error_message tutorial_q8_error_message = tutorial_q8_error_message tutorial_q9_error_message = tutorial_q9_error_message tutorial_q10_error_message = tutorial_q10_error_message tutorial_q11_error_message = tutorial_q11_error_message tutorial_q12_error_message = tutorial_q12_error_message tutorial_q13_error_message = tutorial_q13_error_message tutorial_q14_error_message = tutorial_q14_error_message tutorial_q7b_error_message = tutorial_q7b_error_message tutorial_q12b_error_message = tutorial_q12b_error_message class R3_HitForecast(Page): form_model = 'player' @staticmethod def is_displayed(player): return False @staticmethod def js_vars(player): return dict( severity = 10, endowment_half = Constants.tutorial_endowment / 2, hit_probs_others = [0, 80, 50], hit_probs_you = [10, 0, 0], resources_others = [0, 90, 23], resources_you = [47, 0, 0], categories = ['You'] + ['Player 2', 'Player 3'] ) class P1_Intro(Page): form_model = 'player' class P2_Display(Page): form_model = 'player' class P3_Shield(Page): form_model = 'player' form_fields = ['tutorial_q3'] class P4_Severity(Page): form_model = 'player' form_fields = ['tutorial_q4'] class P5_Resources(Page): form_model = 'player' form_fields = ['tutorial_q5'] @staticmethod def js_vars(player): return dict( severity = 10, endowment_half = Constants.tutorial_endowment / 2, hit_probs_others = [0, 20, 90], hit_probs_you = [60, 0, 0], resources_others = [0, 90, 25], resources_you = [50, 0, 0], categories = ['You'] + ['Player 2', 'Player 3'] ) class P6_Harm(Page): form_model = 'player' form_fields = ['tutorial_q6'] @staticmethod def js_vars(player): return dict( severity = 10, endowment_half = Constants.tutorial_endowment / 2, hit_probs_others = [0, 20, 90], hit_probs_you = [60, 0, 0], resources_others = [0, 90, 25], resources_you = [50, 0, 0], categories = ['You'] + ['Player 2', 'Player 3'] ) class P7_Damage(Page): form_model = 'player' form_fields = ['tutorial_q7'] class P7b_TotalDamage(Page): form_model = 'player' form_fields = ['tutorial_q7b'] class P8_Contribute(Page): form_model = 'player' form_fields = ['tutorial_q8'] class P9_Value(Page): form_model = 'player' form_fields = ['tutorial_q9'] class P10_Share(Page): form_model = 'player' form_fields = ['tutorial_q10'] @staticmethod def is_displayed(player): return False class P11_Reduce(Page): form_model = 'player' form_fields = ['tutorial_q11'] class P12_AddBack(Page): form_model = 'player' form_fields = ['tutorial_q12'] class P12b_LeftoverDamage(Page): form_model = 'player' form_fields = ['tutorial_q12b'] class P13_Loss(Page): form_model = 'player' form_fields = ['tutorial_q13'] class P14_NewResources(Page): form_model = 'player' form_fields = ['tutorial_q14'] class P15_Recap(Page): form_model = 'player' class End(Page): form_model = 'player' page_sequence = [R3_HitForecast, P1_Intro, P2_Display, P3_Shield, P4_Severity, P5_Resources, P6_Harm, P7_Damage, P7b_TotalDamage, P8_Contribute, P9_Value, P10_Share, P11_Reduce, P12_AddBack, P12b_LeftoverDamage, P13_Loss, P14_NewResources, P15_Recap, End]