from otree.api import * doc = """  このアプリは〇〇のために作成。 """ class C(BaseConstants): NAME_IN_URL = 'Sample' PLAYERS_PER_GROUP = 3 NUM_ROUNDS = 1 ENDOWMENT = 100 MULTIPLY = 2 class Subsession(BaseSubsession): pass class Group(BaseGroup): total_contribution = models.IntegerField() individual_share = models.IntegerField() class Player(BasePlayer): age = models.IntegerField(label='あなたの年齢をお書きください') name = models.StringField(label='あなたの名前をお書きください') Q1 = models.IntegerField(label='あなたの好きな音楽ジャンルはなんですか', choices=[[1,'ロック'],[2,'クラシック'],[3,'ラップ'],[4,'メタル'],[5,'テクノ']], widget = widgets.RadioSelect) decision1 = models.IntegerField(label='公共財に投資しますか?', min = 0, max = C.ENDOWMENT) # FUNCTION def set_payoffs(group): players = group.get_players() contributions = [p.decision1 for p in players] group.total_contribution = sum(contributions) group.individual_share = int(group.total_contribution*C.MULTIPLY/C.PLAYERS_PER_GROUP) for player in players: player.payoff = C.ENDOWMENT - player.decision1 + group.individual_share # PAGES class MyPage(Page): form_model = 'player' form_fields = ['decision1'] class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class Results(Page): pass class Question(Page): form_model = 'player' form_fields = ['age','name','Q1'] page_sequence = [Question]