from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Instructions(Page): pass class Survey1(Page): form_model = 'player' form_fields = [ 'age', 'gender', 'education', 'careers', 'identity', ] class MediaIntro(Page): pass class Sample1A(Page): def is_displayed(self): if self.player.media_treatment == 'neutral': return True timeout_seconds = 180 class Sample1B(Page): def is_displayed(self): if self.player.media_treatment == 'disc': return True timeout_seconds = 180 class Sample1C(Page): def is_displayed(self): if self.player.media_treatment == 'counter': return True timeout_seconds = 180 class Questions1(Page): form_model = 'player' form_fields = [ 's1q1', 's1q2', ] class Sample2A(Page): def is_displayed(self): if self.player.media_treatment == 'neutral': return True timeout_seconds = 180 class Sample2B(Page): def is_displayed(self): if self.player.media_treatment == 'disc': return True timeout_seconds = 180 class Sample2C(Page): def is_displayed(self): if self.player.media_treatment == 'counter': return True timeout_seconds = 180 class Questions2(Page): form_model = 'player' form_fields = [ 's2q1', 's2q2', ] class Sample3A(Page): def is_displayed(self): if self.player.media_treatment == 'neutral': return True timeout_seconds = 180 class Sample3B(Page): def is_displayed(self): if self.player.media_treatment == 'disc': return True timeout_seconds = 180 class Sample3C(Page): def is_displayed(self): if self.player.media_treatment == 'counter': return True timeout_seconds = 180 class Questions3(Page): form_model = 'player' form_fields = [ 's3q1', 's3q2', ] def before_next_page(self): for each in self.group.get_players(): print("calculating payoffs") each.set_payoffs() class MediaResult(Page): pass class Expressive1(Page): form_model = 'player' form_fields = ['expressive1'] class Expressive2(Page): def is_displayed(self): if self.player.expressive1 == 1: return True form_model = 'player' form_fields = ['expressive2'] class Expressive3(Page): def is_displayed(self): if self.player.expressive2 == 1: return True pass class Survey2(Page): form_model = 'player' form_fields = [ 'nascent', 'state_of_world', 'pol_characteristics' 'own_characteristics', 'opinion_samples', 'media_habits', 'most_people', ] def before_next_page(self): group = self.group players = group.get_players() for p in players: p.payoff = p.media_earnings class End(Page): pass page_sequence = [ Instructions, Survey1, MediaIntro, Sample1A, Sample1B, Sample1C, Questions1, Sample2A, Sample2B, Sample2C, Questions2, Sample3A, Sample3B, Sample3C, Questions3, MediaResult, Expressive1, Expressive2, Expressive3, Survey2, End ]