from ._builtin import Page, WaitPage from .models import Constants import json import random #################################################### ###################### PART 1 ###################### #################################################### # General Information for participants class Introduction(Page): form_model = 'player' form_fields = ['consent', 'recontact', 'recontact_1'] # def before_next_page(self): # self.player.drawing_ball() # # Instructions part 1 # class Intro_part_1(Page): # pass # Group Assignment class GroupAssignment(Page): #timeout_seconds = 10 #timer_text = 'Time to continue:' def vars_for_template(self): return dict( group_=self.player.minimal_group, ) # def before_next_page(self): # self.player.passing_order() # # Guessing the urn based on the drawn Ball # class BayesianGuess(Page): # form_model = 'player' # form_fields = ['urn_guess'] # # def vars_for_template(self): # return dict( # ball_=self.player.ball, # ) # # def before_next_page(self): # self.player.passing_bayesian_game() # OvO for Minimal Groups class OvoNeutral(Page): form_model = 'player' form_fields = ['ovo_neutral_both_triangle_p1', 'ovo_neutral_both_circle_p1', 'ovo_neutral_different_circle'] # def before_next_page(self): # self.player.out_to_in_group() def vars_for_template(self): return dict( group_=self.player.minimal_group, order_=self.participant.vars['neut_o'] ) class PolicyQuestions1(Page): form_model = 'player' form_fields = ['republican_1'] # Policy Questions class PolicyQuestions1_1(Page): form_model = 'player' def get_form_fields(self): if (self.player.republican_1 == 1) | (self.player.republican_1 == 2): return ['republican_2'] else: return ['republican_3'] class PolicyQuestions1_2(Page): form_model = 'player' form_fields = ['climate_change', 'cohen_plea', 'fire_arm', 'immigrant_crime', 'obama_wiretap', 'voter_fraud' ] random.shuffle(form_fields) # form_fields = ['climate_change', # 'cohen_plea', # 'fire_arm', # 'immigrant_crime', # 'obama_wiretap', # 'voter_fraud', # 'unemployment', # 'abortion', # 'racial_eq', # 'gender_eq', # 'law_order', # 'islamophobia', # 'immigration', # 'leader', # 'anti_est', # 'pol_corr', # 'health_ins', # 'env_pol', # 'media_trust', # 'global_env', # 'soc_eq', # 'gun_law', # 'redistr', # 'wealth_tax', # 'lgbt', # 'republican', # 'election_outcome_electoral', # 'election_outcome_popular'] class PolicyQuestions2(Page): form_model = 'player' # adapt the randomization here art this point form_fields = ['election_outcome_electoral', 'election_outcome_popular', 'econ_measure_biden', 'econ_measure_trump', 'health_measure_biden', 'health_measure_trump'] def vars_for_template(self): return dict( order_=self.participant.vars['first_q'], ) # passing priors across apps def before_next_page(self): self.player.passing_priors() self.player.drawing_ball() # OvO for Policy groups class OvoPolicy(Page): form_model = 'player' form_fields = ['ovo_pol_both_dem_p1', 'ovo_pol_both_rep_p1', 'ovo_pol_different_dem'] def vars_for_template(self): return dict( order_=self.participant.vars['pol_o'], ) def app_after_this_page(self, upcoming_apps): if self.participant.vars['processing_first'] == 1: return elif self.participant.vars['processing_first'] == 0: return upcoming_apps[1] ########################################## ##### APP SEQUENCE ##### ########################################## test = [Introduction, GroupAssignment, OvoNeutral, PolicyQuestions1, PolicyQuestions1_1, PolicyQuestions1_2, PolicyQuestions2, OvoPolicy] page_sequence = test