from otree import settings from otree.api import * import time import random doc = """ Decisions """ #SESSION class Constants(BaseConstants): name_in_url = "Decisions" players_per_group = None num_rounds = 1 #SUBSESSION class Subsession(BaseSubsession): pass #GROUP class Group(BaseGroup): pass ##PLAYER class Player(BasePlayer): time_decisions0 = models.FloatField() time_decisions1 = models.FloatField() time_decisions2 = models.FloatField() time_decisions3 = models.FloatField() time_decisions4 = models.FloatField() time_decisions5 = models.FloatField() time_decisions6 = models.FloatField() time_decisions7 = models.FloatField() time_decisions8 = models.FloatField() time_decisions9 = models.FloatField() time_decisions10 = models.FloatField() time_decisions11 = models.FloatField() time_decisions12 = models.FloatField() time_decisions13 = models.FloatField() time_decisions14 = models.FloatField() spectator_understand = models.IntegerField( choices=[[1, "I understand that my decision can affect the earnings of real people"], [2, "Attention check: Do not select this option"]], label="Spectator Comprehension", widget=widgets.RadioSelect, blank=True ) sgA = models.IntegerField(initial=6,max=6) sgB = models.IntegerField(initial=0,max=6) gammaA = models.IntegerField(initial=6,max=6) gammaB = models.IntegerField(initial=0,max=6) write = models.LongStringField() short_attempts = models.IntegerField(initial=0) fairness = models.IntegerField( choices=[[1, "Completely unfair"], [2, "Somewhat unfair"], [3, "Somewhat fair"], [4, "Completely fair"]], label="How fair do you think the different versions of the task were?", widget=widgets.RadioSelect, blank=True ) talent = models.IntegerField( choices=[[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label='If Agent B had worked really hard, she could have completed more translations than Agent A.', widget=widgets.RadioSelect, blank=True ) versionA = models.BooleanField(initial=False) counterfactual = models.IntegerField( choices=[[0, "Agent A"], [1, "Agent B"], [2, "They would have completed the same amount approximately"]], label='Who do you think would have completed more translations in that case?', widget=widgets.RadioSelect, blank=True ) counterfactual2 = models.IntegerField( choices=[[0, "Agents A would solve many more correct tables"], [1, "Agents A would solve more correct tables"], [2, "Both Agents A and Agents B would solve about the same number of correct tables"], [3, "Agents B would solve more correct tables"], [4, "Agents B would solve many more correct tables"]], label='Which group of agents do you think would solve more correct tables?', widget=widgets.RadioSelect, blank=True ) relevance_effort = models.IntegerField(initial=0) relevance_luck = models.IntegerField(initial=0) comparisson = models.IntegerField( choices=[[1, "1: Agent A had a major advantage"], [2, "2"], [3, "3"], [4, "4: Both agents were on equal footing"], [5, "5"], [6, "6"], [7, "7: Agent B had a major advantage"]], label="Do you think the version of the task assigned to each agent provided any advantage in the competition?", widget=widgets.RadioSelect, blank=True ) empathyA = models.IntegerField( choices=[[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="It is easy for me to imagine Agent A's experience with the task", widget=widgets.RadioSelect, blank=True ) empathyB = models.IntegerField( choices=[[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="It is easy for me to imagine Agent B's experience with the task", widget=widgets.RadioSelect, blank=True ) anger = models.IntegerField( choices = [[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="How much anger did you feel?", widget=widgets.RadioSelect, blank=True ) compassion = models.IntegerField( choices = [[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="How much compassion did you feel?", widget=widgets.RadioSelect, blank=True ) sadness = models.IntegerField( choices = [[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="How much sadness did you feel?", widget=widgets.RadioSelect, blank=True ) indifference = models.IntegerField( choices = [[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="How much indifference did you feel?", widget=widgets.RadioSelect, blank=True ) irritation = models.IntegerField( choices = [[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="How much irritation did you feel?", widget=widgets.RadioSelect, blank=True ) #FUNCTIONS def spectator_understand_error_message(player, value): if value not in [1, 2]: return 'You have to select one of the options.' def fairness_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def talent_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def counterfactual_error_message(player, value): if value not in [0, 1, 2]: return 'You have to select one of the options.' def counterfactual2_error_message(player, value): if value not in [0, 1, 2, 3, 4]: return 'You have to select one of the options.' def empathyA_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def empathyB_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def anger_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def compassion_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def irritation_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def sadness_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def indifference_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' #PAGES class SpectatorIntro(Page): form_model = 'player' form_fields = ['spectator_understand'] @staticmethod def before_next_page(player, timeout_happened): player.time_decisions0 = round(time.time(),3) class SpectatorPair(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): player.time_decisions1 = round(time.time(),3) class SpectatorGame(Page): form_model = 'player' form_fields = ['sgA','sgB'] @staticmethod def before_next_page(player, timeout_happened): player.time_decisions2 = round(time.time(),3) class Narrative(Page): form_model = 'player' form_fields = ['write'] @staticmethod def error_message(player: Player, values): write = values.get('write') if write is None or len(write) < 50: player.short_attempts += 1 return dict(write='Please write a longer response (at least 50 characters).') @staticmethod def before_next_page(player, timeout_happened): player.time_decisions3 = round(time.time(),3) class GammaPair(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): player.time_decisions4 = round(time.time(),3) class GammaGame(Page): form_model = 'player' form_fields = ['gammaA','gammaB'] @staticmethod def before_next_page(player, timeout_happened): player.time_decisions5 = round(time.time(),3) class PreSurvey(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): player.versionA = random.choice([True, False]) player.time_decisions6 = round(time.time(),3) class Fairness(Page): form_model = 'player' form_fields = ['fairness'] @staticmethod def before_next_page(player, timeout_happened): player.time_decisions7 = round(time.time(),3) class Talent(Page): form_model = 'player' form_fields = ['talent'] @staticmethod def before_next_page(player, timeout_happened): player.time_decisions8 = round(time.time(),3) class Counterfactual(Page): form_model = 'player' form_fields = ['counterfactual'] @staticmethod def vars_for_template(player): if player.versionA: version = "A" else: version = "B" return dict( version=version, ) @staticmethod def before_next_page(player, timeout_happened): player.time_decisions9 = round(time.time(),3) class GroupLevel(Page): form_model = 'player' form_fields = ['counterfactual2'] @staticmethod def vars_for_template(player): if player.versionA: version = "A" else: version = "B" return dict( version=version, ) @staticmethod def before_next_page(player, timeout_happened): player.time_decisions10 = round(time.time(),3) class Empathy(Page): form_model = 'player' form_fields = ['empathyA','empathyB'] @staticmethod def before_next_page(player, timeout_happened): player.time_decisions11 = round(time.time(),3) class Ranking(Page): form_model = 'player' form_fields = ['relevance_effort','relevance_luck'] @staticmethod def error_message(player: Player, values): if values['relevance_effort'] + values['relevance_luck'] != 100: player.failed_attempts += 1 return "The sum of points in the first question must equal 100." @staticmethod def before_next_page(player, timeout_happened): player.time_decisions12 = round(time.time(),3) class Comparisson(Page): form_model = 'player' form_fields = ['comparisson'] @staticmethod def vars_for_template(player): participant = player.participant prior = participant.prior return dict( prior=prior, ) @staticmethod def before_next_page(player, timeout_happened): player.time_decisions13 = round(time.time(),3) class Emotions(Page): form_model = 'player' form_fields = ['anger','compassion','sadness','indifference','irritation'] @staticmethod def before_next_page(player, timeout_happened): player.time_decisions14 = round(time.time(),3) #SEQUENCE page_sequence = [SpectatorIntro, SpectatorPair, SpectatorGame, Narrative, GammaPair, GammaGame, PreSurvey, Fairness, Talent, Counterfactual, GroupLevel, Ranking, Comparisson, Empathy, Emotions]