from otree import settings from otree.api import * import time doc = """ Survey """ #SESSION class Constants(BaseConstants): name_in_url = "Survey" players_per_group = None num_rounds = 1 #SUBSESSION class Subsession(BaseSubsession): pass #GROUP class Group(BaseGroup): pass ##PLAYER class Player(BasePlayer): time_survey0 = models.FloatField() time_survey1 = models.FloatField() time_survey2 = models.FloatField() time_survey3 = models.FloatField() time_survey4 = models.FloatField() time_survey5 = models.FloatField() time_survey6 = models.FloatField() time_survey7 = models.FloatField() comp1 = models.IntegerField( choices=[[1, 'True'],[0, 'False']], label='The version of the task (Version A or Version B) is randomly assigned to each person.', widget=widgets.RadioSelect, blank=True ) comp2 = models.IntegerField( choices=[[1, 'True'],[0, 'False']], label='Agents spend the same amount of time on the task and receive the same fixed payment to compensate them for their participation.', widget=widgets.RadioSelect, blank=True ) comp3 = models.IntegerField( choices=[[0, 'Agent A'],[1, 'Agent B']], label='Which agent had to count the number of times the letter "A" appears in the tables?', widget=widgets.RadioSelect, blank=True ) comp_failed_attempts = models.IntegerField(initial=0) inferA = models.IntegerField(min=0,max=50) inferB = models.IntegerField(min=0,max=50) probability = models.IntegerField(min=0,max=100) inferA_confidence = models.IntegerField( choices=[[0, 'Not at all sure'], [1, 'A little sure'], [2, 'Somewhat sure'], [3, 'Very sure'], [4, 'Completely sure']], label='How sure are you about your answer?', widget=widgets.RadioSelect, blank=True ) inferB_confidence = models.IntegerField( choices=[[0, 'Not at all sure'], [1, 'A little sure'], [2, 'Somewhat sure'], [3, 'Very sure'], [4, 'Completely sure']], label='How sure are you about your answer?', widget=widgets.RadioSelect, blank=True ) probability_confidence = models.IntegerField( choices=[[0, 'Not at all sure'], [1, 'A little sure'], [2, 'Somewhat sure'], [3, 'Very sure'], [4, 'Completely sure']], label='How sure are you about your answer?', widget=widgets.RadioSelect, blank=True ) #FUNCTIONS def comp1_error_message(player, value): if value not in [0, 1]: return 'You have to select one of the options.' def comp2_error_message(player, value): if value not in [0, 1]: return 'You have to select one of the options.' def comp3_error_message(player, value): if value not in [0, 1]: return 'You have to select one of the options.' def inferA_confidence_error_message(player, value): if value not in [0, 1, 2, 3, 4]: return 'You have to select one of the options.' def inferB_confidence_error_message(player, value): if value not in [0, 1, 2, 3, 4]: return 'You have to select one of the options.' def probability_confidence_error_message(player, value): if value not in [0, 1, 2, 3, 4]: return 'You have to select one of the options.' #PAGES class Intro(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): player.time_survey0 = round(time.time(),3) def is_displayed(player): participant = player.participant return participant.treatment not in ['STORY','STAT'] class IntroAlternative(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): player.time_survey0 = round(time.time(),3) def is_displayed(player): participant = player.participant return participant.treatment in ['STORY','STAT'] class Context(Page): form_model = 'player' form_fields = ['comp1','comp2','comp3'] @staticmethod def error_message(player: Player, values): solutions = dict(comp1=1, comp2=1, comp3=0) errors = {f: 'Wrong answer! Please try again' for f in solutions if values[f] != solutions[f]} if errors: player.comp_failed_attempts += 1 return errors @staticmethod def before_next_page(player, timeout_happened): player.time_survey1 = round(time.time(),3) def is_displayed(player): participant = player.participant return participant.treatment not in ['STORY','STAT'] class ComprehensionResult(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): player.time_survey2 = round(time.time(),3) def is_displayed(player): participant = player.participant return participant.treatment not in ['STORY','STAT'] class Incentives(Page): form_model = 'player' def is_displayed(player): participant = player.participant return participant.treatment in ['EASY', 'HARD'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey3 = round(time.time(),3) class NoIncentives(Page): form_model = 'player' def is_displayed(player): participant = player.participant return participant.treatment in ['MIXED0', 'MIXED1', 'STORY', 'STAT'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey3 = round(time.time(),3) class InferA(Page): form_model = 'player' form_fields = ['inferA', 'inferA_confidence'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey4 = round(time.time(),3) class InferB(Page): form_model = 'player' form_fields = ['inferB', 'inferB_confidence'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey5 = round(time.time(),3) class Probability(Page): form_model = 'player' form_fields = ['probability', 'probability_confidence'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey6 = round(time.time(),3) class SurveyFinal(Page): form_model = 'player' def is_displayed(player): participant = player.participant return participant.treatment in ['EASY', 'HARD'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey7 = round(time.time(),3) class SurveyFinal2(Page): form_model = 'player' def is_displayed(player): participant = player.participant return participant.treatment in ['MIXED0', 'MIXED1', 'STORY', 'STAT'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey7 = round(time.time(),3) #SEQUENCE page_sequence = [Intro, IntroAlternative, Context, ComprehensionResult, Incentives,NoIncentives, InferA, InferB, Probability, SurveyFinal,SurveyFinal2]