from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) from django.forms.widgets import CheckboxSelectMultiple import random import time import itertools import json # likert scale def likert(label): return models.IntegerField( choices=[1,2,3,4,5,6,7], label=label, widget=widgets.RadioSelectHorizontal, ) races =[['African American','African American'], ['Asian/Asian American','Asian/Asian American'], ['White/Caucasian','White/Caucasian'], ['Hispanic/Latino','Hispanic/Latino'], ['Arab/Arab American','Arab/Arab American'], ['Native American','Native American'], ['Other','Other']] class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): # randomize to treatments for player in self.get_players(): # profile player.order = random.choice([1,2]) # self-control player.sc = random.choice(['low','control','high']) player.page_order = random.choice([0,1]) profiles = ['sk','mz'] sequences = [] sequences.append(profiles[player.page_order]) sequences.append(profiles[1-player.page_order]) pb = ['sona', 'consent', 'self', 'instruction1', 'instruction2', 'instruction3', 'instruction4', 'wait', 'view'] pb.extend(sequences) pb.extend(['pow_c', 'demo','native1', 'native2', 'probe', 'calculate']) player.page_sequence = json.dumps(pb) class Group(BaseGroup): pass class Player(BasePlayer): # randomization order = models.IntegerField() sc = models.StringField() page_order = models.IntegerField() page_sequence = models.StringField() def goal(self): if self.sc == 'low': return 'improve my swimming technique.' elif self.sc == 'control': return 'My goal is to' elif self.sc == 'high': return 'stay healthy and get at least 7 hours of sleep each day' # sona page sona = models.IntegerField(label = 'SONA ID') # self-introduction page initials = models.StringField(label = "Initials") major = models.StringField(label = "Major") food = models.StringField(label = "Favorite type of food") holiday = models.StringField(label = "Favorite holiday") goal2020 = models.LongStringField(label="What is your big goal for 2020?") eve = models.LongStringField(label = "What did you do last Thursday evening?") # instruction page ac1 = models.IntegerField( label = "Who will you evaluate in the first part?" #widget=widgets.RadioSelect ) def ac1_choices(self): choices = [[1, "Two other participants"], [2, "Another participant"], [3, "All the other participants in this Zoom room"]] random.shuffle(choices) return choices ac2 = models.IntegerField( label = "Who will work with you on the group task in the second part?" #widget=widgets.RadioSelect ) def ac2_choices(self): choices = [[1, "All the other participants in this Zoom room"], [2, "Two participants whom I evaluate in the first part"], [3, "Two participants I do not know about"]] random.shuffle(choices) return choices # wait page min_time = models.FloatField() # power conferral page sk_vote = models.IntegerField(label='SK', min=0, max=10) mz_vote = models.IntegerField(label='MZ', min = 0, max = 10) # power perception page sk_pow_p1 = likert('is powerful') sk_pow_p2 = likert('is independent') sk_pow_p3 = likert('is leader-like') sk_pow_p4 = likert('is influential') mz_pow_p1 = likert('is powerful') mz_pow_p2 = likert('is independent') mz_pow_p3 = likert('is leader-like') mz_pow_p4 = likert('is influential') # sk page sk_assert1 = likert('is confident') sk_assert2 = likert('is assertive') sk_assert3 = likert('never gives up easily') sk_assert4 = likert('is able to resist pressure') sk_auth1 = likert('is authentic') sk_auth2 = likert('is genuine') sk_auth3 = likert('is sincere') sk_warm1 = likert('is warm') sk_warm2 = likert('is friendly') sk_warm3 = likert('is caring') sk_warm4 = likert('is empathic') sk_warm5 = likert('is affectionate') sk_comp1 = likert('is competent') sk_comp2 = likert('is intelligent') sk_comp3 = likert('is capable') sk_comp4 = likert('is efficient') sk_comp5 = likert('is clever') sk_moral1 = likert('is trustworthy') sk_moral2 = likert('is just') sk_moral3 = likert('is fair') sk_moral4 = likert('is reliable') sk_moral5 = likert('is considerate') sk_sc1 = likert('has good self-control') sk_sc2 = likert('does things that are in line with his/her more important goals') # mz page mz_assert1 = likert('is confident') mz_assert2 = likert('is assertive') mz_assert3 = likert('never gives up easily') mz_assert4 = likert('is able to resist pressure') mz_auth1 = likert('is authentic') mz_auth2= likert('is genuine') mz_auth3 = likert('is sincere') mz_warm1 = likert('is warm') mz_warm2 = likert('is friendly') mz_warm3= likert('is caring') mz_warm4 = likert('is empathic') mz_warm5 = likert('is affectionate') mz_comp1 = likert('is competent') mz_comp2 = likert('is intelligent') mz_comp3 = likert('is capable') mz_comp4 = likert('is efficient') mz_comp5 = likert('is clever') mz_moral1 = likert('is trustworthy') mz_moral2 = likert('is just') mz_moral3 = likert('is fair') mz_moral4 = likert('is reliable') mz_moral5 = likert('is considerate') mz_sc1 = likert('has good self-control') mz_sc2 = likert('does things that are in line with his/her more important goals') # demographics page age = models.IntegerField(label='What is your age?', min=16, max=125) gender = models.StringField( choices=['Male', 'Female'], label='What is your gender?' ) race = models.StringField(label = "", widget = CheckboxSelectMultiple(choices = races), blank = True) native = models.IntegerField(label = 'Is English your native language?', choices = [[1, "Yes"],[0, "No"]]) # native language page 1 native_lan = models.StringField(label = "What is your native language?", blank = True) native_fluency = models.IntegerField(label = "Are you fluent in English?", choices = [[1,"Yes"],[2, "No"],[3, "I don't know / I am not sure"]], blank = True) # native language page 2 native_age = models.IntegerField(label = "At what age did you become fluent in English?", blank = True) # probe page purpose = models.LongStringField(label = "What do you think is the purpose of this study?") suspicion = models.LongStringField(label = "When you evaluated your fellow participants, did you find anything weird or suspicious? If so, please explain here.", blank = True) comment = models.LongStringField(label = "If you have any comments about the tasks you just did, please type them into the box below. Then click on the \"Next\" button to continue.", blank = True) # calculate page cal_time = models.FloatField()