from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'Assignment2' PLAYERS_PER_GROUP = None NUM_ROUNDS = 5 MY_CONSTANT = cu(5) PAY_OFF_ES = cu(5) class Subsession(BaseSubsession): pass def my_function(subsession: Subsession): pass class Group(BaseGroup): pass def Value(group: Group): pass class Player(BasePlayer): guess = models.IntegerField(label='Your guess', max=60, min=0) Value_of_asset = models.IntegerField(label="Ismaeil's real income") Probability = models.FloatField(label='What is the percentage chance that farm A product is 3kg?', max=10, min=10) MAxincome = models.IntegerField(label="What is Esmaeil's maximum possible income in each year?", max=60) Email = models.LongStringField() def my_function(player: Player): pass class Introduction(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number==1 class Comprehensiontest(Page): form_model = 'player' form_fields = ['Probability', 'MAxincome'] @staticmethod def is_displayed(player: Player): return player.round_number==1 class Forecast(Page): form_model = 'player' form_fields = ['guess'] @staticmethod def vars_for_template(player: Player): import random AVALUE=random.randint(0,10) BVALUE = random.randint(0, 10) CVALUE = random.randint(0, 10) player.Value_of_asset=3*AVALUE+2*BVALUE+CVALUE return{ "Wheat product":AVALUE, "Bean product": BVALUE, "Corn product":CVALUE } @staticmethod def before_next_page(player: Player, timeout_happened): if abs(player.guess-player.Value_of_asset)<11: player.payoff=C.PAY_OFF_ES else: player.payoff =0 class Result(Page): form_model = 'player' form_fields = ['guess', 'Value_of_asset'] class MyWaitPage(WaitPage): pass class FinalResult(Page): form_model = 'player' form_fields = ['Email'] @staticmethod def is_displayed(player: Player): return player.round_number==C.NUM_ROUNDS @staticmethod def vars_for_template(player: Player): all_players=player.in_all_rounds() combined_payoff=0 for temp_player in all_players: combined_payoff += temp_player.payoff return dict(combined_payoff=combined_payoff,b=1+1) page_sequence = [Introduction, Comprehensiontest, Forecast, Result, MyWaitPage, FinalResult]