from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = '_Questionnaire' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def all_countries(label): return models.StringField( label=label, initial='', choices= [ ('Afghanistan', 'Afghanistan'), ('Albania', 'Albania'), ('Algeria', 'Algeria'), ('Andorra', 'Andorra'), ('Angola', 'Angola'), ('Antigua & Deps', 'Antigua & Deps'), ('Argentina', 'Argentina'), ('Armenia', 'Armenia'), ('Australia', 'Australia'), ('Austria', 'Austria'), ('Azerbaijan', 'Azerbaijan'), ('Bahamas', 'Bahamas'), ('Bahrain', 'Bahrain'), ('Bangladesh', 'Bangladesh'), ('Barbados', 'Barbados'), ('Belarus', 'Belarus'), ('Belgium', 'Belgium'), ('Belize', 'Belize'), ('Benin', 'Benin'), ('Bhutan', 'Bhutan'), ('Bolivia', 'Bolivia'), ('Bosnia Herzegovina', 'Bosnia Herzegovina'), ('Botswana', 'Botswana'), ('Brazil', 'Brazil'), ('Brunei', 'Brunei'), ('Bulgaria', 'Bulgaria'), ('Burkina', 'Burkina'), ('Burundi', 'Burundi'), ('Cambodia', 'Cambodia'), ('Cameroon', 'Cameroon'), ('Canada', 'Canada'), ('Cape Verde', 'Cape Verde'), ('Central African Rep', 'Central African Rep'), ('Chad', 'Chad'), ('Chile', 'Chile'), ('China', 'China'), ('Colombia', 'Colombia'), ('Comoros', 'Comoros'), ('Congo', 'Congo'), ('Congo {Democratic Rep}', 'Congo {Democratic Rep}'), ('Costa Rica', 'Costa Rica'), ('Croatia', 'Croatia'), ('Cuba', 'Cuba'), ('Cyprus', 'Cyprus'), ('Czech Republic', 'Czech Republic'), ('Denmark', 'Denmark'), ('Djibouti', 'Djibouti'), ('Dominica', 'Dominica'), ('Dominican Republic', 'Dominican Republic'), ('East Timor', 'East Timor'), ('Ecuador', 'Ecuador'), ('Egypt', 'Egypt'), ('El Salvador', 'El Salvador'), ('Equatorial Guinea', 'Equatorial Guinea'), ('Eritrea', 'Eritrea'), ('Estonia', 'Estonia'), ('Ethiopia', 'Ethiopia'), ('Fiji', 'Fiji'), ('Finland', 'Finland'), ('France', 'France'), ('Gabon', 'Gabon'), ('Gambia', 'Gambia'), ('Georgia', 'Georgia'), ('Germany', 'Germany'), ('Ghana', 'Ghana'), ('Greece', 'Greece'), ('Grenada', 'Grenada'), ('Guatemala', 'Guatemala'), ('Guinea', 'Guinea'), ('Guinea-Bissau', 'Guinea-Bissau'), ('Guyana', 'Guyana'), ('Haiti', 'Haiti'), ('Honduras', 'Honduras'), ('Hungary', 'Hungary'), ('Iceland', 'Iceland'), ('India', 'India'), ('Indonesia', 'Indonesia'), ('Iran', 'Iran'), ('Iraq', 'Iraq'), ('Ireland {Republic}', 'Ireland {Republic}'), ('Israel', 'Israel'), ('Italy', 'Italy'), ('Ivory Coast', 'Ivory Coast'), ('Jamaica', 'Jamaica'), ('Japan', 'Japan'), ('Jordan', 'Jordan'), ('Kazakhstan', 'Kazakhstan'), ('Kenya', 'Kenya'), ('Kiribati', 'Kiribati'), ('Korea North', 'Korea North'), ('Korea South', 'Korea South'), ('Kosovo', 'Kosovo'), ('Kuwait', 'Kuwait'), ('Kyrgyzstan', 'Kyrgyzstan'), ('Laos', 'Laos'), ('Latvia', 'Latvia'), ('Lebanon', 'Lebanon'), ('Lesotho', 'Lesotho'), ('Liberia', 'Liberia'), ('Libya', 'Libya'), ('Liechtenstein', 'Liechtenstein'), ('Lithuania', 'Lithuania'), ('Luxembourg', 'Luxembourg'), ('Macedonia', 'Macedonia'), ('Madagascar', 'Madagascar'), ('Malawi', 'Malawi'), ('Malaysia', 'Malaysia'), ('Maldives', 'Maldives'), ('Mali', 'Mali'), ('Malta', 'Malta'), ('Marshall Islands', 'Marshall Islands'), ('Mauritania', 'Mauritania'), ('Mauritius', 'Mauritius'), ('Mexico', 'Mexico'), ('Micronesia', 'Micronesia'), ('Moldova', 'Moldova'), ('Monaco', 'Monaco'), ('Mongolia', 'Mongolia'), ('Montenegro', 'Montenegro'), ('Morocco', 'Morocco'), ('Mozambique', 'Mozambique'), ('Myanmar, {Burma}', 'Myanmar, {Burma}'), ('Namibia', 'Namibia'), ('Nauru', 'Nauru'), ('Nepal', 'Nepal'), ('Netherlands', 'Netherlands'), ('New Zealand', 'New Zealand'), ('Nicaragua', 'Nicaragua'), ('Niger', 'Niger'), ('Nigeria', 'Nigeria'), ('Norway', 'Norway'), ('Oman', 'Oman'), ('Pakistan', 'Pakistan'), ('Palau', 'Palau'), ('Panama', 'Panama'), ('Papua New Guinea', 'Papua New Guinea'), ('Paraguay', 'Paraguay'), ('Peru', 'Peru'), ('Philippines', 'Philippines'), ('Poland', 'Poland'), ('Portugal', 'Portugal'), ('Qatar', 'Qatar'), ('Romania', 'Romania'), ('Russian Federation', 'Russian Federation'), ('Rwanda', 'Rwanda'), ('St Kitts & Nevis', 'St Kitts & Nevis'), ('St Lucia', 'St Lucia'), ('Saint Vincent & the Grenadines', 'Saint Vincent & the Grenadines'), ('Samoa', 'Samoa'), ('San Marino', 'San Marino'), ('Sao Tome & Principe', 'Sao Tome & Principe'), ('Saudi Arabia', 'Saudi Arabia'), ('Senegal', 'Senegal'), ('Serbia', 'Serbia'), ('Seychelles', 'Seychelles'), ('Sierra Leone', 'Sierra Leone'), ('Singapore', 'Singapore'), ('Slovakia', 'Slovakia'), ('Slovenia', 'Slovenia'), ('Solomon Islands', 'Solomon Islands'), ('Somalia', 'Somalia'), ('South Africa', 'South Africa'), ('South Sudan', 'South Sudan'), ('Spain', 'Spain'), ('Sri Lanka', 'Sri Lanka'), ('Sudan', 'Sudan'), ('Suriname', 'Suriname'), ('Swaziland', 'Swaziland'), ('Sweden', 'Sweden'), ('Switzerland', 'Switzerland'), ('Syria', 'Syria'), ('Taiwan', 'Taiwan'), ('Tajikistan', 'Tajikistan'), ('Tanzania', 'Tanzania'), ('Thailand', 'Thailand'), ('Togo', 'Togo'), ('Tonga', 'Tonga'), ('Trinidad & Tobago', 'Trinidad & Tobago'), ('Tunisia', 'Tunisia'), ('Turkey', 'Turkey'), ('Turkmenistan', 'Turkmenistan'), ('Tuvalu', 'Tuvalu'), ('Uganda', 'Uganda'), ('Ukraine', 'Ukraine'), ('United Arab Emirates', 'United Arab Emirates'), ('United Kingdom', 'United Kingdom'), ('United States', 'United States'), ('Uruguay', 'Uruguay'), ('Uzbekistan', 'Uzbekistan'), ('Vanuatu', 'Vanuatu'), ('Vatican City', 'Vatican City'), ('Venezuela', 'Venezuela'), ('Vietnam', 'Vietnam'), ('Yemen', 'Yemen'), ('Zambia', 'Zambia'), ('Zimbabwe', 'Zimbabwe'), ] ) def make_field(label): return models.IntegerField( choices=[[1, 'Strongly disagree'], [2, 'Disagree'], [3, 'Slightly disagree'], [4, 'Neutral'], [5, 'Slightly agree'], [6, 'Agree'], [7, 'Strongly agree']], label=label, widget=widgets.RadioSelect, ) class Player(BasePlayer): # ------ Questionnaire ------ # satisfaction_1 = make_field('Overall, I feel satisfied with my performance on this task.') satisfaction_2 = make_field('I feel satisfied with my performance on the task.') satisfaction_3 = make_field('I am happy with my performance on the task.') satisfaction_4 = make_field('I am pleased with my performance on the task.') self_determination_1 = make_field('I felt I was doing only what the researchers wanted me to do.') self_determination_2 = make_field('During the task, I felt I was doing what I wanted to be doing.') self_determination_3 = make_field('I felt I was pursuing goals that were my own.') self_determination_4 = make_field('During the task, I felt a relaxed sense of personal freedom.') self_determination_5 = make_field('During the task, I felt free.') self_determination_6 = make_field('During the task, I felt pressured.') self_determination_7 = make_field('I believe I had a choice over which task to try to solve.') self_determination_8 = make_field('I felt like it was my own choice as to which task to solve.') self_determination_9 = make_field('I felt that I had control to decide which task to solve.') ACQ_1 = make_field('Please select "Strongly agree" for this item.') ACQ_2 = make_field('Please select "Strongly agree" for this item.') boredom_1 = make_field('I found the task boring.') boredom_2 = make_field('During the task I thought about doing something else.') boredom_3 = make_field('I felt that the time went by slowly during the task.') autonomy_1 = make_field('I could determine myself how to conduct the tasks.') autonomy_2 = make_field('I have the opinion that I had some freedom of choice regarding the execution of the tasks.') autonomy_3 = make_field('I could decide by myself how much time I spent on each task.') frustration = models.IntegerField(label='How frustrated did you feel performing the task') ManipulationCheck_1 = models.IntegerField( choices=[[1, 'I was kept in the dark about the number of sequences to count.'], [2, 'I was notified about the number of sequences to count.'], [3, 'I could determine the number of sequences to count.']], widget=widgets.RadioSelect, label='For each upcoming task,' ) Fairness_1 = make_field('I feel satisfied with the way tasks were allocated.') Fairness_2 = make_field('I felt that the procedure used to determine task allocation is fair.') TechnicalQuestion = models.LongStringField(label='Did you encounter any problems or technical issues during the study? If not, please write "no".') # ------ Survey -------- age = models.IntegerField(label='What is your age?', min=16, max=125) country = all_countries(label='In which country do you currently reside?') gender = models.StringField( choices=[['Male', 'Male'], ['Female', 'Female'], ['Other', 'Other'], ['I prefer not to disclose', 'I prefer not to disclose']], label='What is your gender?', widget=widgets.RadioSelect, ) education = models.StringField( choices=[['GED equivalent', 'GED equivalent'], ['High school', 'High school'], ['Some college', 'Some college'], ['Bachelor“s degree', 'Bachelor“s degree'], ['Masters/Doctoral or professional degree', 'Masters/Doctoral or professional degree'], ['Prefer not to say', 'Prefer not to say']], label='What is your highest education level?', widget=widgets.RadioSelect, ) income = models.StringField( choices=['Less than 15,000$', '15,000$ - 30,000$', '30,000$-45,000$', '45,000$-60,000$', 'More than 60,000$', 'Prefer not to say'], label='What is your yearly income level?', widget=widgets.RadioSelect, ) prolific_id = models.StringField(default=str(" ")) # PAGES class ManipulationCheck(Page): form_model = 'player' def get_form_fields(self): import random form_fields = [ 'ManipulationCheck_1' ] random.seed(1) random.shuffle(form_fields) return form_fields class Questionnaire_SelfDetermination(Page): form_model = 'player' def get_form_fields(self): import random form_fields = [ 'self_determination_1', 'self_determination_2', 'self_determination_3', 'self_determination_4', 'self_determination_5', 'self_determination_6', 'self_determination_7', 'self_determination_8', 'self_determination_9', 'autonomy_1', 'autonomy_2', 'autonomy_3', 'ACQ_1' ] random.seed() random.shuffle(form_fields) return form_fields class Questionnaire_Rest(Page): form_model = 'player' def get_form_fields(self): import random form_fields = ['frustration', 'boredom_1', 'boredom_2', 'boredom_3', 'Fairness_1', 'Fairness_2', 'satisfaction_2', 'satisfaction_3', 'satisfaction_4', 'ACQ_2' ] random.seed(1) random.shuffle(form_fields) return form_fields class TechnicalQuestion(Page): form_model = 'player' form_fields = ['TechnicalQuestion'] class CombinedResults(Page): def vars_for_template(player: Player): return {'combined_correct_tasks': player.participant.combined_correct_task, 'combined_payoff': cu(1), 'total_answers': player.participant.total_answers} class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'country', 'education', 'income'] @staticmethod def before_next_page(self, timeout_happened): self.prolific_id = self.participant.label class completion(Page): def vars_for_template(player: Player): player.participant.finished = True class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [Questionnaire_SelfDetermination, Questionnaire_Rest, ManipulationCheck, Demographics, TechnicalQuestion, CombinedResults, completion]