from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 show_up = cu(3.5) bonus_belief = cu(1) bonus_RE = cu(6) # XXX to decide completion_code = "C13TKYYD" class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): selected_task = models.StringField() payoff_task = models.CurrencyField() @staticmethod def set_payment(player): import random rng = random.Random() task = rng.choice(["Unusual Uses Task 1", "Unusual Uses Task 2", "Unusual Uses Task 3", "Group Project"]) player.selected_task = task # Determine payoff by task selection: if task == "Unusual Uses Task 1": player.payoff_task = player.participant.vars["RE_1_payoff"] if task == "Unusual Uses Task 2": player.payoff_task = player.participant.vars["RE_2_payoff"] if task == "Unusual Uses Task 3": player.payoff_task = player.participant.vars["RE_3_payoff"] if task == "Group Project": player.payoff_task = player.participant.vars["PG_payoff"] player.payoff = player.payoff_task + C.show_up gender = models.IntegerField( choices=[[1, 'Male'], [2, 'Female'], [3, 'Other/Rather not say']], label="What is your gender?", widget=widgets.RadioSelect, ) age = models.IntegerField(min=18, max=100, label="What is your age?" ) education = models.IntegerField( choices=[[1, 'No formal qualifications'], [2, 'Secondary education'], [3, 'High school diploma/A-levels'], [4, 'Technical/Community college'], [5, 'Undergraduate degree (BA/BSc/other)'], [6, 'Graduate degree (MA/MSc/MPhil/other)'], [7, 'Doctoral degree (PhD/other)'], [8, "Don't know/not applicable"]], label="Which of these is the highest level of education you have completed?", ) income = models.IntegerField( choices=[[1, 'Less than \x2410,000'], [2, '\x2410,000 - \x2419,999'], [3, '\x2420,000 - \x2429,999'], [4, '\x2430,000 - \x2439,999'], [5, '\x2440,000 - \x2449,999'], [6, '\x2450,000 - \x2459,999'], [7, '\x2460,000 - \x2469,999'], [8, '\x2470,000 - \x2479,999'], [9, '\x2480,000 - \x2489,999'], [10, '\x2490,000 - \x2499,999'], [11, '\x24100,000 - \x24149,999'], [12, 'More than \x24150,000'], [13, 'Rather not say']], label="What is your personal income per year (after tax) in USD?", ) children = models.IntegerField( label="Do you have any children?", choices=[[1, 'Yes'], [2, 'No']], widget=widgets.RadioSelect ) religion = models.IntegerField( label="Do you consider yourself religious or spiritual?", choices=[[1, 'Yes'], [2, 'No'], [3, 'Rather not say']], widget=widgets.RadioSelect ) politic = models.IntegerField( label="Generally speaking, where do you place yourself on the left-right political spectrum?", choices=[[1, 'Left'], [2, 'Center-left'], [3, 'Center'], [4, 'Center-right'], [5, 'Right'], [7, 'Rather not say']], widget=widgets.RadioSelect ) nationality = models.IntegerField( label="What is your nationality?", choices=[[1, 'Australia'], [2, 'Austria'], [3, 'Belgium'], [4, 'Canada' ], [5, 'Chile'], [6, 'Czech Republic'], [7, 'Denmark'], [8, 'Estonia'], [9, 'Finland'], [10, 'France'], [11, 'Germany'], [12, 'Greece'], [13, 'Hungary'], [14, 'Iceland'], [15, 'Ireland'], [16, 'Israel'], [17, 'Italy'], [18, 'Japan'], [19, 'Korea'], [20, 'Latvia'], [21, 'Luxembourg'], [22, 'Mexico'], [23, 'Netherlands'], [24, 'New Zealand'], [25, 'Norway'], [26, 'Poland'], [27, 'Portugal'], [28, 'Slovenia'], [29, 'South Africa'], [30, 'Spain'], [31, 'Sweden'], [32, 'Switzerland'], [33, 'United Kingdom'], [34, 'United States'], [35, 'other']] ) control_questionnaire = models.IntegerField( label="It is important that you pay attention during this study. Please choose 'Agree' in this question to prove that you are still attentive.", choices=[[1, 'Strongly agree'], [2, 'Agree'], [3, 'Neither agree nor disagree'], [4, 'Disagree'], [5, 'Strongly disagree'], [6, "Don't know"]], widget=widgets.RadioSelect ) donation_survey = models.IntegerField( ) keep_survey = models.IntegerField( ) willing_give_survey = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], widget=widgets.RadioSelect, ) risk = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7, 8,9,10,11], widget=widgets.RadioSelect, ) student = models.BooleanField( label = "Are you a student?" ) fun = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7], widget=widgets.RadioSelect, ) creative = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7], widget=widgets.RadioSelect, ) difficult = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7], widget=widgets.RadioSelect, ) misreport = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7], widget=widgets.RadioSelect, ) compete = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7], widget=widgets.RadioSelect, ) comments = models.LongStringField( blank=True, label="Do you have any additional comments, questions, or concerns regarding the study? (optional)" ) fair_process = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7], widget=widgets.RadioSelect ) belief_number_referee = models.IntegerField( label="", choices=[[1, 'More misreporting if one participant rates performance'], [2, 'More misreporting if two participants rate performance'], [3, "Similar rate of misreporting"]], widget = widgets.RadioSelect ) belief_transparent = models.IntegerField( label="", choices=[[1, 'More misreporting if review process is transparent'], [2, 'More misreporting if review process is non-transparent'], [3, "Similar rate of misreporting"]], widget=widgets.RadioSelect ) # PAGES class PaymentOverview(Page): @staticmethod def before_next_page(player, timeout_happened): player.set_payment(player) def vars_for_template(player: Player): return dict( RE_1_payoff = player.participant.vars["RE_1_payoff"], RE_2_payoff=player.participant.vars["RE_2_payoff"], RE_3_payoff=player.participant.vars["RE_3_payoff"], PG_payoff=player.participant.vars["PG_payoff"], PG_contribution = player.participant.vars["PG_contribution"], PG_individual_share = player.participant.vars['individual_share'], PG_keep = player.participant.vars['PG_keep'], RE_1_rank = player.participant.vars["RE_1_rank"], RE_2_rank=player.participant.vars["RE_2_rank"], RE_3_rank=player.participant.vars["RE_3_rank"], RE_1_belief = player.participant.vars['RE_1_belief'], RE_2_belief = player.participant.vars['RE_2_belief'], RE_3_belief = player.participant.vars['RE_3_belief'], ) class Thanks(Page): pass class Survey1(Page): form_model = 'player' form_fields = ['fair_process', 'fun', 'creative', 'difficult', 'misreport', 'belief_number_referee', 'belief_transparent'] class Survey2(Page): form_model = 'player' form_fields = ['donation_survey', 'keep_survey', 'willing_give_survey', 'risk', 'compete'] class Survey3(Page): form_model = 'player' form_fields = ['gender', 'age', 'children', 'politic', 'control_questionnaire', 'education', 'income', 'religion', 'nationality', 'student', 'comments'] page_sequence = [Survey1, Survey2, Survey3, PaymentOverview, Thanks]