from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Bienvenida(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class Consentimiento(Page): form_model = 'player' form_fields = ['Nombre', 'Cedula'] def is_displayed(self): return self.round_number == 1 class Instrucciones(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class Ejemplos(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class Desarrollo(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class Compresion(Page): form_model = 'player' form_fields = ['Comprension1', 'Comprension2'] def is_displayed(self): return self.round_number == 1 def error_message(self, values): print('values is', values) if values["Comprension1"] != Constants.Answer1: return 'Respuesta a la pregunta 1: 114 puntos ' \ '(+) 12 x 2 = 24 puntos por su inversión en la actividad extractiva. ' \ '(+) 5 x 7 = 35 puntos por las fichas que permanecen en el banco. ' \ '(-) 5 x 5 = 25 puntos menos por la inversión en la actividad extractiva de los demás jugadores. ' \ 'Pago = 80 + 24 + 35 -25 = 114 puntos.' if values["Comprension2"] != Constants.Answer2: return 'Respuesta a la pregunta 2: 99 puntos ' \ '(+) 12 x 7 = 84 puntos por su inversión en la actividad extractiva. ' \ '(+) 5 x 2 = 10 puntos por las fichas que permanecen en el banco. ' \ '(-) 5 x 15 = 75 puntos menos por la inversión en la actividad extractiva de los demás jugadores. ' \ 'Pago = 80 + 84 + 10 -75 = 99 puntos.' class Resultscompre(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class Contribute1(Page): form_model = 'group' form_fields = ['contribution1'] timeout_seconds = 20 def is_displayed(self): return self.player.id_in_group == 1 class Contribute2(Page): form_model = 'group' form_fields = ['contribution2'] timeout_seconds = 20 def is_displayed(self): return self.player.id_in_group == 2 class Contribute3(Page): form_model = 'group' form_fields = ['contribution3'] timeout_seconds = 20 def is_displayed(self): return self.player.id_in_group == 3 class ResultsWaitPage(WaitPage): body_text = 'Waiting for other participants to contribute.' def after_all_players_arrive(self): self.group.set_payoffs() class Resultspage(Page): form_model = 'player' timeout_seconds = 10 def vars_for_template(self): if self.player.id_in_group == 1: return { "PagoA": self.group.contribution1 * 12, "PagoB": (12 - self.group.contribution1) * 5, "Banco": (12 - self.group.contribution1), "Ext": (self.group.contribution2 + self.group.contribution3), "Costo" : (self.group.contribution2 + self.group.contribution3) * 5 } if self.player.id_in_group == 2: return { "PagoA": self.group.contribution2 * 12, "PagoB": (9 - self.group.contribution2) * 5, "Banco": (9 - self.group.contribution2), "Ext": (self.group.contribution1 + self.group.contribution3), "Costo" : (self.group.contribution1 + self.group.contribution3) * 5 } if self.player.id_in_group == 3: return { "PagoA": self.group.contribution3 * 12, "PagoB": (6 - self.group.contribution3) * 5, "Banco":(6 - self.group.contribution3), "Ext": (self.group.contribution1 + self.group.contribution2), "Costo" : (self.group.contribution1 + self.group.contribution2) * 5 } def before_next_page(self): if self.round_number == 3: self.participant.vars["app1"]= self.player.payoff_app() self.player.payoff_app1 = str (self.participant.vars["app1"]) self.participant.vars["rol"]= self.player.role() self.player.Rol = str (self.participant.vars["rol"]) page_sequence = [Bienvenida, Consentimiento, Instrucciones, Ejemplos, Desarrollo, Compresion, Resultscompre, Contribute1, Contribute2, Contribute3, ResultsWaitPage, Resultspage]