from otree.api import * c = cu doc = '' class Constants(BaseConstants): name_in_url = 'Test' players_per_group = None num_rounds = 34 o_truth1 = 75 o_truth2 = 67 o_truth3 = 46 o_truth4 = -300 o_truth5 = 100 o2_truth1 = 93 o2_truth2 = 47 o2_truth3 = 46 o2_truth4 = 15 o2_truth5 = -117.3 o2_truth6 = 180 o2_truth7 = 1970 o2_truth8 = 7 o2_truth9 = 3352 o2_truth10 = 13.5 temperature = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 28, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) date = ('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '2016.7.23', '2016.1.5', '2017.7.23', '2017.2.2', '2016.3.3', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8', '2017.8.8') weight = (60, 70, 65, 55, 73, 48, 62, 75, 66, 74) picture = ('https://i.loli.net/2021/05/19/Xakr4RQymtgxPnD.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg', 'https://i.loli.net/2021/05/19/cdJAZ8WyxtleLIz.jpg') bonushigh = 5 bonuslow = 3 bonusnull = 0 standardhigh_temperature = 3 standardlow_temperature = 6 standardhigh_weight = 4 standardlow_weight = 10 def TemperatureInRound(subsession): session = subsession.session if subsession.Temperature == -1: subsession.Temperature = Constants.temperature[subsession.round_number-1] def DateInRound(subsession): session = subsession.session if subsession.Date == "-1": subsession.Date = Constants.date[subsession.round_number-1] def WeightInRound(subsession): session = subsession.session if subsession.Weight == -1: subsession.Weight = Constants.weight[subsession.round_number-1] def PicturesInRound(subsession): session = subsession.session if subsession.Pictures == "-1": subsession.Pictures = Constants.picture[subsession.round_number-1] class Subsession(BaseSubsession): Temperature = models.IntegerField(initial=-1) Date = models.StringField(initial='-1') Weight = models.FloatField(initial=-1) Pictures = models.StringField(initial='-1') class Group(BaseGroup): pass class Player(BasePlayer): name = models.StringField(label='Your ID') OverconfidenceLevel1 = models.FloatField(initial=-1) OverconfidenceLevel2 = models.FloatField(initial=-1) o_answer1_1 = models.FloatField() o_answer1_2 = models.FloatField(choices=[[0, '0% Certainly false'], [0.1, '10%'], [0.2, '20%'], [0.3, '30%'], [0.4, '40%'], [0.5, '50% Random'], [0.6, '60%'], [0.7, '70%'], [0.8, '80%'], [0.9, '90%'], [1, '100% Certainly true']], widget=widgets.RadioSelectHorizontal) o_answer1_3 = models.FloatField() o_answer1_4 = models.FloatField() o_answer2_1 = models.FloatField() o_answer2_2 = models.FloatField(choices=[[0, '0% Certainly false'], [0.1, '10%'], [0.2, '20%'], [0.3, '30%'], [0.4, '40%'], [0.5, '50% Random'], [0.6, '60%'], [0.7, '70%'], [0.8, '80%'], [0.9, '90%'], [1, '100% Certainly true']], widget=widgets.RadioSelectHorizontal) o_answer2_3 = models.FloatField() o_answer2_4 = models.FloatField() o_answer3_1 = models.FloatField() o_answer3_2 = models.FloatField(choices=[[0, '0% Certainly false'], [0.1, '10%'], [0.2, '20%'], [0.3, '30%'], [0.4, '40%'], [0.5, '50% Random'], [0.6, '60%'], [0.7, '70%'], [0.8, '80%'], [0.9, '90%'], [1, '100% Certainly true']], widget=widgets.RadioSelectHorizontal) o_answer3_3 = models.FloatField() o_answer3_4 = models.FloatField() o_answer4_1 = models.FloatField() o_answer4_2 = models.FloatField(choices=[[0, '0% 绝对错误'], [0.1, '10%'], [0.2, '20%'], [0.3, '30%'], [0.4, '40%'], [0.5, '50% 完全不确定(正误随机)'], [0.6, '60%'], [0.7, '70%'], [0.8, '80%'], [0.9, '90%'], [1, '100% 完全正确']], widget=widgets.RadioSelectHorizontal) o_answer4_3 = models.FloatField() o_answer4_4 = models.FloatField() o_answer5_3 = models.FloatField() o_answer5_4 = models.FloatField() o_answer5_1 = models.FloatField() o_answer5_2 = models.FloatField(choices=[[0, '0% 一定错误'], [0.1, '10% '], [0.2, '20%'], [0.3, '30%'], [0.4, '40%'], [0.5, '50%正误随机'], [0.6, '60%'], [0.7, '70%'], [0.8, '80%'], [0.9, '90%'], [1, '100%一定正确']], widget=widgets.RadioSelectHorizontal) o2_answer1_1 = models.FloatField() o2_answer1_2 = models.FloatField() o2_answer2_1 = models.FloatField() o2_answer2_2 = models.FloatField() o2_answer3_1 = models.FloatField() o2_answer3_2 = models.FloatField() o2_answer4_1 = models.FloatField() o2_answer4_2 = models.FloatField() o2_answer5_1 = models.FloatField() o2_answer5_2 = models.FloatField() o2_answer6_1 = models.FloatField() o2_answer6_2 = models.FloatField() o2_answer7_1 = models.FloatField() o2_answer7_2 = models.FloatField() o2_answer8_1 = models.FloatField() o2_answer8_2 = models.FloatField() o2_answer9_1 = models.FloatField() o2_answer9_2 = models.FloatField() o2_answer10_1 = models.FloatField() o2_answer10_2 = models.FloatField() o2_answer1 = models.FloatField(choices=[[0, '0'], [0.1, '0.1'], [0.2, '0.2'], [0.3, '0.3'], [0.4, '0.4'], [0.5, '0.5'], [0.6, '0.6'], [0.7, '0.7'], [0.8, '0.8'], [0.9, '0.9'], [1, '1']]) Overconfidence_Weight = models.FloatField(initial=-1) Overconfidence_Temperature = models.FloatField(initial=-1) Weight = models.FloatField(label='上图中人物的体重您认为最有可能是多少(单位:公斤/KG)') Temperature = models.FloatField(label='“我对这一天成都市最高温度的最佳估计是:”') roundWeight = models.FloatField(initial=0) roundTemperature = models.FloatField(initial=0) roundDate = models.StringField(initial='') roundPicture = models.LongStringField(initial='') TestWeight = models.FloatField(label='测试你是否理解体重的规则') TestTemperature = models.FloatField(label='测试你是否理解温度的规则') standardhigh_bound1 = models.FloatField(initial=0) standardhigh_bound2 = models.FloatField(initial=0) standardlow_bound1 = models.FloatField(initial=0) standardlow_bound2 = models.FloatField(initial=0) roundBonus_Weight = models.IntegerField(initial=0) roundBonus_Temperature = models.IntegerField(initial=0) cumulativeBonus_Weight = models.IntegerField(initial=0) cumulativeBonus_Temperature = models.IntegerField(initial=0) cumulativeBonus = models.IntegerField(initial=0) Zero_right = models.FloatField(label='(1)对0道,错10道') right1_wrong9 = models.FloatField(label='(2)对1道,错9道', max=1, min=0) right2_wrong8 = models.FloatField(label='(3)对2道,错8道', max=1, min=0) right3_wrong7 = models.FloatField(label='(4)对3道,错7道', max=1, min=0) right4_wrong6 = models.FloatField(label='(5)对4道,错6道', max=1, min=0) right5_wrong5 = models.FloatField(label='(6)对5道,错5道', max=1, min=0) right6_wrong4 = models.FloatField(label='(7)对6道,错4道', max=1, min=0) right7_wrong3 = models.FloatField(label='(8)对7道,错3道', max=1, min=0) right8_wrong2 = models.FloatField(label='(9)对8道,错2道', max=1, min=0) right9_wrong1 = models.FloatField(label='(10)对9道,错1道', max=1, min=0) right10 = models.FloatField(label='(11)对10道,错0道', max=1, min=0) totalprobability = models.FloatField(initial=0) class Test_Instructions_continue(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number==1 class Understanding_Test(Page): form_model = 'player' form_fields = ['TestWeight', 'TestTemperature'] @staticmethod def is_displayed(player): return player.round_number==1 class MyPage_WeightGuess(Page): form_model = 'player' form_fields = ['Weight'] @staticmethod def is_displayed(player): return player.round_number>=1 and player.round_number<=10 @staticmethod def before_next_page(player, timeout_happened): session = player.session subsession = player.subsession WeightInRound(subsession) PicturesInRound(subsession) player.roundWeight = subsession.Weight player.roundPicture = subsession.Pictures player.standardhigh_bound1=player.roundWeight-Constants.standardhigh_weight player.standardhigh_bound2=player.roundWeight+Constants.standardhigh_weight player.standardlow_bound1=player.roundWeight-Constants.standardlow_weight player.standardlow_bound2=player.roundWeight+Constants.standardlow_weight if player.standardhigh_bound1 <= player.Weight and player.Weight <= player.standardhigh_bound2: player.roundBonus_Weight=Constants.bonushigh elif player.standardlow_bound1 <= player.Weight and player.Weight <= player.standardlow_bound2: player.roundBonus_Weight=Constants.bonuslow else: player.roundBonus_Weight=Constants.bonusnull if player.round_number == 1: player.cumulativeBonus_Weight = player.roundBonus_Weight else: player.cumulativeBonus_Weight=player.in_round(player.round_number-1).cumulativeBonus_Weight + player.roundBonus_Weight class MyPage_WeightResult(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number>=1 and player.round_number<=10 class MyPage_Overprecision1(Page): form_model = 'player' form_fields = ['Zero_right', 'right1_wrong9', 'right2_wrong8', 'right3_wrong7', 'right4_wrong6', 'right5_wrong5', 'right6_wrong4', 'right7_wrong3', 'right8_wrong2', 'right9_wrong1', 'right10'] @staticmethod def is_displayed(player): return player.round_number==10 @staticmethod def before_next_page(player, timeout_happened): participant = player.participant player.totalprobability = player.Zero_right + player.right1_wrong9 + player.right2_wrong8 + player.right3_wrong7 + player.right4_wrong6 + player.right5_wrong5 + player.right6_wrong4 + player.right7_wrong3 + player.right8_wrong2 + player.right9_wrong1 + player.right10 participant.vars['totalprobability'] = player.totalprobability class MyPage_TemperatureGuess(Page): form_model = 'player' form_fields = ['Temperature'] @staticmethod def is_displayed(player): return player.round_number>=11 @staticmethod def vars_for_template(player): session = player.session subsession = player.subsession DateInRound(subsession) player.roundDate=subsession.Date return dict() @staticmethod def before_next_page(player, timeout_happened): session = player.session subsession = player.subsession participant = player.participant TemperatureInRound(subsession) DateInRound(subsession) player.roundTemperature = subsession.Temperature player.roundDate = subsession.Date player.standardhigh_bound1=player.roundTemperature-Constants.standardhigh_temperature player.standardhigh_bound2=player.roundTemperature+Constants.standardhigh_temperature player.standardlow_bound1=player.roundTemperature-Constants.standardlow_temperature player.standardlow_bound2=player.roundTemperature+Constants.standardlow_temperature player.totalprobability= participant.vars['totalprobability'] if player.standardhigh_bound1 <= player.Temperature and player.Temperature <= player.standardhigh_bound2: player.roundBonus_Temperature=Constants.bonushigh elif player.standardlow_bound1 <= player.Temperature and player.Temperature <= player.standardlow_bound2: player.roundBonus_Temperature=Constants.bonuslow else: player.roundBonus_Temperature=Constants.bonusnull if player.round_number == 11: player.cumulativeBonus_Temperature = player.roundBonus_Temperature player.cumulativeBonus = player.roundBonus_Temperature + player.in_round(10).cumulativeBonus_Weight else: player.cumulativeBonus_Temperature = player.in_round(player.round_number-1).cumulativeBonus_Temperature + player.roundBonus_Temperature player.cumulativeBonus = player.in_round(player.round_number-1).cumulativeBonus + player.roundBonus_Temperature class MyPage_TemperatureResult(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number>=11 @staticmethod def before_next_page(player, timeout_happened): participant = player.participant participant.vars['cumulativeBonus'] = player.cumulativeBonus participant.vars['cumulativeBonus_Temperature'] = player.cumulativeBonus_Temperature class FinalPage(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number==Constants.num_rounds @staticmethod def before_next_page(player, timeout_happened): participant = player.participant player.totalprobability= participant.vars['totalprobability'] player.cumulativeBonus = participant.vars['cumulativeBonus'] player.cumulativeBonus_Temperature = participant.vars['cumulativeBonus_Temperature'] page_sequence = [Test_Instructions_continue, Understanding_Test, MyPage_WeightGuess, MyPage_WeightResult, MyPage_Overprecision1, MyPage_TemperatureGuess, MyPage_TemperatureResult, FinalPage]