from otree.api import * doc = """ Demographic questions, the Big 5 personality test and the CRT test. More questions on conscientiousness are also implemented and can be included by adding "Consc_1", "Consc_2" and "Consc_3" to the 'page_sequence'. """ class Constants(BaseConstants): name_in_url = "quiz" players_per_group = None num_rounds = 1 A_CHECK_Q_CORRECT = "Moderate" class Group(BaseGroup): pass class Subsession(BaseSubsession): pass def make_field(label): """ :param label: Question text. :return: Big 5 question field with five choices from 'Very Inaccurate' to 'Very Accurate'. """ return models.StringField( choices=[ "Very Inaccurate", "Moderately Inaccurate", "Moderate", "Moderately Accurate", "Very Accurate", ], label=label, ) class Player(BasePlayer): # Demographic Questions age = models.IntegerField(label="""How old are you?""") gender = models.StringField( label="""What is your gender?""", choices=["Male", "Female", "Other", "Prefer not to say"], ) countryborn = models.StringField(label="""Which country were you born in?""") countryres = models.StringField(label="""Which is your country of residence?""") language = models.StringField( label="""Is English your mother tongue?""", choices=["Yes", "No"] ) # CRT Questions CRT_1 = models.IntegerField( label="""1. The ages of Anna and Barbara add up to 30 years. Anna is 20 years older than Barbara. How old is Barbara?""" ) CRT_2 = models.IntegerField( label="""2. If it takes 2 nurses 2 minutes to check 2 patients, how many minutes does it take 40 nurses to check 40 patients?""" ) CRT_3 = models.IntegerField( label="""3. On a loaf of bread, there is a patch of mold. Every day, the patch doubles in size. If it takes 24 days for the patch to cover the entire loaf of bread, how many days would it take for the patch to cover half of the loaf of bread?""" ) CRT_4 = models.IntegerField( label="""4. If John can drink one barrel of water in 6 days, and Mary can drink one barrel of water in 12 days, how many days would it take them to drink one barrel of water together?""" ) CRT_5 = models.IntegerField( label="""5. A man buys a pig for $60, sells it for $70, buys it back for $80, and sells it finally for $90. How much profit has he made, in dollars?""" ) CRT_6 = models.IntegerField( label="""6. Jerry received both the 15th highest and the 15th lowest mark in the class. How many students are in the class?""" ) CRT_7 = models.IntegerField( label="""7. A turtle starts crawling up a 6-yard-high rock wall in the morning. During each day it crawls 3 yards and during the night it slips back 2 yards. How many days will it take the turtle to reach the top of the wall?""" ) # Big5 B5_1_A = make_field("Am sometimes rude to others.") B5_2_C = make_field("Do a thorough job.") B5_3_E = make_field("Am talkative.") B5_4_N = make_field("Worry a lot.") B5_5_O = make_field("Am original, come up with new ideas.") B5_6_A = make_field("Have a forgiving nature.") B5_7_C = make_field("Tend to be lazy") B5_8_E = make_field("Am outgoing, sociable.") B5_9_N = make_field("Get nervous easily.") B5_10_O = make_field("Value artistic, aesthetic experiences.") B5_11_A = make_field("Am considerate and kind to almost everyone.") B5_12_C = make_field("Do things efficiently.") B5_13_E = make_field("Am reserved.") B5_14_N = make_field("Am relaxed, handle stress well.") B5_15_O = make_field("Have an active imagination.") B5_attention_check = make_field('Please select the option "Moderate" on this item.') # Extra Conscientiousness C1_1_p = make_field("Complete tasks successfully.") C1_2_p = make_field("Excel in what I do.") C1_3_p = make_field("Handle tasks smoothly.") C1_4_p = make_field("Know how to get things done.") C2_1_p = make_field("Like to tidy up.") C2_2_n = make_field("Often forget to put things back in their proper place.") C2_3_n = make_field("Leave a mess in my room.") C2_4_n = make_field("Leave my belongings around.") C3_1_p = make_field("Keep my promises.") C3_2_p = make_field("Tell the truth.") C3_3_n = make_field("Break rules.") C3_4_n = make_field("Break my promises.") C4_1_p = make_field("Do more than what´s expected of me") C4_2_p = make_field("Work hard.") C4_3_n = make_field("Put little time and effort into my work") C4_4_n = make_field("Do just enough work to get by.") C5_1_p = make_field("Am always prepared") C5_2_p = make_field("Carry out my plans.") C5_3_n = make_field("Waste my time.") C5_4_n = make_field("Have difficulty starting tasks.") C6_1_n = make_field("Jump into things without thinking.") C6_2_n = make_field("Make rash decisions.") C6_3_n = make_field("Rush into things.") C6_4_n = make_field("Act without thinking.") class Demographic(Page): form_model = "player" form_fields = ["age", "gender", "countryborn", "countryres", "language"] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.participant.timeout = True @staticmethod def app_after_this_page(player, upcoming_apps): participant = player.participant if participant.timeout: return "kick" class Big5_1(Page): """ Big 5 questions part 1. Also includes an attention check (B5_attention_check). """ form_model = "player" form_fields = [ "B5_1_A", "B5_2_C", "B5_3_E", "B5_4_N", "B5_5_O", "B5_6_A", "B5_attention_check", "B5_7_C", ] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.attention_check_quiz = player.B5_attention_check if timeout_happened: participant.timeout = True if player.B5_attention_check != "Moderate": participant.attention_check_failed = True @staticmethod def app_after_this_page(player, upcoming_apps): participant = player.participant if participant.timeout: return "kick" class Big5_2(Page): """ Big 5 questions part 2. """ form_model = "player" form_fields = [ "B5_8_E", "B5_9_N", "B5_10_O", "B5_11_A", "B5_12_C", "B5_13_E", "B5_14_N", "B5_15_O", ] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.participant.timeout = True @staticmethod def app_after_this_page(player, upcoming_apps): participant = player.participant if participant.timeout: return "kick" class Consc_1(Page): """ Conscientiousness questions part 1. """ form_model = "player" form_fields = [ "C1_1_p", "C1_2_p", "C1_3_p", "C1_4_p", "C2_1_p", "C2_2_n", "C2_3_n", "C2_4_n", ] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): raise NotImplementedError("This part of legacy code has not been tested.") if timeout_happened: player.participant.timeout = True @staticmethod def app_after_this_page(player, upcoming_apps): raise NotImplementedError("This part of legacy code has not been tested.") participant = player.participant if participant.timeout: return "kick" class Consc_2(Page): """ Conscientiousness questions part 2. """ form_model = "player" form_fields = [ "C3_1_p", "C3_2_p", "C3_3_n", "C3_4_n", "C4_1_p", "C4_2_p", "C4_3_n", "C4_4_n", ] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): raise NotImplementedError("This part of legacy code has not been tested.") if timeout_happened: player.participant.timeout = True @staticmethod def app_after_this_page(player, upcoming_apps): raise NotImplementedError("This part of legacy code has not been tested.") participant = player.participant if participant.timeout: return "kick" class Consc_3(Page): """ Conscientiousness questions part 3. """ form_model = "player" form_fields = [ "C5_1_p", "C5_2_p", "C5_3_n", "C5_4_n", "C6_1_n", "C6_2_n", "C6_3_n", "C6_4_n", ] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): raise NotImplementedError("This part of legacy code has not been tested.") if timeout_happened: player.participant.timeout = True @staticmethod def app_after_this_page(player, upcoming_apps): raise NotImplementedError("This part of legacy code has not been tested.") if player.participant.timeout: return "kick" class CRT(Page): """ CRT questions. """ form_model = "player" form_fields = ["CRT_1", "CRT_2", "CRT_3", "CRT_4", "CRT_5", "CRT_6", "CRT_7"] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): score = 0 if player.CRT_1 == 5: score += 1 if player.CRT_2 == 2: score += 1 if player.CRT_3 == 23: score += 1 if player.CRT_4 == 4: score += 1 if player.CRT_5 == 20: score += 1 if player.CRT_6 == 29: score += 1 if player.CRT_7 == 4: score += 1 player.participant.crt_score = score if timeout_happened: player.participant.timeout = True @staticmethod def vars_for_template(player: Player): return {"crt_points": player.session.config["crt_points"]} @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.timeout: return "kick" page_sequence = [Demographic, Big5_1, Big5_2, CRT]