from radiogrid import RadioGridField from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from django.core import validators from django.forms import CharField import random from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from django import forms author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): for player in self.get_players(): player.media_treatment = random.choice(['disc', 'counter', 'neutral']) print('player media treatment is:', player.media_treatment) class Group(BaseGroup): pass COLUMNS = ( (1, "Strongly disagree"), (2, "Disagree"), (3, "Somewhat disagree"), (4, "Somewhat agree"), (5, "Agree"), (6, "Strongly disagree") ) ROWS1 = ( (1, 'Although men and women are equally needed in society, there are certain jobs that women are better at than men' ' and other jobs that men are better at than women.'), (2, 'Although many people think women cannot do certain things well, I like to prove them wrong.'), (3, 'It is important for people, including myself, to be part of making changes in the world that make it more ' 'equal for everybody.'), (4, 'The way the world is right now, only exceptional women can make it in the most powerful places in society.') ) ROWS2 = ( (1, 'Affectionate'), (2, 'Aggressive'), (3, 'Competitive'), (4, 'Confident'), (5, 'Defends own beliefs'), (6, 'Dominant'), (7, 'Gentle'), (8, 'Has leadership abilities'), (9, 'Sensitive to needs of others'), (10, 'Sympathetic'), (11, 'Has greater overall abilities than the average person'), (12, 'Warm'), (13, 'Willing to take risks'), ) ROWS3 = ( (1, 'My race or ethnic background'), (2, 'My personal goals and hopes for the future'), (3, 'My religion'), (4, 'My sex or my gender'), (5, 'My occupational choice and career plans'), (6, 'My commitments on political issues or my political activities'), ) COLUMNS3 = ( (1, 'Not important to my identity'), (2, 'Slightly important to my identity'), (3, 'Somewhat important to my identity'), (4, 'Very important to my identity'), (5, 'Extremely important to my identity'), ) ROWS4 = ( (1, 'I enjoyed reading the articles.'), (2, 'I found it easy to understand the information presented in the articles.'), (3, 'I felt that some of the articles (text or images) were of better journalistic' ' or entertainment quality than others.'), (4, 'I felt that some of the articles (text or images) did not treat men and women ' 'the same, in the way that they described or presented people.'), ) ROWS5 = ( (1, 'Read/watch/listen to political news'), (2, 'Read/watch/listen to celebrity news'), (3, 'Read/watch/listen to sports news'), (4, 'Watch documentaries (movies or series)'), (5, 'Watch romantic comedies (movies or series)'), (6, 'Use Twitter, Facebook, Instagram or similar'), (7, 'Play video games'), ) COLUMNS5 = ( (1, '0 days'), (2, '1-2 days'), (3, '3-4 days'), (4, '5-6 days'), (5, '7 days'), ) ROWS6 = ( (1, 'Most people believe that women are not as capable as men are in high power/status roles like politics'), (2, 'When women are candidates in elections, people are less likely to vote for them than they would ' 'have been if they were a man'), ) COLUMNS8 = ( (1, "No"), (2, "Yes") ) ROWS9 = ( [1, 'Journalist'], [2, 'Local politician'], [3, 'Economist'], [4, 'Member of parliament'], [5, 'Business owner'], [6, 'Lawyer'], [7, 'School teacher or principal'], [8, 'Nurse'], [9, 'Caretaker'], [10, 'Office administrator'], ) class Player(BasePlayer): media_treatment = models.StringField() # SURVEY1 age = models.IntegerField( min=18, label="What is your age?") gender = models.IntegerField( label="What gender are you?", choices=[ [1, 'Male'], [2, 'Female'], [3, 'My gender is not listed'] ], widget=widgets.RadioSelect, ) education = models.IntegerField( label='How many years of university education have you completed at this point?', choices=[ [1, 'Not completed one year yet'], [2, 'One year'], [3, 'Two years'], [4, 'Three or more years'], ], widget=widgets.RadioSelect, ) careers = RadioGridField(rows=ROWS9, values=COLUMNS8, require_all_fields=True, null=True, verbose_name="Of the careers listed below, please select all the ones you would " "potentially be interested in (whether it relates to your actual career or " "not).") identity = RadioGridField(rows=ROWS3, values=COLUMNS3, require_all_fields=True, null=True, verbose_name="These items describe different aspects of identity. " "Please read each item carefully and consider how it " "applies to you.") # MEDIA media_earnings = models.CurrencyField(default=0) def set_payoffs(self): if self.s1q1 == 2 and self.s1q2 == 1: self.media_earnings = 0.5 else: self.media_earnings = 0 if self.s2q1 == 2 and self.s2q2 == 1: self.media_earnings += 0.5 else: self.media_earnings += 0 if self.s3q1 == 2 and self.s3q2 == 2: self.media_earnings += 0.5 else: self.media_earnings += 0 s1q1 = models.IntegerField( label="Which of the above two statements is more accurate?", choices=[ [1, 'Statement 1.'], [2, 'Statement 2.'], ], widget=widgets.RadioSelect, ) s1q2 = models.IntegerField( label="What is an accurate summary of the article?", choices=[ [1, 'Although unemployment, including youth unemployment, is at a low level right now, there are still ' 'concerns due to the long period of economic downturn.'], [2, 'Other countries are faring much better in terms of unemployment, even if things are going well here.'], [3, 'The National Statistics Organisation has not collected figures on the level of unemployment yet.'], ], widget=widgets.RadioSelect, ) s2q1 = models.IntegerField( label="Is the subject of the article appointed to the Culture committee according to the article?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) s2q2 = models.IntegerField( label="Is the statement above in line with what the article said?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) s3q1 = models.IntegerField( label="Do all the parties agree that the youth worker card should be reinstated without changing " "the initiative?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) s3q2 = models.IntegerField( label="What benefit does the youth worker card give?", choices=[ [1, 'It allows workers under the age of 30 to travel to job interviews for free.'], [2, 'It allows workers under the age of 30 to travel for free if their place of ' 'work is far from their home.'], ], widget=widgets.RadioSelect, ) s4q1 = models.IntegerField( label="According to the study, is youth unemployment a national health issue?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) s4q2 = models.IntegerField( label="Is the statement above in line with what the article said?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) s5q1 = models.IntegerField( label="Is the statement above in line with what the article said?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) s5q2 = models.IntegerField( label="Having a partner increased happiness of respondents in the survey by 0.6 points. How much did " "doubling a person’s income increase their happiness?", choices=[ [1, '0.8 points.'], [2, '0.5 points.'], [3, '0.2 points.'], ], widget=widgets.RadioSelect, ) # EXPRESSIVE expressive1 = models.IntegerField( label="Would you like to learn a little more about running for office?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) expressive2 = models.IntegerField( label="Would you like to learn a little more about running for office and campaign logistics?", choices=[ [1, 'Yes.'], [2, 'No.'], ], widget=widgets.RadioSelect, ) # SURVEY2 nascent = models.IntegerField( label='How interested are you in becoming a candidate in politics at some point?', choices=[ [1, 'Not at all interested'], [2, 'Not very interested'], [3, 'Maybe interested'], [4, 'Definitely interested'] ], widget=widgets.RadioSelect,) state_of_world = RadioGridField(rows=ROWS1, values=COLUMNS, require_all_fields=True, null=True, verbose_name="Below is a list of statements. Please rate, from strongly " "disagree to strongly agree, how much you agree with the " "statement.") pol_characteristics = RadioGridField(rows=ROWS2, values=COLUMNS8, require_all_fields=True, null=True, verbose_name="For each characteristic below, please indicate whether you agree" " that a good politician needs the characteristic.") own_characteristics = RadioGridField(rows=ROWS2, values=COLUMNS, require_all_fields=True, null=True, verbose_name="For each characteristic below, please rate from strongly " "disagree to strongly agree how much you agree that the " "characteristic describes you.") opinion_samples = RadioGridField(rows=ROWS4, values=COLUMNS, require_all_fields=True, null=True, verbose_name="Thinking of the media articles you were shown today, please rate " "from strongly disagree to strongly agree how much you agree " "with the following statements.") media_habits = RadioGridField(rows=ROWS5, values=COLUMNS5, require_all_fields=True, null=True, verbose_name="Please indicate for each item how many days in a normal " "week you would do the following.") most_people = RadioGridField(rows=ROWS6, values=COLUMNS, require_all_fields=True, null=True, verbose_name="Please rate your agreement from 0 (strongly disagree) to 5 (strongly " "agree) with the following statements, which ask about how you think " "most people (not you personally) feel or act.")