from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) doc = """ This is a one-period public goods game with 3 players. """ class Constants(BaseConstants): name_in_url = 'public_goods' players_per_group = 2 num_rounds = 10 instructions_template = 'public_goods/instructions.html' # """Amount allocated to each player""" endowment = c(100) multiplier = 1.5 class Subsession(BaseSubsession): def creating_session(self): self.group_randomly() def vars_for_admin_report(self): contributions = [ p.contribution for p in self.get_players() if p.contribution != None ] if contributions: return dict( avg_contribution=sum(contributions) / len(contributions), min_contribution=min(contributions), max_contribution=max(contributions), ) else: return dict( avg_contribution='(no data)', min_contribution='(no data)', max_contribution='(no data)', ) class Group(BaseGroup): total_contribution = models.CurrencyField() individual_share = models.CurrencyField() def set_payoffs(self): self.total_contribution = sum([p.contribution for p in self.get_players()]) self.individual_share = ( self.total_contribution * Constants.multiplier / Constants.players_per_group ) for p in self.get_players(): p.payoff = (Constants.endowment - p.contribution) + self.individual_share class Player(BasePlayer): contribution = models.CurrencyField( choices=[0, 25, 50, 75, 100], widget=widgets.RadioSelect, min=0, max=Constants.endowment, doc="""The amount contributed by the player""" ) test_1 = models.BooleanField( label="解答", choices =[ [False,"〇"], [True,"×"], [False,"わからない"], ] ) test_2 = models.BooleanField( label="解答", choices =[ [True,"〇"], [False,"×"], [False,"わからない"], ] ) test_3 = models.BooleanField( label="解答", choices =[ [False,"0"], [False,"1"], [True,"10"], [False,"5"], [False,"4"], [False,"3"], [False,"8"], [False,"わからない"] ] ) test_4 = models.BooleanField( label="解答", choices =[ [False,"〇"], [True,"×"], ] ) test_5 = models.BooleanField( label="解答", choices =[ [False,"0"], [True, "5"], [False,"3"], [False,"1"], [False,"4"], ] ) test_6 = models.BooleanField( label="解答", choices=[ [True, "1"], [False, "2"], [False, "3"], [False, "4"], [False, "5"], ] ) test_7 = models.BooleanField( label="解答", choices=[ [True, "0"], [False, "1"], [False, "2"], [False, "3"], [False, "4"], ] )