import random from otree.api import * doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Study' players_per_group = None tasks = ['UG', 'Doubled', 'Half', 'DG'] num_rounds = len(tasks) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # This is for main choices, each variable is one row in the choice table MPL UG_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) # # These variables are collected in the final questionnaire sex = models.StringField(widget=widgets.RadioSelectHorizontal(), choices=['Male', 'Female']) age = models.IntegerField(choices=range(18, 60, 1)) comment = models.TextField(label="If you had any difficulty or you have any comment write it here!") # FUNCTIONS def creating_session(subsession: Subsession): if subsession.round_number == 1: for p in subsession.get_players(): round_numbers = list(range(1, Constants.num_rounds + 1)) random.shuffle(round_numbers) p.participant.vars['task_rounds'] = dict(zip(Constants.tasks, round_numbers)) # PAGE class ElicitationNormsUG(Page): @staticmethod def is_displayed(player: Player): return player.round_number == player.participant.vars['task_rounds']['UG'] # which forms are needed from class player form_model = 'player' form_fields = ['UG_1', 'UG_2', 'UG_3', 'UG_4', 'UG_5', 'UG_6', 'UG_7', 'UG_8', 'UG_9', 'UG_10', 'UG_11'] # all 11 options class ElicitationNormsDoubled(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] # which forms are needed from class player form_model = 'player' form_fields = ['Doubled_1', 'Doubled_2', 'Doubled_3', 'Doubled_4', 'Doubled_5', 'Doubled_6', 'Doubled_7', 'Doubled_8', 'Doubled_9', 'Doubled_10', 'Doubled_11'] # all 11 options class ElicitationNormsHalf(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] # which forms are needed from class player form_model = 'player' form_fields = ['Half_1', 'Half_2', 'Half_3', 'Half_4', 'Half_5', 'Half_6', 'Half_7', 'Half_8', 'Half_9', 'Half_10', 'Half_11'] class ElicitationNormsDG(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] # which forms are needed from class player form_model = 'player' form_fields = ['DG_1', 'DG_2', 'DG_3', 'DG_4', 'DG_5', 'DG_6', 'DG_7', 'DG_8', 'DG_9', 'DG_10', 'DG_11'] # all 11 options class Instructions1(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class ExampleSituation(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 class SituationDescriptionUG(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG'] # which forms are needed from class player class SituationDescriptionDoubled(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] # which forms are needed from class player form_model = 'player' class SituationDescriptionDG(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] # which forms are needed from class player form_model = 'player' class SituationDescriptionHalf(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] form_model = 'player' class Questionnaire(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds # forms to retrieve individual information form_model = 'player' form_fields = ['comment', 'sex', 'age'] page_sequence = [Instructions1, ExampleSituation, SituationDescriptionUG, ElicitationNormsUG, SituationDescriptionDoubled, ElicitationNormsDoubled, SituationDescriptionHalf, ElicitationNormsHalf, SituationDescriptionDG, ElicitationNormsDG, Questionnaire]