from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Redirectionpage(Page): pass class Thequestion(Page): def is_displayed(self): return self.participant.payoff > 1 form_model = 'player' form_fields = ['guess'] class Solution(Page): def is_displayed(self): return self.participant.payoff > 1 def before_next_page(self): p = self.player if p.guess == 6: p.cups = 1 else: p.cups = 0 class Lotteries(Page): def is_displayed(self): return self.participant.payoff > 1 form_model = 'player' form_fields = ['L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8'] class Lotteries2(Page): def is_displayed(self): return self.participant.payoff > 1 def vars_for_template(self): p = self.player lottery4 = [1, 2, 3, 4, 5, 6, 7, 8] p.real = random.choice(lottery4) p.bonusmoney = 0 if p.real == 1: p.lotaria = p.L1 p.win = 0.3 if p.real == 2: p.lotaria = p.L2 p.win = 0.5 if p.real == 3: p.lotaria = p.L3 p.win = 0.8 if p.real == 4: p.lotaria = p.L4 p.win = 1 if p.real == 5: p.lotaria = p.L5 p.win = 1.3 if p.real == 6: p.lotaria = p.L6 p.win = 1.5 if p.real == 7: p.lotaria = p.L7 p.win = 1.8 if p.real == 8: p.lotaria = p.L8 p.win = 2 return dict( lot=p.real ) class Lotteries3(Page): def is_displayed(self): return self.player.lotaria == 1 def vars_for_template(self): p = self.player lottery5 = [1, 2] p.outcomeofthelottery = random.choice(lottery5) if p.outcomeofthelottery == 1: p.bonusmoney = p.win else: p.bonusmoney = - 0.5 class Demographics1(Page): def is_displayed(self): return self.participant.payoff > 1 form_model = 'player' form_fields = ['age','gender','education','employment'] class FinalPage(Page): def is_displayed(self): return self.participant.payoff > 1 def vars_for_template(self): p = self.player return dict( geld=self.participant.payoff + p.cups + p.bonusmoney, ) class Results(Page): pass page_sequence = [Redirectionpage, Thequestion, Solution, Lotteries, Lotteries2, Lotteries3, Demographics1, FinalPage, Results]