from otree.api import * c = cu doc = '\nThis app presents the puzzles and gathers and exchanges the reasons.\n' class Constants(BaseConstants): name_in_url = 'puzzles' players_per_group = 2 num_rounds = 1 amount_shared = cu(100) instructions_template = 'puzzles/instructions.html' class Subsession(BaseSubsession): pass def set_payoffs(group): players = group.get_players() for p in players: p.payoff=c(0) if p.agreed_answer_1 == 2: p.payoff = p.payoff + 1.5 if p.agreed_answer_2 == 1: p.payoff = p.payoff + 1.5 def agree_1(group): group.dominant_response_1 = group.get_player_by_id(1).Response1 group.minor_response_1 = group.get_player_by_id(2).Response1 group.powerful_mind_change_1 = group.get_player_by_id(1).Choice1 players = group.get_players() for p in players: if group.powerful_mind_change_1 == 2: p.agreed_answer_1 = group.minor_response_1 else: p.agreed_answer_1 = group.dominant_response_1 def agree_2(group): group.dominant_response_2 = group.get_player_by_id(1).Response2 group.minor_response_2 = group.get_player_by_id(2).Response2 group.powerful_mind_change_2 = group.get_player_by_id(1).Choice2 players = group.get_players() for p in players: if group.powerful_mind_change_2 == 2: p.agreed_answer_2 = group.minor_response_2 else: p.agreed_answer_2 = group.dominant_response_2 class Group(BaseGroup): total_requests = models.CurrencyField() dominant_response_1 = models.IntegerField() minor_response_1 = models.IntegerField() powerful_mind_change_1 = models.IntegerField() dominant_response_2 = models.IntegerField() minor_response_2 = models.IntegerField() powerful_mind_change_2 = models.IntegerField() set_payoffs = set_payoffs agree_1 = agree_1 agree_2 = agree_2 def other_player(player): group = player.group return player.get_others_in_group()[0] class Player(BasePlayer): Reason1 = models.LongStringField(label='Give reasons for your answer to the puzzle. These reasons will be transmitted to your partner prior to voting on the agreed response. The text box will expand if required.') Goodreason1 = models.IntegerField(choices=[[1, '1. Very poor reason. '], [2, '2. Poor reason. '], [3, '3. Average reason. '], [4, '4. Good reason. '], [5, '5. Very good reason. '], [6, '6. Extremely good reason. '], [7, '7. A demonstrative reason that perfectly supports its conclusion']], label='How would you rate the quality of the reasons you gave?') Reasonother1 = models.IntegerField(choices=[[1, '1. Very poor reason'], [2, '2. Poor reason. '], [3, '3. Average reason. '], [4, '4. Good reason. '], [5, '5. Very good reason. '], [6, '6. Extremely good reason. '], [7, '7. A demonstrative reason that perfectly supports its conclusion. ']], label="How would you rate the quality of the other participant's reason?") Choice1 = models.IntegerField(choices=[[1, '1. Stick to my original answer'], [2, "2. Change to the other player's answer "], [3, '3. The answers are the same']], label="Do you wish to stick to your original answer or switch to the other participant's answer?") Response1 = models.IntegerField(choices=[[1, '1. Response 1'], [2, '2. Response 2']], label='Please select your response.') Confidence1 = models.IntegerField(choices=[[1, '1. Not at all confident.'], [2, '2. A little confident. '], [3, '3. Somewhat confident. '], [4, '4. Quite confident. '], [5, '5. Very confident. '], [6, '6. Extremely confident.'], [7, '7. Perfectly confident. '], [8, '8. So confident I cannot imagine ever changing my mind. '], [9, '9. As confident as the things I am most confident about. ']], label='How confident are you in your answer?') agreed_answer_1 = models.IntegerField() Reason2 = models.LongStringField(label='Give reasons for your answer to the puzzle. These reasons will be transmitted to the other participant prior to voting on the agreed response. The text box will expand if required.') Goodreason2 = models.IntegerField(choices=[[1, '1. Very poor reason'], [2, '2. Poor reason'], [3, '3. Average reason'], [4, '4. Good reason'], [5, '5. Very good reason'], [6, '6. Extremely good reason'], [7, '7. A demonstrative reason that perfectly supports its conclusion ']], label='How would you rate the quality of the reasons you gave?') Reasonother2 = models.IntegerField(choices=[[1, '1. Very poor reason '], [2, '2. Poor reason'], [3, '3. Average reason'], [4, '4. Good reason'], [5, '5. Very good reason'], [6, '6. Extremely good reason'], [7, '7. A demonstrative reason that perfectly supports its conclusion']], label="How would you rate the quality of the other participant's reason?") Choice2 = models.IntegerField(choices=[[1, '1. Stick to my original answer'], [2, "2. Change to the other participant's answer"], [3, '3. The answers are the same']], label="Do you wish to stick to your original answer or switch to the other participant's answer?") Confidence2 = models.IntegerField(choices=[[1, '1. Not confident at all'], [2, '2. A little confident'], [3, '3. Somewhat confident '], [4, '4. Quite confident'], [5, '5. Very confident '], [6, '6. Extremely confident '], [7, '7.Perfectly confident'], [8, "8. So confident I can't ever imagine changing my mind"], [9, '9. As confident as the things I am most confident about']], label='How confident are you in your answer?') Response2 = models.IntegerField(choices=[[1, '1. Response 1'], [2, '2. Response 2']], label='Please select your response.') agreed_answer_2 = models.IntegerField() power = models.IntegerField(choices=[[1, '1. Very powerless'], [2, '2'], [3, '3'], [4, '4. Neutral'], [5, '5'], [6, '6'], [7, '7. Very powerful']], label='During the process of interacting with the other participant, how powerful did you feel?', widget=widgets.RadioSelectHorizontal) gender = models.StringField(choices=[['Man', 'Man'], ['Woman', 'Woman'], ['Identify myself in another way', 'Identify myself in another way'], ['Prefer not to say', 'Prefer not to say']], label='Are you a man or a woman?') prolific_id = models.StringField(label='To take part, enter your Prolific ID') other_player = other_player class Instructions(Page): form_model = 'player' form_fields = ['prolific_id'] class Wait0(WaitPage): pass class Puzzle1(Page): form_model = 'player' form_fields = ['Response1', 'Confidence1', 'Reason1', 'Goodreason1'] timeout_seconds = 300 class Wait(WaitPage): pass class Exchange1(Page): form_model = 'player' form_fields = ['Reasonother1', 'Choice1'] @staticmethod def vars_for_template(player): return dict(other_player_reason=player.other_player().Reason1, other_player_response=player.other_player().Response1) class Wait2(WaitPage): after_all_players_arrive = agree_1 class Agree1(Page): form_model = 'player' class Puzzle2(Page): form_model = 'player' form_fields = ['Response2', 'Reason2', 'Confidence2', 'Goodreason2'] timeout_seconds = 300 class Wait3(WaitPage): pass class Exchange2(Page): form_model = 'player' form_fields = ['Reasonother2', 'Choice2'] @staticmethod def vars_for_template(player): return dict(other_player_reason=player.other_player().Reason2, other_player_response=player.other_player().Response2) class Wait4(WaitPage): after_all_players_arrive = agree_2 class Agree2(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): group = player.group set_payoffs(group) class Power(Page): form_model = 'player' form_fields = ['power', 'gender'] class End(Page): form_model = 'player' page_sequence = [Instructions, Wait0, Puzzle1, Wait, Exchange1, Wait2, Agree1, Puzzle2, Wait3, Exchange2, Wait4, Agree2, Power, End]