from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'Survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): CRT1 = models.FloatField(label='1. 一个球拍和一个球总共需要1.10元,球拍比球贵1元,那么球需要多少钱?(请填写数字)') CRT2 = models.FloatField(label='2. 如果5台机器制造5个零件需要5分钟,那么100台机器造100个零件需要多少分钟?(请填写数字)') CRT3 = models.FloatField(label='3. 湖里有一片睡莲,每天睡莲的面积都会翻一倍,如果睡莲占据整个湖面需要48天,那么睡莲占据湖面的一半需要多少天?(请填写数字)') Research_purpose = models.LongStringField(label='4. 您认为这项实验研究是关于什么的?') Belief_of_fee = models.IntegerField(choices=[[1, '是'], [2, '否']], label='5. 您是否相信您的选择会影响您的实验报酬?', widget=widgets.RadioSelect) belief_of_emission_reduction = models.IntegerField(choices=[[1, '是'], [2, '否']], label='6. 您是否相信实验中对于碳汇的承诺会被真实地执行? ', widget=widgets.RadioSelect) gender = models.IntegerField(choices=[[1, '男'], [2, '女']], label='7. 您的性别?', widget=widgets.RadioSelect) age = models.IntegerField(label='8. 您的年龄?', max=100, min=0) education = models.IntegerField(choices=[[1, '本科'], [2, '硕士'], [3, '博士']], label='9. 您目前在读? ', widget=widgets.RadioSelect) wage = models.IntegerField(choices=[[1, '1万以下'], [2, '1-2万'], [3, '2-3万'], [4, '3-4万'], [5, '4万以上']], label='10. 您的家庭月收入水平?', widget=widgets.RadioSelectHorizontal) major = models.StringField(label='11. 您的专业?') investment_experiment = models.IntegerField(label='12. 您有多少年的投资经验?(请填写整数年份)') investment_frequency = 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'], [11, '11'], [12, '12'], [13, '13'], [14, '14 经常']], label='13. 您是否经常进行投资? ') ininvestment_plan = models.IntegerField(choices=[[1, '有'], [2, '没有']], label='14. 接下来五年内您有投资计划吗? ', widget=widgets.RadioSelect) earnings_weighted = 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'], [11, '11'], [12, '12'], [13, '13'], [14, '14 非常重要']], label='15. 在进行投资决策时,项目的预期收益对您来说有多重要?') carbon_emission_weighted = 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'], [11, '11'], [12, '12'], [13, '13'], [14, '14 非常重要']], label='16. 在进行投资决策时,项目的二氧化碳排放量对您来说有多重要? ') ESG_consciousness1 = models.IntegerField(choices=[[1, '是'], [2, '否']], label='17. 您听说过绿色投资、可持续投资、社会责任投资或ESG投资吗?', widget=widgets.RadioSelect) ESG_consciousness2 = models.IntegerField(choices=[[1, '是'], [2, '否']], label='18. 您在投资时是否关注过投资对象在二氧化碳排放等环境相关方面的表现?', widget=widgets.RadioSelect) Code = models.IntegerField(label='请实验人员输入验证码') Chosenquestion = models.IntegerField() dividend = models.IntegerField(initial=0) carbon_reduction = models.IntegerField(initial=0) bid = models.IntegerField(initial=0) price = models.IntegerField(initial=0) win = models.IntegerField(initial=0) buy = models.IntegerField(initial=0) class Survey(Page): form_model = 'player' form_fields = ['CRT1', 'CRT2', 'CRT3', 'Research_purpose', 'Belief_of_fee', 'belief_of_emission_reduction', 'gender', 'age', 'education', 'wage', 'major', 'investment_experiment', 'investment_frequency', 'ininvestment_plan', 'earnings_weighted', 'carbon_emission_weighted', 'ESG_consciousness1', 'ESG_consciousness2'] class Ending(Page): form_model = 'player' class Security(Page): form_model = 'player' form_fields = ['Code'] @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant import random player.Chosenquestion=random.randint(1,2) if player.Chosenquestion==1: player.dividend=player.participant.vars['task2_question1_dividend'] player.carbon_reduction=player.participant.vars['task2_question1_carbon_reduction'] player.bid=participant.vars['task2_question1'] player.price=participant.vars['task2_question1_price'] player.win=participant.vars['task2_question1_win'] player.buy=participant.vars['task2_question1_buy'] else: player.dividend=player.participant.vars['task2_question2_dividend'] player.carbon_reduction=player.participant.vars['task2_question2_carbon_reduction'] player.bid=participant.vars['task2_question2'] player.price=participant.vars['task2_question2_price'] player.win=participant.vars['task2_question2_win'] player.buy=participant.vars['task2_question2_buy'] @staticmethod def error_message(player: Player, values): if values['Code'] != 2468 : return '验证码错误!' class Payoff_task2(Page): form_model = 'player' page_sequence = [Survey, Ending, Security, Payoff_task2]