from otree.api import * c = cu doc = '' 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='What is your age?') siblings = models.IntegerField(label='How many siblings do you have?') birth_order = models.StringField(choices=[['First-born', 'First-born'], ['Second-born', 'Second-born'], ['Middle child (including those born second to second-to-last)', 'Middle child (including those born second to second-to-last)'], ['Last-born', 'Last-born'], ['Prefer not to say', 'Prefer not to say']], label='If you have siblings: What is your birth order?') gender = models.StringField(choices=[['Male', 'Male'], ['Female', 'Female'], ['Others', 'Others']], label='What is your gender?') marital_status = models.StringField(choices=[['Single', 'Single'], ['In a relationship', 'In a relationship'], ['Engaged', 'Engaged'], ['Married', 'Married'], ['Divorced', 'Divorced'], ['Prefer not to say', 'Prefer not to say']], label='What is your marital status?') s2 = models.IntegerField(choices=[[1, ''], [2, ''], [3, ''], [4, ''], [5, '']], label='No matter how much money one makes, life is unsatisfactory without a strong sense of duty and character. ', widget=widgets.RadioSelectHorizontal) s6 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='The true test of character is a willingness to stand by one’s principles, no matter what price one has to pay. ', widget=widgets.RadioSelectHorizontal) s8 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='It is important to me to feel that I have not compromised my principles. ', widget=widgets.RadioSelectHorizontal) s9 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='If one believes something is right, one must stand by it, even if it means losing friends or missing out on profitable opportunities.', widget=widgets.RadioSelectHorizontal) s10 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='Compromising one’s principles is always wrong, regardless of the circumstances or the amount that can be personally gained. ', widget=widgets.RadioSelectHorizontal) s11 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='Universal ethical principles exist and should be applied under all circumstances, with no exceptions.', widget=widgets.RadioSelectHorizontal) s13 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='Integrity is more important than financial gain. ', widget=widgets.RadioSelectHorizontal) s14 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='It is important to fulfill one’s obligations at all times, even when nobody will know if one doesn’t.', widget=widgets.RadioSelectHorizontal) s17 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='One’s principles should not be compromised regardless of the possible gain.', widget=widgets.RadioSelectHorizontal) s18 = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='Some transgressions are wrong and cannot be legitimately justified or defended regardless of how much one tries. ', widget=widgets.RadioSelectHorizontal) h6 = models.IntegerField(choices=[[5, 'Never'], [4, 'One or two times'], [3, 'Three to six times'], [2, 'Six to ten times'], [1, 'More than ten time']], label='In your life, how many times have you stolen something?', widget=widgets.RadioSelectHorizontal) h5 = models.IntegerField(choices=[[5, 'More than once a week'], [4, 'About once a week'], [3, 'About once a month'], [2, 'About once every other month'], [1, 'Once a year or less']], label='How often do you lend personal possessions to your friends (e.g., tools, clothes, bicycle, etc....)?\u2028\u2028', widget=widgets.RadioSelectHorizontal) h4 = models.IntegerField(choices=[[5, 'More than once a week'], [4, 'About once a week'], [3, 'About once a month'], [2, 'About once every other month'], [1, 'Once a year or less']], label='How often do you lend money to your friends?\u2028\u2028', widget=widgets.RadioSelectHorizontal) h7 = models.IntegerField(choices=[[1, 'Very often'], [2, 'Often'], [3, 'Sometimes'], [4, 'Rarely'], [5, 'Never']], label='How often do you lie to your parents?', widget=widgets.RadioSelectHorizontal) h8 = models.IntegerField(choices=[[1, 'Very often'], [2, 'Often'], [3, 'Sometimes'], [4, 'Rarely'], [5, 'Never']], label='How often do you lie to close friends?\u2028\u2028', widget=widgets.RadioSelectHorizontal) h9 = models.IntegerField(choices=[[1, 'Very often'], [2, 'Often'], [3, 'Sometimes'], [4, 'Rarely'], [5, 'Never']], label='When you are working for pay, how often do you slack off?', widget=widgets.RadioSelectHorizontal) class Introduction(Page): form_model = 'player' class Hardfacts(Page): form_model = 'player' form_fields = ['age', 'siblings', 'birth_order', 'gender', 'marital_status'] class Softfacts(Page): form_model = 'player' form_fields = ['s2', 's6', 's8', 's9', 's10', 's11', 's13', 's14', 's17', 's18', 'h6', 'h5', 'h4', 'h7', 'h8', 'h9'] @staticmethod def before_next_page(player: Player, timeout_happened): import json answers = [player.s2, player.s6, player.s8, player.s9, player.s10, player.s11, player.s13, player.s14, player.s17, player.s18, player.h6, player.h5, player.h4, player.h7, player.h8, player.h9] player.participant.answers = json.dumps(answers) s2_answer = answers[0] s6_answer = answers[1] s8_answer = answers[2] s9_answer = answers[3] s10_answer = answers[4] s11_answer = answers[5] s13_answer = answers[6] s14_answer = answers[7] s17_answer = answers[8] s18_answer = answers[9] h6_answer = answers[10] h5_answer = answers[11] h4_answer = answers[12] h7_answer = answers[13] h8_answer = answers[14] h9_answer = answers[15] page_sequence = [Introduction, Hardfacts, Softfacts]