from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random from random import Random class Instructions(Page): form_model = 'player' def is_displayed(self): return self.player.round_number == 1 def vars_for_template(self): return {'n_questions': Constants.n_questions, 'n_sections': Constants.n_sections, 'n_pics': Constants.n_pics, 'bonus': Constants.bonus } class FirstOrderBeliefs(Page): form_model = 'player' def get_form_fields(self): all_fields = ['b1_wealth', 'b1_beauty', 'b1_health', 'b1_life', 'b1_self', 'b1_ability', 'b1_trust', 'b1_credit', 'b1_lend'] Random(4).shuffle(all_fields) return all_fields def vars_for_template(self): image = self.player.image age = self.player.img_age return {'img_to_show': image, 'age': age, 'round': self.player.round_number} class SecondOrderBeliefs(Page): form_model = 'player' def get_form_fields(self): all_fields = ['b2_wealth', 'b2_beauty', 'b2_health', 'b2_life', 'b2_self', 'b2_ability', 'b2_trust', 'b2_credit', 'b2_lend'] Random(4).shuffle(all_fields) return all_fields def before_next_page(self): for p in self.group.get_players(): p.set_payoff() def vars_for_template(self): image = self.player.image age = self.player.img_age return {'img_to_show': image, 'age': age, 'round': self.player.round_number} class Results(Page): form_model = 'player' def is_displayed(self): return self.player.round_number == 3 def vars_for_template(self): return { 'participation_fee': Constants.participation_fee, 'n_sections': Constants.n_sections, 'bonus': Constants.bonus } page_sequence = [ Instructions, FirstOrderBeliefs, SecondOrderBeliefs, Results ]