from otree import settings from otree.api import * import time doc = """ Introduction """ class Constants(BaseConstants): name_in_url = "CountingInstructions" players_per_group = None num_rounds = 1 captcha_length = 3 #SUBSESSION class Subsession(BaseSubsession): pass #GROUP class Group(BaseGroup): pass #PLAYER class Player(BasePlayer): treatment = models.StringField() time_inst = models.FloatField() time_rank = models.FloatField() time_survey1 = models.FloatField() time_survey2 = models.FloatField() time_attention = models.FloatField() comp_failed_attempts = models.IntegerField(label="Errors in Comprehension test for Digit Recall",initial=0) attention_attempts = models.IntegerField(label="Errors in Attention Check",initial=0) comp_score = models.IntegerField( choices=[[0, "The number of tables you solve correctly within 4 minutes"], [1, "The number of As present in the tables"], [2, "The number of attempts you make"]], label="What does your score depend on?", widget=widgets.RadioSelect, blank=True ) comp_version = models.IntegerField( choices=[[0, "Count how many times character B appears in the table"], [1, "Count how many times character A appears in the table"], [2, "There is no Version A"]], label="What do you have to do if you are assigned version A?", widget=widgets.RadioSelect, blank=True ) comp_table = models.IntegerField( choices=[[0, "No"], [1, "Yes"]], label="Are there any differences in the tables between versions?", widget=widgets.RadioSelect, blank=True ) comparisson = models.IntegerField( choices=[[1, "1: Getting Version A is a major advantage"], [2, "2"], [3, "3"], [4, "4: Both versions are approximately the same"], [5, "5"], [6, "6"], [7, "7: Getting Version B is a major advantage"]], label="Do you think any version confers an advantage for achieving higher scores?", widget=widgets.RadioSelect, blank=True ) preference_ranking = models.StringField() similar = models.IntegerField( choices = [[1, "Not at all"], [2, "Slightly"], [3, "Moderately"], [4, "Completely"]], label="Do the two versions of the task feel similar to you??", widget=widgets.RadioSelect, blank=True ) attention = models.IntegerField( choices=[[1, "A"], [2, "B"], [3, "C"], [4, "D"]], label="Attention check", widget=widgets.RadioSelect, blank=True ) #FUNCTIONS def comp_score_error_message(player, value): if value not in [0, 1, 2]: return 'You have to select one of the options.' def comp_version_error_message(player, value): if value not in [0, 1, 2]: return 'You have to select one of the options.' def comp_table_error_message(player, value): if value not in [0, 1]: return 'You have to select one of the options.' def similar_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' def comparisson_error_message(player, value): if value not in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: return 'You have to select one of the options.' def attention_error_message(player, value): if value not in [1, 2, 3, 4]: return 'You have to select one of the options.' #PAGES class Instructions(Page): form_model = 'player' form_fields = ['comp_score', 'comp_version', 'comp_table'] @staticmethod def error_message(player: Player, values): solutions = dict(comp_score=0, comp_version=1, comp_table=0) if values != solutions: player.comp_failed_attempts += 1 return "At least one answer is not correct." @staticmethod def before_next_page(player, timeout_happened): player.time_inst = round(time.time(),3) class PreSurvey(Page): pass class Ranking(Page): form_model = 'player' form_fields = ['preference_ranking'] @staticmethod def before_next_page(player, timeout_happened): player.time_rank = round(time.time(),3) class Survey1(Page): form_model = 'player' form_fields = ['similar'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey1 = round(time.time(),3) class Survey2(Page): form_model = 'player' form_fields = ['comparisson'] @staticmethod def before_next_page(player, timeout_happened): participant = player.participant participant.prior = player.comparisson player.time_survey2 = round(time.time(),3) class Attention(Page): form_model = 'player' form_fields = ['attention'] @staticmethod def error_message(player: Player, values): solutions = dict(attention=3) if values != solutions: player.attention_attempts += 1 return "Please read the question carefully." @staticmethod def before_next_page(player, timeout_happened): player.time_attention = round(time.time(),3) #SEQUENCE page_sequence = [Instructions, PreSurvey, Ranking, Survey1, Survey2, Attention]