from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Pres_Beef(Page): pass class Pres_Croc(Page): pass class Eat_Decision(Page): form_model = 'player' form_fields = ['decision'] def before_next_page(self): self.player.meat_draw = random.randint(0, 1) if self.player.decision == 1 and self.player.meat_draw == 1: self.player.decision_string = "You have chosen to eat meat and the computer has also drawn that you eat meat." \ " You will thus eat both meats." elif self.player.decision == 1 and self.player.meat_draw == 0: self.player.decision_string = "You have chosen to eat meat but the computer has drawn that you do not eat meat." \ " You will thus not eat meat. The experiment still continues." else: self.player.decision_string = "You have chosen not to eat meat. You will thus not eat meat. " \ "The experiment still continues." if self.player.decision == 0 or self.player.meat_draw == 0: self.participant.vars['lottery_no_meat'] += 1 class Eat_Result(Page): pass page_sequence = [Pres_Beef, Pres_Croc, Eat_Decision, Eat_Result]