from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class MyPage(Page): pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): pass class task1(Page): def is_displayed(self): return self.player.treat == 'investor' and self.player.treat_investor == 'GradeCI' form_model = 'player' form_fields = ['invest_dec1_i1', 'invest_dec1_i2'] def error_message(self, values): if values["invest_dec1_i1"] + values["invest_dec1_i2"] > 10: return 'Sie können nicht mehr als 10€ investieren.' def vars_for_template(self): grade_1 = [other.promotion_grade for other in self.player.get_others_in_subsession() if other.id_in_subsession == self.player.dec1_i1][0] grade_2 = [other.promotion_grade for other in self.player.get_others_in_subsession() if other.id_in_subsession == self.player.dec1_i2][0] photo_1 = [other.photoid for other in self.player.get_others_in_subsession() if other.id_in_subsession == self.player.dec1_i1][0] ## das gleiche wie mit grades nur dass hier die jeweiligen fotos aufgerufen werden photo_2 = [other.photoid for other in self.player.get_others_in_subsession() if other.id_in_subsession == self.player.dec1_i2][0] return dict(promo1="{}".format(grade_1), promo2="{}".format(grade_2), photo1= "image_upload/photo{}.jpg".format(photo_1), photo2= "image_upload/photo{}.jpg".format(photo_2)) class Results(Page): pass page_sequence = [MyPage, ResultsWaitPage, Results]