from otree.api import * doc = """ Just a simple survey (UK) that includes baseline demographics and simple attention checks. """ def attention_checks(label): return models.IntegerField( choices=[ [1, ''], [2, ''], [3, ''], [4, ''], [5, ''], ], label=label, widget=widgets.RadioSelectHorizontal ) class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField( label="How old are you?" ) gender = models.IntegerField( choices=[ [1, "Male"], [2, "Female"], [3, "Other"] ], widget=widgets.RadioSelect, label="What is your gender identity?" ) gender_3_TEXT = models.StringField( blank=True, label="If you selected OTHER above, please indicate how you would like to be identified in the text box below:" ) politics = models.StringField( choices=[ ['Alliance Party', 'Alliance Party'], ['Conservative Party', 'Conservative Party'], ['Co-operative Party', 'Co-operative Party'], ['Democratic Unionist Party', 'Democratic Unionist Party'], ['Green Party', 'Green Party'], ['Labour Party', 'Labour Party'], ['Liberal Democratic Party', 'Liberal Democratic Party'], ['Plaid Cymru', 'Plaid Cymru'], ['Scottish National Party', 'Scottish National Party'], ['Sinn Fein', 'Sinn Fein'], ['Social Democratic and Labour Party', 'Social Democratic and Labour Party'], ['None of the Above', 'None of the Above'], ], widget=widgets.RadioSelect(), label="Which of the political parties do you think most align with your personal values?" ) edu = models.StringField( choices=[ ['Completed some high school', 'Completed some high school'], ['High school graduate or GED equivalent', 'High school graduate or GED equivalent'], ['Completed some college', 'Completed some college'], ['Associates degree', 'Associates degree'], ['College degree', 'College degree'], ['Masters degree', 'Masters degree'], ['Doctorate degree', 'Doctorate degree'], ['None of the above', 'None of the above'] ], widget=widgets.RadioSelect(), label="What is the highest level education you have completed?" ) inc = models.StringField( choices=[ ['Less than £10,000', 'Less than £10,000'], ['£10,000 to £14,999', '£10,000 to £14,999'], ['£15,000 to £24,999', '£15,000 to £24,999'], ['£25,000 to £34,999', '£25,000 to £34,999'], ['£35,000 to £49,999', '£35,000 to £49,999'], ['£50,000 to £74,999', '£50,000 to £74,999'], ['£75,000 to £99,999', '£75,000 to £99,999'], ['£100,000 to £149,999', '£100,000 to £149,999'], ['£150,000 to £199,999', '£150,000 to £199,999'], ['£200,000 or more', '£200,000 or more'], ], widget=widgets.RadioSelect(), label="What was your total household income in 2022?" ) hh_num = models.IntegerField( label="How many individuals lived in your household in 2022?" ) careful = attention_checks("I made my decisions in this study carefully.") random = attention_checks("I made the decisions in this study randomly.") understood_pay = attention_checks("I understood what my decisions meant for the payment of myself and the other workers.") left = attention_checks("Please check the option that is on the far left.") right = attention_checks("Please check the option that is on the far right.") # PAGES class SurveyStart(Page): pass class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'gender_3_TEXT', 'politics', 'edu', 'inc', 'hh_num'] class AttCheck(Page): form_model = 'player' form_fields = ['careful', 'random', 'understood_pay', 'left', 'right'] class SurveyEnd(Page): pass page_sequence = [SurveyStart, Demographics, AttCheck, SurveyEnd]