from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'MLAFiveYearlyInfo' PLAYERS_PER_GROUP = None NUM_ROUNDS = 5 B_RETURNS = (42.065, 28.669, 90.029, 110.01, 47.642, 19.005, 32.165, 37.323, 34.624, 43.257, 33.03, 78.774, 38.776, 48.105, 29.601, 13.734, 77.099, 20.045, 62.49, 63.295, 31.854, 58.687, 14.818, 78.884, 51.183, 35.05, 47.791, 61.174, 78.364, 178.53, 24.239, 67.133, 12.505, 55.807, 25.168, 43.429, 55.06, 28.472, 48.204, 51.45, 26.807, 27.141, 21.066, 9.695, 29.184, 66.72, 70.701, 21.883, 31.64, 80.673, 39.496, 71.493, 50.133, 20.406, 61.262, 58.336, 56.53, 33.804, 28.048, 0.017, 25.867, 81.85, 60.685, 11.854, 30.204, 98.086, 4.326, 53.229, 106.614, 52.455, 25.288, -14.398, 16.307, 53.729, 11.466, 44.329, 86.386, 85.775, 29.313, 67.06, 77.548, 51.501, 18.346, -1.904, 37.212, 48.591, 106.399, 15.45, 84.913, 46.621, 58.527, 21.257, 44.661, 109.802, 70.881, 22.877, 80.494, 21.84, 94.633, 55.009) A_RETURNS = (10.602, 10.333, 12.367, 11.022, 11.89, 8.693, 11.693, 11.033, 11.322, 10.509, 11.203, 9.608, 10.643, 12.404, 11.473, 13.038, 10.91, 9.191, 9.579, 10.556, 10.586, 11.448, 11.154, 10.527, 11.187, 9.165, 11.95, 9.628, 11.574, 10.541, 11.103, 12.768, 10.4, 10.445, 9.349, 11.731, 11.316, 11.435, 12.341, 11.069, 10.755, 10.382, 12.301, 9.445, 11.853, 11.022, 12.204, 11.217, 13.124, 10.959, 10.022, 9.439, 11.304, 10.46, 11.598, 9.258, 10.196, 12.531, 9.677, 11.69, 9.865, 12.373, 10.49, 9.722, 9.331, 12.063, 10.338, 11.266, 12.299, 11.62, 11.967, 10.092, 10.306, 9.355, 12.426, 10.707, 10.426, 9.787, 11.563, 11.901, 12.205, 11.073, 10.265, 12.452, 10.909, 9.248, 11.669, 9.977, 12.765, 12.33, 11.034, 10.83, 8.969, 10.886, 10.336, 11.204, 9.774, 10.743, 9.232, 8.545) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): fund_a_allocation = models.IntegerField() fund_a_realized = models.FloatField() fund_b_realized = models.FloatField() combined_realized = models.FloatField() debrief_accepted = models.BooleanField() email_address = models.StringField() class Consent_Form(Page): form_model = 'player' form_fields = ['email_address'] @staticmethod def is_displayed(player: Player): return player.round_number==1 class Introduction(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number==1 class Decision(Page): form_model = 'player' form_fields = ['fund_a_allocation'] class Results(Page): form_model = 'player' @staticmethod def js_vars(player: Player): group = player.group fund_a_return_calc=C.A_RETURNS[(5*(player.id_in_group-1))+player.round_number-1] fund_b_return_calc=C.B_RETURNS[(5*(player.id_in_group-1))+player.round_number-1] combined_return_calc=fund_a_return_calc*(player.fund_a_allocation)/100 + fund_b_return_calc*(100-player.fund_a_allocation)/100 player.combined_realized = combined_return_calc return dict( fund_b_return=round(fund_b_return_calc,3), fund_a_return=round(fund_a_return_calc,3), combined_return= round(combined_return_calc,3) ) class Debrief(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number==5 page_sequence = [Consent_Form, Introduction, Decision, Results, Debrief]