from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from otreeutils.surveys import create_player_model_for_survey, generate_likert_field, generate_likert_table author = 'Huanren Zhang' doc = """ survey questions """ class Constants(BaseConstants): name_in_url = 'ljasobu' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass # some pre-defined choices GENDER_CHOICES = ( ('female', 'Female'), ('male', 'Male'), ('no_answer', 'Prefer not to answer'), ) YESNO_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ) # define a Likert 5-point scale with its labels likert_5_labels = ( 'Strongly disagree', 'Disagree', 'Neither agree nor disagree', 'Agree', 'Strongly agree' ) likert_7_labels = ( 'Strongly Disagree', 'Moderately Disagree', 'Slightly Disagree', 'Neutral', 'Slightly Agree', 'Moderately Agree', 'Strongly Agree' ) likert_5point_field = generate_likert_field(likert_5_labels) likert_7point_field = generate_likert_field(likert_7_labels) # define survey questions per page # for each page define a page title and a list of questions # the questions have a field name, a question text (input label), and a field type (model field class) SURVEY_DEFINITIONS = ( { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { 'fields': [ ('flipping_cards', { 'help_text': """ There are four cards below, and you want to turn over as few cards as possible to verify whether the following statement is true: Every card with a vowel on one side has an even number on the other side.
""", 'text': 'Write down the cards that you want to turn over to examine.', 'field': models.CharField(initial='',max_length=4), })], }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { # you need to provide a dict then. you can add more keys to the dict which are then available in the template 'form_name': 'first_form9', # optional, can be used for CSS styling 'fields': [ ('linda', { 'text': 'Linda is 31 years old, single, outspoken, and very bright. She majored in philosophy. As a student, she was deeply concerned with issues of discrimination and social justice, and also participated in anti-nuclear demonstrations. Which of the following is more probable?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( 'Linda is a bank teller and is active in the feminist movement'), ( 'Linda is an elementary school teacher.'), ( 'Linda is an insurance salesperson'), ( 'Linda is a bank teller'), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { # you need to provide a dict then. you can add more keys to the dict which are then available in the template 'fields': [ ('bill', { 'text': 'Bill is 2.1 meters tall with an athletic build. Which is more likely?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( 'He is a basketball player.'), ( 'He is a jockey or a basketball player.'), ( 'He is a teacher.'), ( 'He is a teacher and a jockey.'), ), ), }), ] }, ] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { # you need to provide a dict then. you can add more keys to the dict which are then available in the template 'fields': [ ('birth_gender', { 'text': 'You and your spouse have had three children together, all of them girls. Now that you are expecting your fourth child, you wonder whether the odds favor having a boy this time. What is the best estimate of your probability of having another girl?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(('6.25%','6.25% (1 out of 16), because the odds of getting four girls in a row is 1 out of 16'), ('50%','50% (1 in 2), because there is roughly an equal chance of getting each gender'), ('6.25~50%','A percentage that falls somewhere between these two estimates (6.25–50%)'), ), ), })], }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { # you need to provide a dict then. you can add more keys to the dict which are then available in the template 'fields': [ ('most_likely', { 'text': 'Which of the following instances seems most likely?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( 'Drawing a red marble from a bag containing 50 percent red marbles and 50 percent white marbles.'), ( 'Drawing a red marble seven times in succession, with replacement (a selected marble is put back into the bag before the next marble is selected), from a bag containing 90 percent red marbles and 10 percent white marbles.'), ( 'Drawing at least one red marble in seven tries, with replacement, from a bag containing 10 percent red marbles and 90 percent white marbles.'), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { # you need to provide a dict then. you can add more keys to the dict which are then available in the template 'fields': [ ('least_likely', { 'text': 'Which of the following instances seems least likely?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( 'Drawing a red marble from a bag containing 50 percent red marbles and 50 percent white marbles.'), ( 'Drawing a red marble seven times in succession, with replacement (a selected marble is put back into the bag before the next marble is selected), from a bag containing 90 percent red marbles and 10 percent white marbles'), ( 'Drawing at least one red marble in seven tries, with replacement, from a bag containing 10 percent red marbles and 90 percent white marbles.'), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { 'fields': [ ('monty_hall', { 'help_text': """ You are in a game show and the host presents you with three doors. Behind one door is a car; behind the others, goats.
""", 'text': 'You pick a door, say No. 1, and the host, who knows what\'s behind the doors, opens another door, say No. 3, which has a goat. He then says to you "Do you want to switch to door No. 2?" What would you do in order to be more likely to win a car?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(('switch' ), ('stay' ), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { 'fields': [ ('hospital_babies', { 'text': 'A certain town is served by two hospitals. In the larger hospital, about 45 babies are born each day. In the smaller hospital, about 15 babies are born each day. About 50 percent of all babies are boys. For a period of one year, each hospital recorded the days in which more than 60 percent of the babies born were boys. Which hospital do you think recorded more such days?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( 'The larger hospital'), ( 'The smaller hospital'), ( 'About the same (that is, within 5% of each other)'), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { 'fields': [ ('candidate_photo', { 'help_text': """
""", 'text': 'You are the campaign manager for a politician. You current goal is to increase the support from the left-wing liberals that support individual freedom and social equality. Which photo of the politician shown above should be used?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( 'left'), ( 'middle'), ( 'right'), ), ), }), ] }, ] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { 'fields': [ ('policy', { 'text': 'Politician A proposes lower taxes and cuts in public services; B proposes higher taxes and more public services. A decides to funds a third-party candidate C. What policies should C endorse to increase A\'s chance of winning?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(('lower taxes than A, more public services than A'), ('lower taxes than A, less public services than A'), ('the same taxes as A, more cuts in public services than A'), ('higher taxes than A, more public services than B'), ('higher taxes than B, same public services as before'), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { 'fields': [ ('down_syndrome', { 'text': 'There is only a 1 in 1,000 chance that a woman will have a baby with Down syndrome. Lisa obtains the Triple Screen test for detecting Down syndrome. The test is moderately accurate: When a baby has Down syndrome, the test delivers a positive result 86% of the time. However, 5% of babies produce a positive result despite not having Down syndrome. Lisa obtains a positive result for Down syndrome. What are the chances that her baby has Down syndrome?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( '0-10%'), ( '11-30%'), ( '31-70%'), ( '71-100%'), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { 'fields': [ ('blue_cab', { 'text': 'A cab was involved in a hit-and-run accident at night. 85% of the cabs in the city are Green and 15% are Blue. A witness identified the cab as Blue. The court tested the reliability of the witness under the circumstances that existed on the night of the accident and concluded that the witness correctly identified each one of the two colors 80% of the time and failed 20% of the time. What is the probability that the cab involved in the accident was Blue?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(( '0-30%'), ( '31%-50%'), ( '51%-80%'), ( '81-100%'), ), ), })] }] }, { 'page_title': '', 'survey_fields': [ # you can also split questions into several forms for better CSS styling { # you need to provide a dict then. you can add more keys to the dict which are then available in the template 'fields': [ ('batting_averages', { 'text': 'If you had to describe the relationship between baseball players\' batting averages in one season and their batting averages in the subsequent season, which of the following four descriptions would you pick?', 'field': models.CharField(widget=widgets.RadioSelect, choices=(('Zero correlation', 'Zero correlation: Performance entirely unpredictable from year to year'), ('Weak correlation', 'Weak correlation of about .4: Performance moderately predictable, but with a lot of random influences.'), ('Strong correlation', 'Strong correlation of about .7: Performance quite predictable, with a small random component.'), ('Perfect correlation', 'Perfect correlation of 1.0: Performance stable from one year to the next.'), ), ), })] }] }, ) # now dynamically create the Player class from the survey definitions # we can also pass additional (non-survey) fields via `other_fields` Player = create_player_model_for_survey('probability_judgment.models', SURVEY_DEFINITIONS, other_fields={ 'batting_averages_correct':models.BooleanField(initial=False), 'candidate_photo_correct': models.BooleanField(initial=False), 'birth_gender_correct': models.BooleanField(initial=False), 'blue_cab_correct': models.BooleanField(initial=False), })