from otree.api import * import data as dt import scripts as sc # dog for emotional support doc = """ |\_/| | @ @ Woof! | <> _ | _/\------____ ((| |)) | `--' | ____|_ ___| |___.' /_/_____/____/_______| """ class C(BaseConstants): NAME_IN_URL = 'Questionnaire_effort' # experiment needs two person groups PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 # make a budget so can change it later if we have to class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField(label='What is your age?', min=10, max=125) payment_id_m = models.StringField() payoff_zhang = models.CurrencyField() payoff_ming = models.CurrencyField() app2 = models.IntegerField(min=1, max=2) date_payment = models.StringField() gender = models.StringField( choices=[[1, 'Male'], [2, 'Female'], [3, 'Other'], [4, 'Prefer not to tell']], label='What is your gender?', widget=widgets.RadioSelect, ) nationality = models.StringField(choices=dt.list_of_countries, label='Nationality') education = models.StringField( choices=[[1, 'State exam or diploma'], [2, 'High School'], [3, 'Bachelor'], [4, 'Master'], [5, 'Doctoral']], label='The highest degree you completed' ) major = models.StringField( choices=[[1, 'Social Science'], [2, 'Natural Science'], [3, 'Formal Science'], [4, 'Other'], [5, 'Prefer not to tell']], label='What is your major?' ) living_cost = models.IntegerField( label='How much money do you have available to spend per month after paying for rent? (€)', min=10, ) budget = models.IntegerField( label='How much money is your monthly budget?', min=10, ) rich_or_poor=models.IntegerField( choices=[[1, 'Richer than me'], [2, 'Poorer than me'], [3, 'Similar to me'], [4, 'I have no idea']], label='Do you think your peers are richer or poorer than you?', widget=widgets.RadioSelect ) income_father = models.StringField( choices=[[1, 'less than 1000 €'], [2, '1001~2000 €'], [3, '2001~3000 €'], [4, '3001~4000 €'], [5, '4001~5000 €'], [6, '5001~6000 €'], [7, '6001~7000 €'], [8, 'more than 7000 €'], [9, 'I have no idea']], label='How much does your father earn one month?', widget=widgets.RadioSelect ) income_mother = models.StringField( choices=[[1, 'less than 1000 €'], [2, '1001~2000 €'], [3, '2001~3000 €'], [4, '3001~4000 €'], [5, '4001~5000 €'], [6, '5001~6000 €'], [7, '6001~7000 €'], [8, 'more than 7000 €'], [9, 'I have no idea']], label='How much does your mother earn one month?', widget=widgets.RadioSelect ) education_father = models.StringField( choices=[[1, 'Mandatory schooling'], [2, 'Vocational training'], [3, 'High-School'], [4, 'University (Bachelor/Master Degree)'], [5, 'University (PhD)'], [6, 'I have no idea']], label='What is the education of father?', widget=widgets.RadioSelect ) job_father = models.StringField( choices=[[1, 'full-time job'], [2, 'part-time job'], [3, 'currently not employed'], [4, 'retired'], [5, 'I have no idea']], label='The occupation of father', widget=widgets.RadioSelect ) education_mother = models.StringField( choices=[[1, 'Mandatory schooling'], [2, 'Vocational training'], [3, 'High-School'], [4, 'University (Bachelor/Master Degree)'], [5, 'University (PhD)'], [6, 'I have no idea']], label='What is the education of mother?', widget=widgets.RadioSelect ) job_mother = models.StringField( choices=[[1, 'full-time job'], [2, 'part-time job'], [3, 'currently not employed'], [4, 'retired'], [5, 'I have no idea']], label='The occupation of mother', widget=widgets.RadioSelect ) class Instruction(Page): pass class Questionnaire(Page): form_model = 'player' form_fields = ['age', 'gender', 'nationality', 'education', 'major', 'budget', 'living_cost', 'rich_or_poor','income_father', 'income_mother', 'education_father', 'job_father', 'education_mother', 'job_mother'] @staticmethod def is_displayed(player: Player): return player.id_in_group == player.id_in_group @staticmethod def before_next_page(player: Player, timeout_happened): player.payoff = (player.participant.payoff_UG + player.participant.payoff_inequality) * 0.5 player.participant.payoff_zhang = (player.participant.payoff_UG + player.participant.payoff_inequality) * 0.5 player.payoff_zhang = round((player.participant.payoff_UG + player.participant.payoff_inequality) * 0.5, 1) player.payoff_ming = player.participant.payoff2 * 0.5 + 3.0 if player.payoff_zhang == 0: player.payoff_zhang = 3.0 @staticmethod def app_after_this_page(player: Player, upcoming_apps): player.app2 = player.participant.app1 player.participant.payment_id = sc.name_gen_LC(8) player.payment_id_m = player.participant.payment_id class DecisionWaitPage(WaitPage): pass class Payment_zero1(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 1 and player.participant.payoff2 == 0: player.date_payment = 'tomorrow' return player.id_in_group == player.id_in_group class Payment_zero2(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 2 and player.participant.payoff2 == 0: player.date_payment = 'tomorrow' return player.id_in_group == player.id_in_group class Payment_soon8(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 1 and player.participant.payoff2 == 8: player.date_payment = 'tomorrow' return player.id_in_group == player.id_in_group class Payment_future12(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 1 and player.participant.payoff2 == 12: player.date_payment = 'four weeks later' return player.id_in_group == player.id_in_group class Payment_future4(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 1 and player.participant.payoff2 == 4: player.date_payment = 'four weeks later' return player.id_in_group == player.id_in_group class Payment_soon82(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 2 and player.participant.payoff2 == 8: player.date_payment = 'tomorrow' return player.id_in_group == player.id_in_group class Payment_soon4(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 2 and player.participant.payoff2 == 4: player.date_payment = 'tomorrow' return player.id_in_group == player.id_in_group class Payment_soon12(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.field_maybe_none('app2') == 2 and player.participant.payoff2 == 12: player.date_payment = 'tomorrow' return player.id_in_group == player.id_in_group page_sequence = [Questionnaire, Payment_future4, Payment_future12, Payment_soon4, Payment_soon8, Payment_soon12, Payment_soon82, Payment_zero1, Payment_zero2]