from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'payment_game_calculationB' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 INSTRUCTIONS_TEMPLATE = 'payment_game_calculation/instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): value1 = models.PositiveIntegerField( initial=None ) value2 = models.PositiveIntegerField( initial=None ) smartphone3_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) smartphone3_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) applewatch3_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) applewatch3_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) dyson3_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) dyson3_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) macbook3_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) macbook3_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) smartphone12_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) smartphone12_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) applewatch12_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) applewatch12_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) dyson12_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) dyson12_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) macbook12_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) macbook12_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) smartphone24_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) smartphone24_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) applewatch24_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) applewatch24_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) dyson24_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) dyson24_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) macbook24_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) macbook24_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) smartphone36_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) smartphone36_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) applewatch36_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) applewatch36_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) dyson36_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) dyson36_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) macbook36_wtp_calculation = models.PositiveIntegerField(verbose_name='1回あたり支払可能な最高額を回答してください(単位:円)。', initial=None) macbook36_wtp_calculationResult = models.PositiveIntegerField(verbose_name='上記で回答した金額の総額を計算して回答してください。(単位:円)。', initial=None) def error_message(player, smartphone3_wtp_calculation, smartphone3_wtp_calculationResult): if smartphone3_wtp_calculationResult != smartphone3_wtp_calculation * 3: return "この答えは間違ってます。もう一度、計算してください。" #def smartphone3_wtp_calculationResult_error_message(player, smartphone3_wtp_calculationResult): #if smartphone3_wtp_calculationResult != player.smartphone3_wtp_calculation * 3: #return "この答えは間違ってます。もう一度、計算してください。" #def applewatch3_wtp_calculationResult_error_message(player, applewatch3_wtp_calculationResult): #if applewatch3_wtp_calculationResult != player.applewatch3_wtp_calculation * 3: #return "この答えは間違ってます。もう一度、計算してください。" # PAGES class Smartphone3(Page): form_model = 'player' form_fields = [ 'smartphone3_wtp_calculation', 'smartphone3_wtp_calculationResult', ] @staticmethod def before_next_page(player, timeout_happened): player.value1 = player.smartphone3_wtp_calculation player.value2 = player.smartphone3_wtp_calculationResult if player.smartphone3_wtp_calculationResult != player.smartphone3_wtp_calculation * 3: return "この答えは間違ってます。もう一度、計算してください。" def calculation_error_message(player, value1, value2): if player.value2 != player.value1 * 3: return "この答えは間違ってます。もう一度、計算してください。" class Smartphone12(Page): form_model = 'player' form_fields = [ 'smartphone12_wtp_calculation', 'smartphone12_wtp_calculationResult', ] class Smartphone24(Page): form_model = 'player' form_fields = [ 'smartphone24_wtp_calculation', 'smartphone24_wtp_calculationResult', ] class Smartphone36(Page): form_model = 'player' form_fields = [ 'smartphone36_wtp_calculation', 'smartphone36_wtp_calculationResult', ] #class Smartphone3Display(Page): #form_model = 'player' #form_fields = [ #'smartphone3_wtp_calculationResult', #] #@staticmethod #def is_displayed(player): #return player.offer_accepted == 0 #def before_next_page(self, timeout_happened): #self.smartphone3_wtp_calculationResult = self.smartphone3_wtp_calculation * 3 #if not self.offer_accepted: # いいえ(戻って修正する)が選択された場合、offer_accepted をリセットして同じページにリダイレクト #self.offer_accepted = 0 #self.smartphone3_wtp_calculationResult = None class applewatch3(Page): form_model = 'player' form_fields = [ 'applewatch3_wtp_calculation', 'applewatch3_wtp_calculationResult', ] class applewatch12(Page): form_model = 'player' form_fields = [ 'applewatch12_wtp_calculation', 'applewatch12_wtp_calculationResult', ] class applewatch24(Page): form_model = 'player' form_fields = [ 'applewatch24_wtp_calculation', 'applewatch24_wtp_calculationResult', ] class applewatch36(Page): form_model = 'player' form_fields = [ 'applewatch36_wtp_calculation', 'applewatch36_wtp_calculationResult', ] class dyson3(Page): form_model = 'player' form_fields = [ 'dyson3_wtp_calculation', 'dyson3_wtp_calculationResult', ] class dyson12(Page): form_model = 'player' form_fields = [ 'dyson12_wtp_calculation', 'dyson12_wtp_calculationResult', ] class dyson24(Page): form_model = 'player' form_fields = [ 'dyson24_wtp_calculation', 'dyson24_wtp_calculationResult', ] class dyson36(Page): form_model = 'player' form_fields = [ 'dyson36_wtp_calculation', 'dyson36_wtp_calculationResult', ] class macbook3(Page): form_model = 'player' form_fields = [ 'macbook3_wtp_calculation', 'macbook3_wtp_calculationResult', ] class macbook12(Page): form_model = 'player' form_fields = [ 'macbook12_wtp_calculation', 'macbook12_wtp_calculationResult', ] class macbook24(Page): form_model = 'player' form_fields = [ 'macbook24_wtp_calculation', 'macbook24_wtp_calculationResult', ] class macbook36(Page): form_model = 'player' form_fields = [ 'macbook36_wtp_calculation', 'macbook36_wtp_calculationResult', ] class instructionsA(Page): pass class instructionsB(Page): pass class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [ instructionsB, Smartphone3, applewatch3, dyson3, macbook3, Smartphone12, applewatch12, dyson12, macbook12, Smartphone24, applewatch24, dyson24, macbook24, Smartphone36, applewatch36, dyson36, macbook36, ]