from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from django.templatetags.static import static from django import forms from django.core.validators import RegexValidator import random author = 'Clint McKenna cmck@umich.edu' doc = """ syllogism task taken from Kokis et al. (2002) """ # values for ethnicity checkbox ethnicityVals = ( ('white', 'European American/White'), ('black', 'African American/Black'), ('asian', 'Asian/Pacific Islander'), ('nativeAm', 'Native American/Alaska Native'), ('latino', 'Hispanic/Latino'), ('other', 'Other'), ('preferNot', 'Prefer not to respond'), ) class Constants(BaseConstants): name_in_url = 'syllogismMturk' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): conditions = ['aApp', 'iApp', 'aAvd', 'iAvd'] for p in self.get_players(): p.condition = random.choice(conditions) class Group(BaseGroup): pass class Player(BasePlayer): # WSC vars # experimental condition condition = models.StringField() # word stem completions # action approach w1_aApp = models.StringField(label='A _ T I O N', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) w2_aApp = models.StringField(label='D O I N _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w3_aApp = models.StringField(label='E N G A G _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) w4_aApp = models.StringField(label='G _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{2}$', message='Length has to be 2', code='nomatch')]) w5_aApp = models.StringField(label='M A K _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{4}$', message='Length has to be 4', code='nomatch')]) w6_aApp = models.StringField(label='A D V _ N C E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{7}$', message='Length has to be 7', code='nomatch')]) w7_aApp = models.StringField(label='P _ R S U E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) w8_aApp = models.StringField(label='_ T T A C K', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) # inaction approach w1_iApp = models.StringField(label='C _ L M', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{4}$', message='Length has to be 4', code='nomatch')]) w2_iApp = models.StringField(label='N _ T I C E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) w3_iApp = models.StringField(label='A L L _ W', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w4_iApp = models.StringField(label='F _ C U S', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w5_iApp = models.StringField(label='S T _ L L', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w6_iApp = models.StringField(label='R E C _ G N I Z E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{9}$', message='Length has to be 9', code='nomatch')]) w7_iApp = models.StringField(label='C _ N S I D E R', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{8}$', message='Length has to be 8', code='nomatch')]) w8_iApp = models.StringField(label='O B S E R _ E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{7}$', message='Length has to be 7', code='nomatch')]) # action avoid w1_aAvd = models.StringField(label='_ V O I D', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w2_aAvd = models.StringField(label='E S C A _ E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) w3_aAvd = models.StringField(label='E V A D _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w4_aAvd = models.StringField(label='_ E T R E A T', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{7}$', message='Length has to be 7', code='nomatch')]) w5_aAvd = models.StringField(label='W _ T H D R A W A L', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{10}$', message='Length has to be 10', code='nomatch')]) w6_aAvd = models.StringField(label='S I D E _ T E P', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{8}$', message='Length has to be 8', code='nomatch')]) w7_aAvd = models.StringField(label='E L U D _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w8_aAvd = models.StringField(label='D I S E N _ A G E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{9}$', message='Length has to be 9', code='nomatch')]) # inaction avoid w1_iAvd = models.StringField(label='I N A C T I O _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{8}$', message='Length has to be 8', code='nomatch')]) w2_iAvd = models.StringField(label='P A U S _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) w3_iAvd = models.StringField(label='F R E _ Z E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) w4_iAvd = models.StringField(label='U N _ B L E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) w5_iAvd = models.StringField(label='S T _ P', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{4}$', message='Length has to be 4', code='nomatch')]) w6_iAvd = models.StringField(label='P A R A L Y Z _ D', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{9}$', message='Length has to be 9', code='nomatch')]) w7_iAvd = models.StringField(label='A B S T A I _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{7}$', message='Length has to be 7', code='nomatch')]) w8_iAvd = models.StringField(label='D I S M _ S S', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{7}$', message='Length has to be 7', code='nomatch')]) # filler words f1 = models.StringField(label='C _ O S E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) f2 = models.StringField(label='C _ T', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{3}$', message='Length has to be 3', code='nomatch')]) f3 = models.StringField(label='M O O _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{4}$', message='Length has to be 4', code='nomatch')]) f4 = models.StringField(label='S U _', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{3}$', message='Length has to be 3', code='nomatch')]) f5 = models.StringField(label='A L L _ G _ T O R', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{9}$', message='Length has to be 9', code='nomatch')]) f6 = models.StringField(label='_ E A _ H E R', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{7}$', message='Length has to be 7', code='nomatch')]) f7 = models.StringField(label='H _ R D', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{4}$', message='Length has to be 4', code='nomatch')]) f8 = models.StringField(label='S _ U D _ N T', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{7}$', message='Length has to be 7', code='nomatch')]) f9 = models.StringField(label='W H I _ E', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) f10 = models.StringField(label='P _ N C I L', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{6}$', message='Length has to be 6', code='nomatch')]) f11 = models.StringField(label='P L _ N T', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{5}$', message='Length has to be 5', code='nomatch')]) f12 = models.StringField(label='D _ S K', blank=True, widget=forms.TextInput(attrs={'autofocus': 'autofocus'}), validators=[RegexValidator(regex='^.{4}$', message='Length has to be 4', code='nomatch')]) # syllogism tasks s1 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) s2 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) s3 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) s4 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) s5 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) s6 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) s7 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) s8 = models.StringField( choices=['Yes', 'No'], label='', blank=True, widget=widgets.RadioSelect ) # demographics age = models.StringField(label='What is your age in years?', blank=True) gender = models.StringField( choices=[ 'Female', 'Male', 'Other', ], widget=widgets.RadioSelect, label='To which gender do you most identify?', blank=True ) genderOther = models.StringField(label='If you indicated \"other\" for gender identification, please specify:', blank=True) ethnicity = models.StringField( widget=forms.CheckboxSelectMultiple( choices=ethnicityVals ), label=' ', blank=True ) ethnicityOther = models.StringField(label='If you indicated \"other\" for ethnicity, please specify:', blank=True) eduYear = models.StringField( choices=[ 'Some High School', 'High School Graduate', 'Some College', '4-Year College Graduate (B.A. or B.S.)', 'Graduate or Professional School (M.D., J.D., Ph.D.', 'Don\'t know/Prefer not to respond', ], widget=widgets.RadioSelect, label='What is the highest level of education you have attained?', blank=True ) politics = models.StringField( choices=[ 'Very Liberal', 'Liberal', 'Slightly Liberal', 'Moderate/Middle-of-the-road', 'Slightly Conservative', 'Conservative', 'Very Conservative', 'Don\'t know/Not political', 'Libertarian', 'Other', ], widget=widgets.RadioSelect, label='When it comes to politics, do you usually think of yourself as liberal, moderate, conservative, or something else?', blank=True ) party = models.StringField( choices=[ 'Republican', 'Democrat', 'Independent', 'Something else', 'Don\'t know/Not political', ], widget=widgets.RadioSelect, label='Generally speaking, do you usually think of yourself as a Republican, a Democrat, an Independent, or something else?', blank=True ) studyFeedback = models.LongStringField(label='Is there any feedback you would like to provide about the study, or clarify any responses you provided?', widget=widgets.Textarea, blank=True) honesty = models.StringField( choices=[ 'yes', 'no', ], widget=widgets.RadioSelect, label='As researchers, the quality of our data is very important to us, so we want to make sure that your responses are valid and authentic. In your honest opinion, should we use your data?', blank=True )