from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, ) import random from django import forms import numpy as np from captcha.fields import ReCaptchaField from captcha.widgets import ReCaptchaV2Checkbox author = 'Elisa Macchi' doc = """ MTurk Survey to Test for BMI Perception: Introduction, Consent Form and Captcha """ class Constants(BaseConstants): name_in_url = 'survey_mturk_bmi_intro' players_per_group = None num_rounds = 1 # Consent consent_template = 'survey_mturk_bmi_intro/consent_template.html' code = 'XXX' consent_timeout = int(600) startwp_timer = 600 # Time time = 30 # Characteristics n_questions = 120 n_sections = 5 # Payoffs: participation_fee = c(3) bonus = c(0.03) max_bonus = c(3) race_choices = [["White", "White"], ["Asian", "Asian"], ["Black or African American", "Black or African American"], ["Native Hawaiian or Pacific Islander", "Native Hawaiian or Pacific Islander"], ["Hispanic or Latino", "Hispanic or Latino"], ["Other", "Other"]] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): attention_check_4july = models.IntegerField(choices=[[1, 'Independence day'], [2, 'Halloween'], [3, 'Nothing'], [4, 'International coffee day'], ], widget=widgets.RadioSelectHorizontal, label='''What do we celebrate on the Fourth of July?''' ) consent = models.BooleanField(widget=forms.CheckboxInput, initial=False ) is_dropout = models.BooleanField(default=False) ip = models.StringField() captcha = models.CharField(blank=True) qualified = models.BooleanField() state = models.IntegerField(choices=[[1, "AL"], [2, "AK"], [3, "AZ"], [4, "AR"], [5, "CA"], [6, "CO"], [7, "CT"], [8, "DE"], [9, "FL"], [10, "GA"], [11, "HI"], [12, "ID"], [13, "IL"], [14, "IN"], [15, "IA"], [16, "KS"], [17, "KY"], [18, "LA"], [19, "ME"], [20, "MD"], [21, "MA"], [22, "MI"], [23, "MN"], [24, "MS"], [25, "MO"], [26, "MT"], [27, "NE"], [28, "NV"], [29, "NH"], [30, "NJ"], [31, "NM"], [32, "NY"], [33, "NC"], [34, "ND"], [35, "OH"], [36, "OK"], [37, "OR"], [38, "PA"], [39, "RI"], [40, "SC"], [41, "SD"], [42, "TN"], [43, "TX"], [44, "UT"], [45, "VT"], [46, "VA"], [47, "WA"], [48, "WV"], [49, "WI"], [50, "WY"]], label='''In which state do you live?''') yob = models.IntegerField(choices=range(2010, 1930, -1), label='''What is your year of birth?''' ) sex = models.BooleanField(choices=[[1, 'Male'], [0, 'Female'], [-66, 'Prefer not to say']], widget=widgets.RadioSelectHorizontal, label=''' What is your sex?''' ) marital_status = models.IntegerField(choices=[[1, 'Single'], [2, 'Married'], [3, 'Living as married'], [4, 'Separated'], [5, 'Divorced'], [6, 'Widowed']], widget=widgets.RadioSelectHorizontal, label=''' Which of the following best describes your current relationship status?''' ) household_composition = models.IntegerField(min=0, max=20, label="How many individuals live in your household?") personal_income = models.CurrencyField(choices=[[1, "Less than $10,000"], [2, "$10,000 to $14,999"], [3, "$15,000 to $19,999"], [4, "$20,000 to $29,999"], [5, "$30,000 to $34,999"], [6, "$35,000 to $39,999"], [7, "$40,000 to $44,999"], [8, "$45,000 to $49,999"], [9, "$50,000 to $54,999"], [10, "$55,000 to $59,999"], [11, "$60,000 to $64,999"], [12, "$65,000 to $69,999"], [13, "$70,000 to $74,999"], [14, "$75,000 to $79,999"], [15, "$80,000 to $84,999"], [16, "$85,000 to $89,999"], [17, "$90,000 to $94,999"], [18, "$95,000 to $99,999"], [19, "$100,000 to $149,999"], [20, "More than $150,000"]], label=''' Information about income is very important to understand. Would you please give us your best guess? Please indicate the answer that includes your personal income in 2019 before taxes.''') race = models.StringField(widget= forms.widgets.CheckboxSelectMultiple(choices=Constants.race_choices), label ='''Choose one or more races that you consider yourself to be:''') education = models.IntegerField(choices=[[1, 'Primary school'], [2, 'Secondary school'], [3, 'Technical/Vocational training'], [4, 'Some College'], [5, 'Bachelor Degree'], [6, 'Masters Degree'], [7, 'Post-graduate degree'], [8, 'None of the above']], widget=widgets.RadioSelect, label=''' What is the highest level of education you have completed?''' ) height_feet = models.FloatField(choices=range(4, 9, 1), label = "Feet:") height_inches = models.FloatField(choices=range(0, 10, 1), label = "Inches:") weight = models.IntegerField( label=''' What is your weight in pounds? Please, provide your best guess.''')