from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random import json class part5(Page): form_model = 'player' class demographic1(Page): form_model = 'player' form_fields = ['race', 'state', 'education', 'marital_status', 'dependent', 'household_income', 'health_insurance_co', 'access_to_healthcare', 'past_mammogram', 'employment'] class demographic2(Page): form_model = 'player' def get_form_fields(self): cond1 = (self.player.past_mammogram != 1) cond2 = (self.player.employment != 0) cond3 = (self.player.health_insurance_co != 0) if (cond1 and cond2 and cond3): return ['mammogram_behavior', 'mammogram_frequency', 'health_insurance', 'employment_sector', 'paid_sick_leave_avail'] elif (not cond1 and cond2 and cond3): return ['health_insurance', 'employment_sector', 'paid_sick_leave_avail'] elif (cond1 and not cond2 and cond3): return ['mammogram_behavior', 'mammogram_frequency', 'health_insurance'] elif (cond1 and cond2 and not cond3): return ['mammogram_behavior', 'mammogram_frequency', 'employment_sector', 'paid_sick_leave_avail'] elif (not cond1 and not cond2 and cond3): return ['health_insurance'] elif (not cond1 and cond2 and not cond3): return ['employment_sector', 'paid_sick_leave_avail'] else: return ['mammogram_behavior', 'mammogram_frequency'] def is_displayed(self): cond1 = (self.player.past_mammogram != 1) cond2 = (self.player.employment != 0) cond3 = (self.player.health_insurance_co != 0) return (cond1 or cond2 or cond3) class demographic3(Page): form_model = 'player' def get_form_fields(self): cond1 = (self.player.paid_sick_leave_avail != 0) cond2 = (self.player.past_mammogram != 1) if (cond1 and cond2): return ['paid_sick_leave2', 'paid_sick_leave4'] elif (not cond1 and cond2): return ['paid_sick_leave2', 'paid_sick_leave3'] else: return ['paid_sick_leave2'] def is_displayed(self): cond2 = (self.player.employment != 0) return (cond2) class numeracy(Page): form_model = 'player' form_fields = [ 'numeracy1', 'numeracy2', 'numeracy3', 'numeracy4' ] class health_anxiety(Page): form_model = 'player' form_fields = [ 'ha1', 'ha2', 'ha3', 'ha4', 'ha5' ] class risk_attitude(Page): form_model = 'player' form_fields = ['risk_preference'] page_sequence = [part5, demographic1, demographic2, demographic3, health_anxiety, numeracy, risk_attitude]