from otree.api import * class C(BaseConstants): NAME_IN_URL = 'survey_post_treatment' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 # Labels for the 6-point Likert scale Age_CHOICES = [ [1, '18-25 years old'], [2, '26-35 years old'], [3, '35-45 years old'], [4, '46-55 years old'], [5, '56-65 years old'], [6, 'More than 66 years old'], ] Education_CHOICES = [ [1, 'No education'], [2, 'High school diploma or lower'], [3, 'More'], ] Gender_CHOICES = [ [1, 'Male'], [2, 'Female'], [3, 'Other'], ] ForestSize_CHOICES = [ [0, 'No forest land'], [1, 'less than 1 ha'], [2, 'From 2 to 5 ha'], [3, 'From 6 to 10 ha'], [4, 'More than 10 ha'], ] ActivityForest_CHOICES = [ [1, 'Main activity'], [2, 'Secondary activity'], [3, 'Not part of my activities'], ] Income_CHOICES = [ [1, 'Poor'], [2, 'Not too poor'], [3, 'Quite rich'], [4, 'Loaded'], ] DEM_ITEMS = { 'dem_1': {'label': 'What is your age?', 'choices': Age_CHOICES}, 'dem_2': {'label': 'What is the maximum level of education achieved?', 'choices': Education_CHOICES}, 'dem_3': {'label': 'What is your gender?', 'choices': Gender_CHOICES}, 'dem_4': {'label': 'What is the size of your forest?', 'choices': ForestSize_CHOICES}, 'dem_5': {'label': 'Does managing your forest take a big part of your activity?', 'choices': ActivityForest_CHOICES}, 'dem_6': {'label': 'What is your income?', 'choices': Income_CHOICES}, } class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # --- Individualism-Communitarianism items --- # Each is a 1–6 Likert item; ic_4 is reverse-scored dem_1 = models.IntegerField( label=C.DEM_ITEMS['dem_1']['label'], choices=C.Age_CHOICES, widget=widgets.RadioSelect, ) dem_2 = models.IntegerField( label=C.DEM_ITEMS['dem_2']['label'], choices=C.Education_CHOICES, widget=widgets.RadioSelect, ) dem_3 = models.IntegerField( label=C.DEM_ITEMS['dem_3']['label'], choices=C.Gender_CHOICES, widget=widgets.RadioSelect, ) dem_4 = models.IntegerField( label=C.DEM_ITEMS['dem_4']['label'], choices=C.ForestSize_CHOICES, widget=widgets.RadioSelect, ) dem_5 = models.IntegerField( label=C.DEM_ITEMS['dem_5']['label'], choices=C.ActivityForest_CHOICES, widget=widgets.RadioSelect, ) dem_6 = models.IntegerField( label=C.DEM_ITEMS['dem_6']['label'], choices=C.Income_CHOICES, widget=widgets.RadioSelect, ) # --- Pages --- class Demographics(Page): form_model = 'player' form_fields = ['dem_1', 'dem_2', 'dem_3', 'dem_4', 'dem_5', 'dem_6'] @staticmethod def vars_for_template(player: Player): # No randomisation — fixed order items = [] for field_name, meta in C.DEM_ITEMS.items(): items.append({ 'name': field_name, 'label': meta['label'], 'choices': meta['choices'], }) fields_order = [item['name'] for item in items] return { 'items': items, 'fields_order': fields_order, } page_sequence = [Demographics]