from otree.api import * c = Currency doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'umfrage' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): payoff_player = models.IntegerField(initial=0) #Control Variables gender = models.StringField( label="Was ist Ihr Geschlecht?", choices=['Männlich', 'Weiblich', 'Keine Angabe'], widget=widgets.RadioSelect ) age = models.StringField( label="Wie alt sind Sie?", choices=['<18', '18-21', '22-25', '26-29', '>30'], widget=widgets.RadioSelect ) education = models.StringField( label="Was ist Ihr derzeitiger Bildungsstand? (höchste abgeschlossene Ausbildung)", choices=['Master/Diplom', 'Bachelor', 'Kaufmännische Ausbildung', 'Abitur', 'Keine Antwort zutreffend'], widget=widgets.RadioSelect ) study = models.StringField( label="In welcher Fachrichtung liegt/lag Ihr Studium?", choices=['Wirtschaftswissenschaften', 'Ingenieurswissenschaften', 'Naturwissenschaften', 'Geisteswissenschaften', 'Informatik/Mathematik', 'Andere'], widget=widgets.RadioSelect ) game_theory = models.StringField( label="Wie gut schätzen Sie Ihre Kenntnisse im Bereich der Spieltheorie ein?", choices=['Sehr gut', 'Gut', 'Grundlegend', 'Gering', 'Keine'], widget=widgets.RadioSelect ) comprehension = models.StringField( label="Wie gut haben Sie die Instruktionen und den Spielablauf verstanden? ", choices=['Sehr gut', 'Gut', 'Grundlegend', 'Kaum', 'Gar nicht'], widget=widgets.RadioSelect ) #Strategy Variables strategy1 = models.LongStringField( label="Welches Ziel haben Sie in Ihrer Rolle jeweils verfolgt?" ) strategy2 = models.LongStringField( label="Inwiefern haben Sie Ihre Strategie zwischen den beiden Spielen verändert?" ) # PAGES class MyPageWaitPage(WaitPage): @staticmethod def after_all_players_arrive(group: Group): pass class MyPage(Page): form_model = 'player' form_fields = ['gender', 'age', 'education', 'study', 'game_theory', 'comprehension', 'strategy1', 'strategy2'] def vars_for_template(player: Player): player.payoff_player = 0 class FinalPage(Page): def vars_for_template(player: Player): print(player.participant.payoff) #Store Payout in currency field if player.payoff_player == 0: player.payoff_player = 1 player.participant.payoff += cu(4000) print("Payoff Entrant ", player.participant.payoff) # Store Payout in currency field return dict( FinalPayoff_Points=player.participant.payoff+4000, FinalPayoff_Euro=player.participant.payoff.to_real_world_currency(player.session)+4 ) page_sequence = [MyPage, FinalPage]