from ._builtin import Page, WaitPage from .models import Constants import json import random ######################## ## INTRO ## ######################## class Introduction(Page): def before_next_page(self): self.player.prior_decisions() ######################## ## RESULTS ## ######################## class Results(Page): def vars_for_template(self): return dict( income=self.participant.vars['income_guess'], control=self.participant.vars['control_correct'], bonus=self.participant.vars['bonus'], pay=int(self.participant.payoff) ) ######################## ## PRIOR PAYOFF REVELATION ## ######################## class PriorPayoffs(Page): def vars_for_template(self): return dict( income_health=self.participant.vars['income_health'], income_econ=self.participant.vars['income_econ'], answer_health=self.participant.vars['health_guess'], answer_econ=self.participant.vars['econ_guess'], income=self.participant.vars['income_guess'] ) # def before_next_page(self): # self.player.drawing_ball() ######################## ## GROUP ASSIGNMENT ## ######################## class GroupAssignment(Page): def vars_for_template(self): return dict( group=self.player.minimal_group ) ######################## ## OVO MINIMAL ## ######################## 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_order'] ) ######################## ## HAS YOUR LEVEL OF POLITICAL LEANING CHANGED? ## ######################## class PolicyQuestionsChangeIdent(Page): form_model = 'player' form_fields = ['change_pol_ident'] ######################## ## IF CHANGE == 1 ## ## PARTY AFFILIATION QUESTIONS ## ######################## class PolicyQuestionsLeaning(Page): #def is_displayed(self): # return self.player.change_pol_ident == 1 form_model = 'player' form_fields = ['republican_1'] class PolicyQuestionsStrength(Page): #def is_displayed(self): # return self.player.change_pol_ident == 1 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'] def before_next_page(self): self.player.party_aff() ######################## ## VACCINATION RELATED ## ######################## class PolicyQuestionsVaccine1(Page): form_model = 'player' form_fields = ['vacc1'] random.shuffle(form_fields) class PolicyQuestionsVaccine2(Page): def is_displayed(self): return (self.player.vacc1 == 2) | (self.player.vacc1 == 3) form_model = 'player' def get_form_fields(self): if (self.player.vacc1 == 3): return ['vacc1_1'] else: return ['vacc1_2'] ######################## ## STATE IDENTIFICATION ## ######################## class StateIdentification(Page): form_model = 'player' form_fields = ['ident_state'] ######################## ## AFFECTIVE POLARIZATION ## ######################## class PolicyQuestionsAffective1(Page): form_model = 'player' form_fields = ['aff5', 'aff6', 'aff7'] def vars_for_template(self): return dict( aff5='How comfortable are you having close personal friends who are {}s?'.format(self.participant.vars['party_aff'][2]), aff6='How comfortable are you having neighbors on your street who are {}s?'.format(self.participant.vars['party_aff'][2]), aff7='Suppose a daughter or son of yours was getting married. How would you feel if she/ he married a supporter of the {} party?'.format(self.participant.vars['party_aff'][3]) ) class PolicyQuestionsTemperature(Page): form_model = 'player' form_fields = ['aff9D', 'aff9R'] def vars_for_template(self): return dict( ord_=random.randint(0,1) ) class PolicyQuestionsAffective2D(Page): form_model = 'player' # FORMFIELDS l_d = [] for i in range(10, 19, 1): l_d.append('aff' + str(i) + 'D') form_fields = l_d class PolicyQuestionsAffective2R(Page): form_model = 'player' l_r = [] for i in range(10, 19, 1): l_r.append('aff' + str(i) + 'R') form_fields = l_r # vars['party_aff'] = ('Democrat', 'Democratic', 'Republican', 'Republican') class PolicyQuestionsAffective3(Page): form_model = 'player' form_fields = ['aff1', 'aff2', 'aff3', 'aff4', 'aff8'] # def get_form_fields(self): # if (self.player.republican_1 == 1) | (self.player.republican_3 == 1): # return ['aff1', 'aff2', 'aff3', 'aff4', 'aff8'] # else: # return ['aff1', 'aff2', 'aff3', 'aff4', 'aff8R'] def vars_for_template(self): return dict( aff1_label='How important is being a {} to you?'.format(self.participant.vars['party_aff'][0]), aff2_label='How well does the term {} describe you?'.format(self.participant.vars['party_aff'][0]), aff3_label='When talking about the {} party, how often do you use ‘we’ instead of ‘they’?'.format(self.participant.vars['party_aff'][1]), aff4_label='To what extent do you think of yourself as a {}?'.format(self.participant.vars['party_aff'][0]), aff8_label='You are a {} because you are more:'.format(self.participant.vars['party_aff'][0]) ) # # aff8_label = 'You are a {} because you are for what the {} party represents, or are you more against what the {} party represents?'.format( # self.participant.vars['party_aff'][0], # self.participant.vars['party_aff'][1], # self.participant.vars['party_aff'][3]) # def vars_for_template(self): # return dict( # aff1='How important is being a {} to you?'.format(self.participant.vars['party_aff'][0]), # aff2='How well does the term {} describe you?'.format(self.participant.vars['party_aff'][0]), # aff3='When talking about the {} party, how often do you use ‘we’ instead of ‘they’?'.format(self.participant.vars['party_aff'][1]), # aff4='To what extent do you think of yourself a being a {}?'.format(self.participant.vars['party_aff'][0]), # dem_=((self.player.republican_1 == 1) | (self.player.republican_3 == 1)) # ) ######################## ## OTHER QUESTIONS ## ######################## class MaskPri(Page): form_model = 'player' form_fields = ['mask_prior'] class MaskInfo(Page): pass class ArticleRating(Page): form_model = 'player' form_fields = ['skew', 'reliance'] random.shuffle(form_fields) class MaskPost(Page): form_model = 'player' form_fields = ['mask_post'] def vars_for_template(self): return dict( prior=self.player.mask_prior, ) def before_next_page(self): self.player.ControlQuestion() class MaskControl(Page): form_model = 'player' form_fields = ['mask_control'] class MaskTrustScience(Page): form_model = 'player' form_fields = ['science_trust'] class News1(Page): form_model = 'player' form_fields = ['zip_code', 'status_dem', 'status_rep', 'abc', 'cnn', 'fox', 'local', 'msnbc', 'npr', 'magazines', 'face', 'twit', 'other'] class News2(Page): def is_displayed(self): return self.player.magazines == 1 form_model = 'player' form_fields = ['economist', 'nyt', 'wsj', 'wash_ex', 'wash_pos', 'nature', 'science', 'other_2' ] ######################## ## OTHER QUESTIONS ## ######################## class IdentityQuestions(Page): form_model = 'player' form_fields = ['ident_race', 'ident_gender', 'ident_political', 'ident_us', 'ident_state2'] random.shuffle(form_fields) class Rosen(Page): form_model = 'player' form_fields = ['rosen_1', 'rosen_2', 'rosen_3', 'rosen_4', 'rosen_5', 'rosen_6', 'rosen_7', 'rosen_8', 'rosen_9', 'rosen_10',] random.shuffle(form_fields) class DigFoot(Page): form_model = 'player' form_fields = ['dig_foot1', 'dig_foot2', 'dig_foot3', 'dig_foot4', 'dig_foot5', 'dig_foot6'] random.shuffle(form_fields) ######################## ## OVO STATE ## ######################## class OvoState(Page): form_model = 'player' form_fields = ['ovo_state_both_in', 'ovo_state_both_out', 'ovo_state_different_in'] def vars_for_template(self): return dict( order_=self.participant.vars['pol_order'], ) ######################## ## OVO POLICY ## ######################## 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_order'], ) # 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] # ######################## # ## RATIONALITY GUESSES ## # ######################## # class RationalityGuess(Page): # form_model = 'player' # form_fields = ['dem_correct_guess', # 'rep_correct_guess'] # random.shuffle(form_fields) # # def before_next_page(self): # self.player.rationality_guess() # # ######################## # ## RATIONALITY RESULTS ## # ## ONLY OBSERVED FOR TREAT == 1 ## # ######################## # class RationalityGuessResults(Page): # def is_displayed(self): # return self.player.treatment == 1 # def vars_for_template(self): # return dict( # dem_guess=self.player.dem_correct_guess, # rep_guess=self.player.rep_correct_guess # ) ########################################## ##### APP SEQUENCE ##### ########################################## temp1 = [Introduction, GroupAssignment, OvoNeutral, PolicyQuestionsChangeIdent, PolicyQuestionsLeaning, PolicyQuestionsStrength, PolicyQuestionsVaccine1, PolicyQuestionsVaccine2, PolicyQuestionsAffective1, PolicyQuestionsTemperature] temp2 = [PolicyQuestionsAffective2D, PolicyQuestionsAffective2R] random.shuffle(temp2) temp3 = [PolicyQuestionsAffective3, OvoPolicy, IdentityQuestions, StateIdentification, Rosen, News1, News2, MaskPri, MaskInfo, ArticleRating, MaskControl, MaskTrustScience, MaskPost, DigFoot, OvoState, PriorPayoffs, Results] page_sequence = temp1 + temp2 + temp3 # page_sequence = [Introduction, # GroupAssignment, # OvoNeutral, # PolicyQuestionsChangeIdent, # PolicyQuestionsLeaning, # PolicyQuestionsStrength, # PolicyQuestionsVaccine, # PolicyQuestionsAffective, # OtherQuestions, # OvoPolicy]