from otree.api import * class C(BaseConstants): NAME_IN_URL = 'Questionnaire' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField(min=1960, max=2006, doc="age in years") gender = models.IntegerField(choices=[[1, 'männlich'], [2, 'weiblich'], [3, 'divers']], widget=widgets.RadioSelectHorizontal) studies = models.IntegerField(choices=[[1, 'Rechtswissenschaften'], [2, 'Volkswirtschaft'], [3, 'Sozialwissenschaft'], [4, 'Betriebswirtschaft'], [5, 'Medizin'], [6, 'Erziehungswissenschaft'], [7, 'Geisteswissenschaft'], [8, 'Informatik'], [9, 'Mathematik'], [10, 'Naturwissenschaft'], [11, 'Psychologie'], [12, 'Bewegungswissenschaften'], [13, 'Sonstiges']], doc="field of studies") semester = models.IntegerField(min=0, max=35, doc="semester") work = models.IntegerField(choices=[[1, 'Ja'], [2,'Nein']]) bafog = models.IntegerField(choices=[[1, 'Ja'], [2,'Nein']]) education = models.IntegerField(choices=[(1, 'kein Abschluss'), (2, 'Hauptschulabschluss'), (3, 'Realschulabschluss'), (4, 'Abitur'), (5, 'Bachelorabschluss'), (6, 'Masterabschluss'), (7, 'Promotion')]) income = models.IntegerField(choices=[(1, 'weniger als 1.000 Euro'), (2, 'zwischen 1.000 - 2.000 Euro'), (3, 'zwischen 2.000 - 3.000 Euro'), (4, 'zwischen 3.000 - 4.000 Euro'), (5, 'mehr als 4.000 Euro')]) nationality = models.StringField() religion = models.StringField() partypreferences = models.IntegerField( choices=[ [1, "Extrem links"], [2, "Links"], [3, "In der Mitte"], [4, "Rechts"], [5, "Extrem rechts"], [6, "Keine Angabe"], ] ) opinion = models.IntegerField(choices=[[1, 'Nicht wichtig'], [2,'Eher nicht wichtig'], [3, 'Weder wichtig, noch unwichtig'], [4, 'Eher wichtig'], [5, 'Sehr wichtig']]) car_km = models.IntegerField() car_justified = models.IntegerField(choices=[[1, 'Voll und ganz gerechtfertigt'], [2,'Eher gerechtfertigt'], [3, 'Weder/Noch'], [4, 'Weniger gerechtfertigt'], [5, 'Gar nicht gerechtfertigt']]) SQ_Abwesenheit_1 = models.BooleanField(blank=True) SQ_Abwesenheit_2 = models.BooleanField(blank=True) SQ_Abwesenheit_3 = models.BooleanField(blank=True) SQ_Abwesenheit_4 = models.BooleanField(blank=True) SQ_Abwesenheit_5 = models.BooleanField(blank=True) SQ_Abwesenheit_6 = models.BooleanField(blank=True) SQ_Abwesenheit_7 = models.BooleanField(blank=True) SQ_unreguliert_1 = models.BooleanField(blank=True) SQ_unreguliert_2 = models.BooleanField(blank=True) SQ_unreguliert_3 = models.BooleanField(blank=True) SQ_unreguliert_4 = models.BooleanField(blank=True) SQ_unreguliert_5 = models.BooleanField(blank=True) SQ_unreguliert_6 = models.BooleanField(blank=True) SQ_unreguliert_7 = models.BooleanField(blank=True) def rating_field(): return models.IntegerField( choices=[ [1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], ], widget=widgets.RadioSelectHorizontal ) scale1 = rating_field() scale2 = rating_field() scale3 = rating_field() scale4 = rating_field() scale5 = rating_field() scale6 = rating_field() scale7 = rating_field() scale8 = rating_field() scale9 = rating_field() scale10 = rating_field() scale11 = rating_field() scale12 = rating_field() scale13 = rating_field() # FUNCTIONS # PAGES class Soziodemographie(Page): form_model = 'player' form_fields = ['age', 'gender', 'studies', 'semester', 'work', 'bafog', 'education', 'income', 'nationality', 'religion', 'partypreferences'] class Reasons(Page): form_model = 'player' form_fields = ['opinion', 'car_justified', 'car_km'] class OUS_Scale(Page): form_model = 'player' form_fields = ['scale1', 'scale2', 'scale3', 'scale4', 'scale5', 'scale6', 'scale7', 'scale8', 'scale9'] class Scale2(Page): form_model = 'player' form_fields = ['scale10', 'scale11', 'scale12', 'scale13'] class Deontologie_Frage1(Page): form_model = 'player' form_fields = ['SQ_unreguliert_1', 'SQ_unreguliert_2', 'SQ_unreguliert_3', 'SQ_unreguliert_4', 'SQ_unreguliert_5', 'SQ_unreguliert_6', 'SQ_unreguliert_7'] @staticmethod def is_displayed(player): return player.id_in_group % 2 == 0 class Deontologie_Frage2(Page): form_model = 'player' form_fields = ['SQ_Abwesenheit_1', 'SQ_Abwesenheit_2', 'SQ_Abwesenheit_3', 'SQ_Abwesenheit_4', 'SQ_Abwesenheit_5', 'SQ_Abwesenheit_6', 'SQ_Abwesenheit_7'] @staticmethod def is_displayed(player): return player.id_in_group % 2 != 0 class Results(Page): @staticmethod def vars_for_template(player: Player): session = player.session participant = player.participant payoff = participant.payoff.to_real_world_currency(session) return dict(payoff=payoff) page_sequence = [ Soziodemographie, Reasons, OUS_Scale, Scale2, Deontologie_Frage1, Deontologie_Frage2, Results]