from otree.api import * import random doc = """ PS3 - Belief Elicitation """ class C(BaseConstants): NAME_IN_URL = 'PS3' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 base_payment = cu(10) zero_payment = cu(0) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): answer_1 = models.BooleanField( label="Please choose who you think will win", choices = [ [True, "Gaethje"], [False, "Chandler"], ] ) confidence_1 = models.IntegerField( label = "On a scale of 1 to 10, how confident are you in your answer?", choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal ) reward_1 = models.CurrencyField() answer_2 = models.BooleanField( label="Please choose who you think will win", choices = [ [True, "Rodriguez"], [False, "Emmet"], ] ) confidence_2 = models.IntegerField( label = "On a scale of 1 to 10, how confident are you in your answer?", choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal ) reward_2 = models.CurrencyField() answer_3 = models.BooleanField( label="Please choose who you think will win", choices = [ [True, "Wineland"], [False, "O'Malley"], ] ) confidence_3 = models.IntegerField( label = "On a scale of 1 to 10, how confident are you in your answer?", choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal ) reward_3 = models.CurrencyField() # PAGES class Introduction(Page): pass class Page_1(Page): form_model = "player" form_fields = ["answer_1", "confidence_1"] class Result_1(Page): @staticmethod def vars_for_template(player: Player): if player.answer_1: player.reward_1 = C.base_payment else: player.reward_1 = C.zero_payment class Page_2(Page): form_model = "player" form_fields = ["answer_2", "confidence_2"] class Result_2(Page): @staticmethod def vars_for_template(player: Player): if player.answer_2: player.reward_2 = C.base_payment else: player.reward_2 = C.zero_payment class Page_3(Page): form_model = "player" form_fields = ["answer_3", "confidence_3"] class Result_3(Page): @staticmethod def vars_for_template(player: Player): if player.answer_3: player.reward_3 = C.zero_payment else: player.reward_3 = C.base_payment class Combined_Results(Page): @staticmethod def vars_for_template(player: Player): player.payoff = player.reward_1 + player.reward_2 + player.reward_3 page_sequence = [Introduction, Page_1, Result_1, Page_2, Result_2, Page_3, Result_3, Combined_Results]