from otree.api import * doc = """ SurveyandResults of all tasks """ class C(BaseConstants): NAME_IN_URL = 'SurveyandResultsrandom' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 AQ = ['q1', 'q2', 'q3', 'q4', 'q5'] def creating_session(Subsession): session = Subsession.session session.vars['Treatment'] = 'HP' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def make_field(label): return models.IntegerField( choices=[ [1, 'Strongly disagree'], [2, 'Somewhat disagree'], [3, 'Neither agree nor disagree'], [4, 'Somewhat agree'], [5, 'Strongly agree'] ], label=label, widget=widgets.RadioSelect, ) def make_field2(label): return models.IntegerField( min=0, max=10, label=label, ) class Player(BasePlayer): r1 = make_field('1. If someone does me a favor, I am prepared to return it.') r2 = make_field('2. If I suffer a serious wrong, I will take revenge as soon as possible, no matter what the cost.') r3 = make_field('3. If somebody puts me in a difficult position, I will do the same to them.') r4 = make_field('4. I go out of my way to help somebody who has been kind to me before.') r5 = make_field('5. If somebody offends me, I will offend them back.') r6 = make_field('6. I am ready to undergo personal costs to help somebody who helped me before.') p1 = make_field2( 'a) At school, I am only willing to do something for a colleague if I expect that they would do the same for me. ') p2 = make_field2( 'b) I am willing to donate time and money to charity, even if I dont profit from that directly.') p3 = make_field2('c) I am willing to help others even if I expect that I will never meet them again.') p4 = make_field2('d) When I spend time and money on something I expect to profit from that in the future.') p5 = make_field2('e) When I donate money, I expect that this is recognized and acknowledged.') p6 = make_field2( 'f) I do not understand why some people spend their lifetime fighting for a cause which they do not benefit from directly.') p7 = make_field2('g) I am a person who would go out of my way to help others.') p8 = make_field2('h) In comparison to others, I am a rather selfless person. ') p9 = make_field2('i) I am only willing to help others if I expect that they would do the same for me. ') p10 = make_field2('j) Other people regard me as an unselfish person.') g1 = make_field('1. I tried to maximize my own payoff.') g2 = make_field('2. I tried to maximize the payoff of the participant that I was matched with.') g3 = make_field('3. I tried to maximize the payoff of the Nonprofit.') g4 = make_field('4. I was concerned about the impact of my decisions on the player that I was matched with.') g5 = make_field('5. I was concerned about the impact of my decisions on the Nonprofit.') a1 = models.LongStringField( label='1. In a few words, how did you decide what type (A or B) to report in each round of Task 1?') a2 = models.LongStringField( label='2. How did you estimate the probability that a Firm would be of Type A?') a3 = models.LongStringField(label= '3. Did you sometimes decide to report a Firm as Type A when you believed it to be Type B (or vice versa)? Why yes or why not? ') f0 = models.LongStringField( label='1. In a few words, how did you estimate the probability that you were of Type A in each round of Task 1?') f02 = models.LongStringField( label='2. In a few words, how did you choose between the two Auditors when you were the 1st Firm?') # fh2 only for HP # f3 to f6 1. Thinking about the decisions you made in Task 1, please indicate how much you agree or disagree with each of the following statements: f1 = make_field('1. I expected the Auditor to feel an obligation to report me as Type A.') f2 = make_field('2. I expected the Auditor to feel an obligation to report me as Type B.') f3 = make_field('3. I expected the Auditor to be more concerned about my payoff than the Nonprofit’s payoff.') f4 = make_field('4. I expected the Auditor to be less concerned about my payoff than the Nonprofit’s payoff.') # f7 to f11 2. Thinking about the decisions you made in Task 1, please indicate how much you agree or disagree with each of the following statements: f5 = make_field( '5. I was concerned that the Auditor could negatively impact the Nonprofit if they reported me incorrectly') f6 = make_field('6. I was concerned that the Auditor could negatively impact me if they reported me as Type B.') f7 = make_field('7. I wanted to avoid appearing to be selfish.') f8 = make_field( '8. I made my decisions randomly.') # fh11 is HP only # f12 to f13 #3. Please indicate how much you agree or disagree with each of the following statements: f3:f5 f9 = make_field('9. I preferred Auditors with a reputation of reporting Type A more often.') f10 = make_field('10. I preferred Auditors with a reputation of reporting Type B more often.') f11 = make_field('11. I considered the Auditors’ previous Report Decisions when selecting one of them.') #qold = make_field('1. I was more likely to want to help the Firm when I was matched with the 1st Firm than when I was matched with the 2nd Firm.') q1 = make_field('
  • I understood the instructions.
  • ') q2 = make_field('
  • I was more likely to report the Firm as being Type A when I was matched with the 1st Firm than when I was matched with the 2nd Firm.
  • ') q3 = make_field('
  • I felt an obligation to try to ensure a high payoff for the Firm that I was matched with.
  • ') q4 = make_field('
  • I felt an obligation to try to ensure a high payoff for the Nonprofit that I was matched with.
  • ') q5 = make_field('
  • I felt an obligation to report the Firm’s type as accurately as possible.
  • ') q6 = make_field('6. I was concerned about negatively impacting the Nonprofit if I reported a Firm incorrectly.') q7 = make_field('7. I was concerned about negatively impacting the Firm if I reported it as Type B.') q8 = make_field('8. I wanted to avoid appearing to be selfish.') q9 = make_field('9. I made my decisions randomly.') q10 = make_field( '10. I took into account the composition of the plates (damaged vs. undamaged) to make my Report Decisions.') q11 = make_field( '11. I took into account the risk that I could receive a monetary penalty if my Report Decision was incorrect.') q12 = make_field( '12. I felt more certain about my Report Decisions when I observed a greater number of plates.') q13 = make_field( '13. I felt an obligation to report the Firm as Type A because they paid for the audit.') q14 = make_field( '14. I felt an obligation to report the 1st Firm as Type A because they selected me.') q15 = make_field( '15. I worried that, if I reported a Firm as Type B, I would be less likely to be selected by the 1st Firm in future rounds.') q18 = make_field( '1. I cared more about my own payoffs.') q19 = make_field( '2. I cared more about the Firm`s payoffs.') q20 = make_field( '3. I cared more about the Nonprofit’s payoffs.') # q21 = make_field( # '4. I got bored') q22 = make_field( '4. I was more likely to make random decisions.') q23 = make_field( '5. I understood the task better.') # q20, q22, q23, q24 and q25 are the same f19 = make_field( '2. I cared more about the Auditor`s payoffs.') d1 = models.IntegerField( choices=[ [1, 'Male'], [2, 'Female'], [3, 'Transgender male'], [4, 'Transgender female'], [5, 'Non-listed'], [6, 'Prefer not to disclose'] ], label='1. Which best describes your gender identity?', widget=widgets.RadioSelect, ) d2 = models.IntegerField(min=0, max=100, label='2. Please specify your age:') d3 = models.IntegerField( choices=[ [1, 'White'], [2, 'Asian'], [3, 'Hispanic / Latin American'], [4, 'African-American'], [5, 'American Indian / Alaskan Native'], [6, 'Hawaiian / Pacific Islander'], [7, 'Prefer not to disclose'], [8, 'Other '] ], label='3. Please specify your race / ethnic origin.', widget=widgets.RadioSelect, ) d4 = models.IntegerField( choices=[ [1, 'A College student'], [2, 'A Graduate student'], [3, 'Not a student'], [4, 'Other'] ], label='4. Are you currently...?', widget=widgets.RadioSelect, ) d5 = models.StringField( label='5. What is/was your major in college? (NA if not applicable)') d6= models.IntegerField( choices=[ [1, 'I do not donate money to charitable organizations '], [2, 'Less than $10 '], [3, 'Between $10 and $50 '], [4, 'Between $50 and $100'], [5, 'More than $100'] ], label='6. How much money do you usually donate to charitable organizations per year? ', widget=widgets.RadioSelect, ) d7 = models.LongStringField( label='7. Overall, what did you think about the study? Were the instructions clear and easy to understand? Please feel free to share any thoughts you may have about this study. Please enter NA if you have no comments.') # PAGES class FirstScreen(Page): pass # General Reciprocity Questions class QuestionsGR(Page): form_model = 'player' form_fields = ['r1', 'r2', 'r3', 'r4', 'r5', 'r6'] # General Prosociality Questions class QuestionsGP(Page): form_model = 'player' form_fields = ['p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10'] def error_message(player, values): solutions = dict(p1=10,p2=10,p3=10,p4=10,p5=10,p6=10,p7=10,p8=10,p9=10,p10=10) error_messages = dict() for field_name in solutions: if values[field_name] > solutions[field_name]: error_messages[field_name] = 'Please enter a value between 0 and 10' return error_messages # Open Questions for the Auditor class QuestionsOA(Page): form_model = 'player' form_fields = ['a1', 'a2', 'a3'] def is_displayed(player: Player): participant = player.participant return participant.T1role == 'Auditor X' or participant.T1role == 'Auditor Y' def vars_for_template(player: Player): session = player.session # Open Questions for the Firm class QuestionsOF(Page): form_model = 'player' @staticmethod def get_form_fields(player): session = player.session Treatment = session.vars['Treatment'] if Treatment != 'HP': return ['f0'] if Treatment == 'HP': return ['f0','f02'] # f02 is for HP only def is_displayed(player: Player): participant = player.participant return participant.T1role == '1st Firm' or participant.T1role == '2nd Firm' def vars_for_template(player: Player): session = player.session # General Task 1 not Open Questions class QuestionsG(Page): form_model = 'player' form_fields = ['g1', 'g2', 'g3', 'g4', 'g5'] def is_displayed(player: Player): participant = player.participant session = player.session Treatment = session.vars['Treatment'] return participant.T1role == 'Auditor X' or participant.T1role == 'Auditor Y' or Treatment == 'HP' def vars_for_template(player: Player): session = player.session # Reciprocity for the Auditor class Questions1A(Page): form_model = 'player' AQ = ['q1', 'q2', 'q3', 'q4', 'q5'] import random random.shuffle(AQ) numbered_AQ = [(i + 1, q) for i, q in enumerate(AQ)] form_fields = [q for q in AQ] #def is_displayed(player: Player): # participant = player.participant # return participant.T1role == 'Auditor X' or participant.T1role == 'Auditor Y' or participant.T1role == 'Auditor Z' # Other Questions for the Auditor class Questions2A(Page): form_model = 'player' form_fields = ['q6','q7', 'q8', 'q9', 'q10'] def is_displayed(player: Player): participant = player.participant return participant.T1role == 'Auditor X' or participant.T1role == 'Auditor Y' or participant.T1role == 'Auditor Z' def vars_for_template(player: Player): session = player.session class Questions3A(Page): form_model = 'player' @staticmethod def get_form_fields(player): session = player.session Treatment = session.vars['Treatment'] if Treatment == 'R': return ['q11', 'q12'] if Treatment == 'P': return ['q11', 'q12', 'q13'] if Treatment == 'HP': return ['q11', 'q12', 'q13','q14','q15'] def is_displayed(player: Player): participant = player.participant return participant.T1role == 'Auditor X' or participant.T1role == 'Auditor Y' or participant.T1role == 'Auditor Z' def vars_for_template(player: Player): session = player.session class Questions4A(Page): form_model = 'player' form_fields = ['q18', 'q19', 'q20', 'q22', 'q23'] def is_displayed(player: Player): participant = player.participant return participant.T1role == 'Auditor X' or participant.T1role == 'Auditor Y' or participant.T1role == 'Auditor Z' def vars_for_template(player: Player): session = player.session # Reciprocity Questions for the Firm class QuestionsF1(Page): form_model = 'player' @staticmethod def get_form_fields(player): session = player.session Treatment = session.vars['Treatment'] return ['f1', 'f2', 'f3', 'f4','f5','f6'] def is_displayed(player: Player): participant = player.participant return participant.T1role == '1st Firm' or participant.T1role == '2nd Firm' def vars_for_template(player: Player): session = player.session # Other Questions for the Firm class QuestionsF2(Page): form_model = 'player' form_fields = ['f7', 'f8', 'f9', 'f10','f11'] def is_displayed(player: Player): participant = player.participant return participant.T1role == '1st Firm' or participant.T1role == '2nd Firm' def vars_for_template(player: Player): session = player.session class QuestionsF4(Page): form_model = 'player' form_fields = ['q18', 'f19', 'q20', 'q22', 'q23'] def is_displayed(player: Player): participant = player.participant return participant.T1role == '1st Firm' or participant.T1role == '2nd Firm' def vars_for_template(player: Player): session = player.session class ResultsStart(Page): def vars_for_template(player: Player): session = player.session participant = player.participant T1payoff = participant.T1payoff.to_real_world_currency(session) T2payoff = participant.T2payoff.to_real_world_currency(session) T3payoff = participant.mpl_payoff.to_real_world_currency(session) Taskpayoff = T1payoff+T2payoff+T3payoff import math Totalpayoff = math.ceil(participant.payoff_plus_participation_fee()) T1npoimpact = participant.T1npoimpact.to_real_world_currency(session) T2npoimpact = participant.T2nporesult.to_real_world_currency(session) return dict(T1payoff=T1payoff, T2payoff=T2payoff, T3payoff=T3payoff, T1npoimpact=T1npoimpact,T2npoimpact=T2npoimpact, Taskpayoff=Taskpayoff, Totalpayoff=Totalpayoff) class ResultsStart2(Page): def vars_for_template(player: Player): session = player.session participant = player.participant class ResultsTask1(Page): def vars_for_template(player: Player): session = player.session participant = player.participant T1payoff = participant.T1payoff.to_real_world_currency(session) return dict(T1payoff=T1payoff) class ResultsTask2(Page): def vars_for_template(player: Player): session = player.session participant = player.participant T2payoff = participant.T2payoff.to_real_world_currency(session) return dict(T2payoff=T2payoff) class ResultsTask3(Page): def vars_for_template(player: Player): session = player.session participant = player.participant T3payoff = participant.mpl_payoff.to_real_world_currency(session) return dict(T3payoff=T3payoff) class ResultsEnd(Page): def vars_for_template(player: Player): session = player.session participant = player.participant T1payoff = participant.T1payoff.to_real_world_currency(session) T2payoff = participant.T2payoff.to_real_world_currency(session) T3payoff = participant.mpl_payoff.to_real_world_currency(session) import math Totalpayoff = math.ceil(participant.payoff_plus_participation_fee()) return dict(T1payoff=T1payoff, T2payoff=T2payoff, T3payoff=T3payoff, Totalpayoff=Totalpayoff) class QuestionsD(Page): form_model = 'player' form_fields = ['d1', 'd2', 'd3', 'd4', 'd5', 'd6','d7'] # def is_displayed(player: Player): # participant = player.participant def vars_for_template(player: Player): session = player.session class StudyEnds(Page): def vars_for_template(player: Player): import math participant = player.participant Totalpayoff = math.ceil(participant.payoff_plus_participation_fee()) return dict(Totalpayoff=Totalpayoff) #page_sequence = [FirstScreen, QuestionsGR, QuestionsOA, QuestionsOF, Questions1A, QuestionsF1, Questions2A, QuestionsF2, # Questions3A, QuestionsG, ResultsStart, QuestionsD, StudyEnds] #just for testing page_sequence = [FirstScreen,Questions1A]