from otree.api import Currency as c, currency_range from ._builtin import WaitPage, Page as oTreePage from .models import Constants import random import numpy as np statements = ["Soziale Ungleichheit ist in Deutschland ein großes Problem.", "Der Spitzensteuersatz für die höchsten Einkommen sollte angehoben werden.", "Die allgemeine Steuerlast in Deutschland ist zu hoch.", "Es ist gut, dass es in Deutschland keine Vermögenssteuer gibt.",] frames = ["l", "l", "r", "r",] class Page(oTreePage): def get_progress(self): totpages = self.participant._max_page_index curpage = self.participant._index_in_pages return f"{curpage / totpages * 100:.0f}" class Introduction(Page): def is_displayed(self): return (self.player.round_number == 1) def before_next_page(self): p = self.player indices = [0,1,2,3] random.shuffle(indices) for r in [1,2,3,4]: p.in_round(r).statement = statements[indices[r-1]] p.in_round(r).frame = frames[indices[r-1]] if r == 4: p.in_round(r).realized_bool = self.participant.vars["realized_bool"] p.in_round(r).realized_stage = self.participant.vars["realized_stage"] p.in_round(r).iban = self.participant.vars["iban"] for r in [1,2,3,4]: self.player.in_round(r).progress = np.int(100*self.participant._index_in_pages / self.participant._max_page_index) class Statement(Page): form_model = 'player' form_fields = ['answer'] def before_next_page(self): for r in [1,2,3,4]: self.player.in_round(r).progress = np.int(100*self.participant._index_in_pages / self.participant._max_page_index) def vars_for_template(self): return {'progress': self.player.progress} class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'education', 'income', 'occupation', 'studyfield', 'motive', 'no_age', 'no_gender', 'no_education', 'no_income', 'no_occupation', 'no_studyfield'] def is_displayed(self): return (self.player.round_number == 4) def before_next_page(self): for r in [1,2,3,4]: self.player.in_round(r).progress = np.int(100*self.participant._index_in_pages / self.participant._max_page_index) def vars_for_template(self): return {'progress': self.player.progress} def error_message(self, values): message = "" c_age = (values["age"] is None) and (values["no_age"] is None) c_gender = (values["gender"] is None) and (values["no_gender"] is None) c_education = (values["education"] is None) and (values["no_education"] is None) c_occupation = (values["occupation"] is None) and (values["no_occupation"] is None) c_studyfield = (values["studyfield"] is None) and (values["no_studyfield"] is None) c_income = (values["income"] is None) and (values["no_income"] is None) if c_age: message = message + 'Bitte geben Sie entweder Ihr Alter an oder wählen Sie "Keine Angabe". ' if c_gender: message = message + 'Bitte geben Sie entweder Ihr Geschlecht an oder wählen Sie "Keine Angabe". ' if c_education: message = message + 'Bitte geben Sie entweder Ihren Bildungsabschluss an oder wählen Sie "Keine Angabe". ' if c_occupation: message = message + 'Bitte geben Sie entweder Ihre Hauptbeschäftigung an oder wählen Sie "Keine Angabe". ' if c_studyfield: message = message + 'Bitte geben Sie entweder Ihr Studien-/Berufsfeld an oder wählen Sie "Keine Angabe". ' if c_income: message = message + 'Bitte geben Sie entweder Ihr Einkommen an oder wählen Sie "Keine Angabe". ' if c_age or c_gender or c_education or c_occupation or c_studyfield or c_income: return message class End(Page): def is_displayed(self): return (self.player.round_number == 4) page_sequence = [Introduction, Statement, Demographics, End]