from otree.api import * from otree.api import BasePlayer #import otree_tools.models doc = """Big 5 personality test""" class C(BaseConstants): NAME_IN_URL = 'part2' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 INSTRUCTIONS_TEMPLATE = 'bigfive_long/Instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def make_q(label): return models.IntegerField(label=label, choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect) class Player(BasePlayer): q1 = make_q('1. Is outgoing, sociable.') q2 = make_q('2. Is compassionate, has a soft heart.') q3 = make_q('3. Tends to be disorganized.') q4 = make_q('4. Is relaxed, handles stress well.') q5 = make_q('5. Has few artistic interests.') q6 = make_q('6. Has an assertive personality.') q7 = make_q('7. Is respectful, treats others with respect.') q8 = make_q('8. Tends to be lazy.') q9 = make_q('9. Stays optimistic after experiencing a setback.') q10 = make_q('10. Is curious about many different things.') q11 = make_q('11. Rarely feels excited or eager.') q12 = make_q('12. Tends to find fault with others.') q13 = make_q('13. Is dependable, steady.') q14 = make_q('14. Is moody, has up and down mood swings.') q15 = make_q('15. Is inventive, finds clever ways to do things.') q16 = make_q('16. Tends to be quiet.') q17 = make_q('17. Feels little sympathy for others.') q18 = make_q('18. Is systematic, likes to keep things in order.') q19 = make_q('19. Can be tense.') q20 = make_q('20. Is fascinated by art, music, or literature.') q21 = make_q('21. Is dominant, acts as a leader.') q22 = make_q('22. Starts arguments with others.') q23 = make_q('23. Has difficulty getting started on tasks.') q24 = make_q('24. Feels secure, comfortable with self.') q25 = make_q('25. Avoids intellectual, philosophical discussions.') q26 = make_q('26. Is less active than other people.') q27 = make_q('27. Has a forgiving nature.') q28 = make_q('28. Can be somewhat careless.') q29 = make_q('29. Is emotionally stable, not easily upset.') q30 = make_q('30. Has little creativity.') q31 = make_q('31. Is sometimes shy, introverted.') q32 = make_q('32. Is helpful and unselfish with others.') q33 = make_q('33. Keeps things neat and tidy.') q34 = make_q('34. Worries a lot.') q35 = make_q('35. Values art and beauty.') q36 = make_q('36. Finds it hard to influence people.') q37 = make_q('37. Is sometimes rude to others.') q38 = make_q('38. Is efficient, gets things done.') q39 = make_q('39. Often feels sad.') q40 = make_q('40. Is complex, a deep thinker.') q41 = make_q('41. Is full of energy.') q42 = make_q('42. Is suspicious of others’ intentions.') q43 = make_q('43. Is reliable, can always be counted on.') q44 = make_q('44. Keeps their emotions under control.') q45 = make_q('45. Has difficulty imagining things.') q46 = make_q('46. Is talkative.') q47 = make_q('47. Can be cold and uncaring.') q48 = make_q('48. Leaves a mess, doesn’t clean up.') q49 = make_q('49. Rarely feels anxious or afraid.') q50 = make_q('50. Thinks poetry and plays are boring.') q51 = make_q('51. Prefers to have others take charge.') q52 = make_q('52. Is polite, courteous to others.') q53 = make_q('53. Is persistent, works until the task is finished.') q54 = make_q('54. Tends to feel depressed, blue.') q55 = make_q('55. Has little interest in abstract ideas.') q56 = make_q('56. Shows a lot of enthusiasm.') q57 = make_q('57. Assumes the best about people.') q58 = make_q('58. Sometimes behaves irresponsibly.') q59 = make_q('59. Is temperamental, gets emotional easily.') q60 = make_q('60. Is original, comes up with new ideas.') #Domain extraversion = models.FloatField() agreeableness = models.FloatField() conscientiousness = models.FloatField() neuroticism = models.FloatField() openness = models.FloatField() #Facet # Sociability = models.FloatField() # Assertiveness = models.FloatField() # Energy = models.FloatField() # Compassion = models.FloatField() # Respectfulness = models.FloatField() # Trust = models.FloatField() # Organization = models.FloatField() # Productiveness = models.FloatField() # Responsibility = models.FloatField() # Anxiety = models.FloatField() # Depression = models.FloatField() # Emotional = models.FloatField() # Intellectual = models.FloatField() # Aesthetic = models.FloatField() # Creative = models.FloatField() #Demographics # qd1 = models.IntegerField(widget=widgets.RadioSelectHorizontal, # label="Have you completed this questionnaire before?", # choices=[[1, "Yes"], [2, "No"]]) qd2 = models.IntegerField(widget=widgets.RadioSelectHorizontal, label="What is your gender?", choices=[[1, "Male"], [2, "Female"], [3,"Non-binary"], [4,"Other"], [5, "Prefer not to say"]]) qd3 = models.IntegerField(label="What is your age? (If you prefer not to say, type 0.)") # White = models.BooleanField(blank=True, label="White/Caucasian") # Hispanic = models.BooleanField(blank=True, label="Hispanic/Latino") # Black = models.BooleanField(blank=True, label="Black/African-American") # Asian = models.BooleanField(blank=True, label="Asian/Asian-American") # AmIndian = models.BooleanField(blank=True, label="American Indian/Native American") # NaHawaiian = models.BooleanField(blank=True, label="Native Hawaiian/Pacific Islander") # Other = models.BooleanField(blank=True, label="Other") # # # qd4 = models.IntegerField(widget=widgets.RadioSelectHorizontal, # label="Do you speak English fluently?", # choices=[[1, "Yes"], [2, "No"]]) # qd5 = models.IntegerField( # label="Where would you place yourself on the following spectrum of social class?", # choices=[[1, "Working class"], [2, "Lower-middle class"], [3,"Middle class"], [4,"Upper-middle class"], [5,"Upper class"]]) # qd6 = models.IntegerField( # label="If you currently live in the USA, in which state do you live?", # choices=[[1, "Alabama"], [2, "Alaska"], [3,"Arizona"], # [4,"Arkansas"], [5,"California"], # [6, "Colorado"], [7, "Connecticut"], [8, "Delaware"], # [9, "Florida"], [10, "Georgia"], # [11, "Hawaii"], [12, "Idaho"], [13, "Illinois"], # [14, "Indiana"], [15, "Iowa"], # [16, "Kansas"], [17, "Kentucky"], [18, "Louisiana"], # [19, "Maine"], [20, "Maryland"], # [21, "Massachusetts"], [22, "Michigan"], [23, "Minnesota"], # [24, "Mississippi"], [25, "Missouri"], # [26, "Montana"], [27, "Nebraska"], [28, "Nevada"], # [29, "New Hampshire"], [30, "New Jersey"], # [31, "New Mexico"], [32, "New York"], [33, "North Carolina"], # [34, "North Dakota"], [35, "Ohio"], # [36, "Oklahoma"], [37, "Oregon"], [38, "Pennsylvania"], # [39, "Rhode Island"], [40, "South Carolina"], # [41, "South Dakota"], [42, "Tennessee"], [43, "Texas"], # [44, "Utah"], [45, "Vermont"], # [46, "Virginia"], [47, "Washington"], [48, "Washington D.C"], [49, "West Virginia"], # [50, "Wisconsin"], [51, "Wyoming"], # [52, "Outside the US"] # ]) # qd7 = models.IntegerField(label="What is your zip code?") # qd8 = models.StringField(label="If you currently live outside of the USA, in what country do you live? (Write N/A if you live in the USA)") # qd9 = models.IntegerField( # label="What is the highest level of formal education that you have completed?", # choices=[[1, "Have not completed high school"], [2, "High school graduate"], [3,"Some college"], [4,"College graduate"], [5,"Master's degree"], [6,"Doctorate"]]) # qd10 = models.IntegerField( # label="What is your current employment status?", # choices=[[1, "Student"], [2, "Not employed"], [3,"Work part-time"], [4,"Work full-time"]]) # qd11 = models.IntegerField( # label="What is your current marital status?", # choices=[[1, "Never married"], [2, "Married or in a marriage-like relationship"], [3,"Divorced"], [4,"Widowed"]]) qd12 = models.IntegerField(widget=widgets.RadioSelectHorizontal, label="Are you a parent?", choices=[[1, "Yes"], [2, "No"], [3, "Prefer not to say"]]) # qd13 = models.IntegerField(widget=widgets.RadioSelectHorizontal, # label="Overall, how interested are you in politics? (1: Not at all interested, 5:Very interested ", # choices=[1,2,3,4,5]) qd14 = models.IntegerField(widget=widgets.RadioSelect, label="In political matters, people talk of \"the left\" and \"the right.\" How would you place your views on this scale, generally speaking?", choices=[[1, "Left"], [2, "Somewhat left"], [3,"Middle"], [4, "Somewhat right"], [5, "Right"], [6, "Prefer not to say"], [7, "Don't know; no opinion"] ]) def combine_score(positive1,positive2,negative1,negative2): return 3 + (positive1+positive2-negative1-negative2) / 4 # PAGES class Welcome(Page): pass class Introduction(Page): pass class Survey1(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'q8', 'q9', 'q10'] class Survey2(Page): form_model = 'player' form_fields = ['q11', 'q12', 'q13', 'q14', 'q15', 'q16', 'q17', 'q18', 'q19', 'q20'] class Survey3(Page): form_model = 'player' form_fields = ['q21', 'q22', 'q23', 'q24', 'q25', 'q26', 'q27', 'q28', 'q29', 'q30'] class Survey4(Page): form_model = 'player' form_fields = ['q31', 'q32', 'q33', 'q34', 'q35', 'q36', 'q37', 'q38', 'q39', 'q40'] class Survey5(Page): form_model = 'player' form_fields = ['q41', 'q42', 'q43', 'q44', 'q45', 'q46', 'q47', 'q48', 'q49', 'q50'] class Survey6(Page): form_model = 'player' form_fields = ['q51', 'q52', 'q53', 'q54', 'q55', 'q56', 'q57', 'q58', 'q59', 'q60']\ class Demographics(Page): form_model = 'player' # form_fields = ['qd1','qd2','qd3','White','Hispanic','Black', 'Asian', 'AmIndian', 'NaHawaiian','Other', 'qd4','qd5'] form_fields = ['qd2','qd3','qd12','qd14'] # @staticmethod # def before_next_page(player:Player, timeout_happened): # player.Sociability = combine_score(player.q1, player.q46, player.q16, player.q31) # player.Assertiveness = combine_score(player.q6, player.q21, player.q36, player.q51) # player.Energy = combine_score(player.q41, player.q56, player.q11, player.q26) # player.Compassion = combine_score(player.q2, player.q32, player.q17, player.q47) # player.Respectfulness = combine_score(player.q7, player.q52, player.q22, player.q37) # player.Trust = combine_score(player.q27, player.q57, player.q12, player.q42) # player.Organization = combine_score(player.q18, player.q33, player.q3, player.q48) # player.Productiveness = combine_score(player.q38, player.q53, player.q8, player.q23) # player.Responsibility = combine_score(player.q13, player.q43, player.q28, player.q58) # player.Anxiety = combine_score(player.q19, player.q34, player.q4, player.q49) # player.Depression = combine_score(player.q39, player.q54, player.q9, player.q24) # player.Emotional = combine_score(player.q14, player.q59, player.q29, player.q44) # player.Intellectual = combine_score(player.q10, player.q40, player.q25, player.q55) # player.Aesthetic = combine_score(player.q20, player.q35, player.q5, player.q50) # player.Creative = combine_score(player.q15, player.q60, player.q30, player.q45) # player.extraversion = (player.Sociability + player.Assertiveness + player.Energy)/3 # player.agreeableness = (player.Compassion + player.Respectfulness + player.Trust) / 3 # player.conscientiousness = (player.Organization + player.Productiveness + player.Responsibility) / 3 # player.neuroticism = (player.Anxiety + player.Depression + player.Emotional) / 3 # player.openness = (player.Intellectual + player.Aesthetic + player.Creative) / 3 class Results(Page): pass page_sequence = [Survey1, Survey2, Survey3, Survey4, Survey5, Survey6, Demographics]