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 total_page_count = 59 #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.",] statements = ["Auf hohe Vermögen soll in Deutschland wieder eine Steuer erhoben werden.", "Der Mindestlohn soll schnellstmöglich auf mindestens 12 Euro erhöht werden.", "Hartz 4 / Arbeitslosengeld II soll weiterhin im Rahmen von Sanktionen gekürzt werden können.", "Das Problem der sozialen Ungleichheit wird in Deutschland größer gemacht, als es eigentlich ist."] frames = ["l", "l", "r", "r",] all_rounds = [1,2,3,4] 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): for r in all_rounds: self.player.in_round(r).progress = np.int(100*self.participant._index_in_pages / self.participant._max_page_index) self.participant.vars['page_count'] = self.participant.vars['page_count'] + 1 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).iban = self.participant.vars["iban"] class Statement(Page): form_model = 'player' form_fields = ['answer'] def before_next_page(self): for r in all_rounds: self.player.in_round(r).progress = np.int(100*self.participant._index_in_pages / self.participant._max_page_index) self.participant.vars['page_count'] = self.participant.vars['page_count'] + 1 def vars_for_template(self): return {'progress': np.int(100*(self.participant.vars['page_count'] / total_page_count))} class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'education', 'income', 'occupation', 'studyfield', '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 all_rounds: self.player.in_round(r).progress = np.int(100*self.participant._index_in_pages / self.participant._max_page_index) self.participant.vars['page_count'] = self.participant.vars['page_count'] + 1 def vars_for_template(self): return {'progress': np.int(100*(self.participant.vars['page_count'] / total_page_count))} def error_message(self, values): message = "" c_age = (values["age"] is None) and not (values["no_age"] is True) c_gender = (values["gender"] is None) and not (values["no_gender"] is True) c_education = (values["education"] is None) and not (values["no_education"] is True) c_occupation = (values["occupation"] is None) and not (values["no_occupation"] is True) c_studyfield = (values["studyfield"] is None) and not (values["no_studyfield"] is True) c_income = (values["income"] is None) and not (values["no_income"] is True) 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 Checkbox(Page): form_model = 'player' form_fields = ['checkmark1'] def is_displayed(self): return (self.player.round_number == 4) def before_next_page(self): for r in all_rounds: self.player.in_round(r).progress = np.int(100*self.participant._index_in_pages / self.participant._max_page_index) self.participant.vars['page_count'] = self.participant.vars['page_count'] + 1 class End(Page): form_model = 'player' def is_displayed(self): return (self.player.round_number == 4) def vars_for_template(self): return {'progress': self.participant.vars['page_count']} page_sequence = [Introduction, Statement, Demographics, Checkbox, End]