from otree.api import * import random c = cu doc = 'Show questionnaire (and collect payment details), report payoffs from previous apps.' class Constants(BaseConstants): name_in_url = 'questionnaire_and_payment4' players_per_group = None num_rounds = 1 conversion_rate = 0.01 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): totalpoints_currency = models.FloatField() Paymentsused = models.CurrencyField() round_selected = models.IntegerField() age = models.IntegerField(label='What is your age?', min=0, max=100) gender = models.StringField(widget=widgets.RadioSelect, choices=[[0, 'Male'], [1, 'Female'], [3, 'Other'], [4, 'Prefer not to say']], label='What is your gender?') Marital_status = models.StringField(widget=widgets.RadioSelect, choices=[[1, 'Single/Never Married'], [2, 'Married/has Domestic Partner'], [3, 'Divorced/Separated'], [4, 'Prefer not to say']], label='What is your marital status?') Residence = models.StringField(widget=widgets.RadioSelect, choices=[[1, "Yes"], [0, "No"]], label="Do you live with your parents outside of school? ") Residence1 = models.StringField(label="What zip code did you grew up in?") Education = models.StringField(widget=widgets.RadioSelect, choices=[[1, "Some College"], [2, "College Degree"], [3, "Postgraduate"]], label='Education level') Major = models.StringField(label='What is your major at the University of Arkansas?') understanding = models.StringField(widget=widgets.RadioSelect, choices=[[1, 'Not at all'], [2, 'A little'], [3, 'Average'], [4, 'Quite well'], [5, 'Completely']], label='How much do you believe that you understood the instructions of ' 'experiment? ') Income = models.StringField(choices=[[0, 'Less than $49,999 '], [1, '$50,000 - $79,999'], [2, '$80,000 - $109,000'], [3, '$110,000- $139,999'], [4, '$140,000 - $199,999'], [5, 'Over $200,000']], widget=widgets.RadioSelect, label="Which category best describes your annual family income?") Volunteering = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Did not volunteer"], [1, "Volunteered less than 3 times "], [2, "Volunteered up to 5 times"], [3, "Volunteered less than 10 times"], [4, "Volunteered more than 10 times"]], label='Approximately how many times did you volunteer in the past year?') Employment_status = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Not working outside home"], [1, "Student"], [2, "Employed"]], label="What is your employment status?") # Occupation = models.StringField(label="12. Please indicate your primary occupation if you chose other above ") Salary = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Less than $13,999"], [1, "$14,000 - $27,999"], [2, "$28,000 - $43,999"], [3, "$44,000 - $65,999"], [4, "$66,000 - $89,000"], [5, "$90,000 or above"]], label="What is your salary per year?") Finances = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Prefer not to answer"], [1, "Poor"], [2, "Not so good"], [3, "Good"], [4, "Very good"], [5, "Excellent"]], label="How would you describe the state of your own personal finances these days? ") Religion = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Christian (Catholic) "], [1, "Christian (Other)"], [2, "Muslim"], [3, "Jewish"], [4, "Hindu"], [5, "Buddhist"], [6, "Other"]], label="Primary Religious Affiliation") Race = models.StringField(widget=widgets.RadioSelect, choices=[[0, "White"], ["1", "African-American/Black"], [2, "Hispanic"], [3, "American Indian or Native Alaskan"], [4, "Asian (Chinese, Japanese, Korean, etc.) or Pacific"], [5, "Indian Subcontinent "], [6, "Middle Eastern "], [7, 'Other']], label="What is your ethnicity ?") # Race1 = models.StringField(label="If you chose other above, please specify") Political = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Republican Party"], [1, "Democratic Party"], [3, "Independent"], [2, "Other"]], label="In politics today, do you consider yourself a Republican, a Democrat, " "an Independent, or something else?") volunteer = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Strongly Disagree"], [1, "Disagree"], [2, "Neither Agree or Disagree"], [3, "Agree"], [4, "Strongly Agree"]], label='To what extent do you agree with the following statement:” Members of my ' 'group actively invested in the group project when given the opportunity to ' 'in game 1') public = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Strongly Disagree"], [1, "Disagree"], [2, "Neither Agree or Disagree"], [3, "Agree"], [4, "Strongly Agree"]], label='To what extent do you agree with the following statement: “Members of my group ' 'contributed substantial amounts to the group account in game 2”.') minimum = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Strongly Disagree"], [1, "Disagree"], [2, "Neither Agree or Disagree"], [3, "Agree"], [4, "Strongly Agree"]], label='To what extent do you agree with the following statement: “Members of my ' 'group contributed substantial hours to the activity in game 3.”') Puzzle = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Strongly Disagree"], [1, "Disagree"], [2, "Neither Agree or Disagree"], [3, "Agree"], [4, "Strongly Agree"]], label='To what extent do you agree with the ' 'following statement : The puzzle solving ' 'activity in the experiment are adequate to ' 'build a sense of community') Friendly = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Strongly Disagree"], [1, "Disagree"], [2, "Neither Agree or Disagree"], [3, "Agree"], [4, "Strongly Agree"]], label='To what extent do you agree with the following statement : I had friendly ' 'group members') Working = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Strongly Disagree"], [1, "Disagree"], [2, "Neither Agree or Disagree"], [3, "Agree"], [4, "Strongly Agree"]], label='To what extent do you agree with the ' 'following statement : Working with my group ' 'members was helpful to me in completing the ' 'puzzle') Comfort = models.StringField(widget=widgets.RadioSelect, choices=[[0, "Strongly Disagree"], [1, "Disagree"], [2, "Neither Agree or Disagree"], [3, "Agree"], [4, "Strongly Agree"]], label='To what extent do you agree with the ' 'following statement : I felt comfortable ' 'in seeking help from people on my group.') class Questionnaire(Page): form_model = 'player' form_fields = {'age', 'gender', 'Marital_status', 'Residence', 'Residence1', 'Education', 'Major', 'understanding', 'Income', 'Volunteering', 'Employment_status', 'Salary', 'Finances', 'Religion', 'Race', 'Political', 'volunteer', 'public', 'minimum', 'Puzzle', 'Friendly', 'Working', 'Comfort'} @staticmethod def before_next_page(player, timeout_happened): round_selected = random.randrange(0, 3) player.round_selected = round_selected class ResultsWaitPage(WaitPage): pass class Payments(Page): form_model = 'player' def vars_for_template(Player): group = Player.group participant = Player.participant participant_pay = list(participant.vars.values()) Payments = [] Payments1 = participant_pay[0] Payments2 = participant_pay[1] Payments3 = participant_pay[2] Payments4 = participant_pay[3] Payments = [Payments1] + [Payments2] + [Payments3] + [Payments4] risk_pay = Payments[3] amount_owned = Payments[Player.round_selected] ###Times exchange rate if applicable rr = risk_pay[1] r1c2 = amount_owned[0] r2c2 = amount_owned[2] r2c3 = amount_owned[4] r2c4 = amount_owned[6] r3c2 = amount_owned[8] r3c3 = amount_owned[10] r3c4 = amount_owned[12] r4c2 = amount_owned[14] r4c3 = amount_owned[16] r4c4 = amount_owned[18] r5c2 = amount_owned[20] r5c3 = amount_owned[22] r5c4 = amount_owned[24] r6c2 = amount_owned[26] r6c3 = amount_owned[28] r6c4 = amount_owned[30] ppp = [r2c2] + [r3c2] + [r4c2] + [r5c2] + [r6c2] + [rr] # Points_nrr = [r2c2]+[r3c2]+[r4c2]+[r5c2]+[r6c2] Points = sum(ppp) Player.totalpoints_currency = round((Points * Constants.conversion_rate)) Player.payoff = c(Points * Constants.conversion_rate) return dict(a1=r1c2, a2=r2c2, a3=r2c3, a4=r2c4, a5=r3c2, a6=r3c3, a7=r3c4, a8=r4c2, a9=r4c3, a10=r4c4, a11=r5c2, a12=r5c3, a13=r5c4, a14=r6c2, a15=r6c3, a16=r6c4, rr_msg=rr, Points_earned=Points, game_selected=Player.round_selected + 1, pay_me=amount_owned) class Goodbye(Page): pass page_sequence = [Questionnaire, ResultsWaitPage, Payments, Goodbye]