from otree.api import * import random doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'control1' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): pass class Group(BaseGroup): pass class Player(BasePlayer): total_payoff = models.FloatField() ExNo = models.IntegerField(label="Enter your experimental number as shown on your desk:") dis3_1 = models.FloatField() dis3_2 = models.FloatField() dis0_1 = models.FloatField() dis0_2 = models.FloatField() dis03_1 = models.FloatField() dis03_2 = models.FloatField() payoff_1 = models.IntegerField() payoff_2 = models.FloatField() CQ_1 = models.StringField( label="How will you be paid by the whole study?", choices=[ ['A', 'Fixed payment and the payment for one randomly selected task.'], ['B', 'Fixed payment and the payments for two tasks.'], ], widget=widgets.RadioSelect ) CQ_2 = models.StringField( label="How will you be paid for Part 1?", choices=[ ['A', '$Y, which is fixed.'], ['B', '$Y, different participants may be paid differently.'], ], widget=widgets.RadioSelect ) CQ_3 = models.StringField( label="What's your payment for Part 2?", choices=[ ['A', '$X, which is fixed.'], ['B', '$X, which depends on your allocation decisions.'], ], widget=widgets.RadioSelect ) CQ_4 = models.StringField( label="How will recipients get paid?", choices=[ ['A', 'Your choice for a random scenario.'], ['B', 'Your choice based on the actual scenario they will experience in a later session.'], ], widget=widgets.RadioSelect ) # PAGES class MyPage(Page): form_model = 'player' form_fields = ['ExNo'] # A Page can have any of the 4 functions, is_displayed(), vars_for_template(), # before_next_page(), timeout_seconds class Part1(Page): pass class CQ1(Page): form_model = 'player' form_fields = ['CQ_1', 'CQ_2'] def error_message(player, value): if value['CQ_1'] != "B": return "Try again." if value['CQ_2'] != 'A': return "Try again." class count1(Page): pass class count2(Page): pass class count3(Page): pass class count4(Page): pass class count5(Page): pass class count6(Page): pass class count7(Page): pass class count8(Page): pass class count9(Page): pass class count10(Page): pass class Part2(Page): pass class CQ2(Page): form_model = 'player' form_fields = ['CQ_3', 'CQ_4'] def error_message(player, value): if value['CQ_3'] != "A": return "Try again." if value['CQ_4'] != 'B': return "Try again." class Allocation(Page): form_model = 'player' form_fields = ['dis3_1', 'dis3_2', 'dis0_1', 'dis0_2', 'dis03_1', 'dis03_2'] class EndPage(Page): pass page_sequence = [MyPage, Part1, CQ1, count1, count2, count3, count4, count5, count6, count7, count8, count9, count10, Part2, CQ2, Allocation, EndPage]