from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Magnus Strobel' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'public_goods_game_unconditional' players_per_group = None num_rounds = 1 endowment = c(20) class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): p.participant.vars["public_goods_game_instructions"] = "public_goods_game_unconditional/Instructions_text.html" class Group(BaseGroup): total_contribution = models.CurrencyField() class Player(BasePlayer): contribution = models.CurrencyField(min=0, max=Constants.endowment) control_question_1_a = models.IntegerField(choices=[[0, "0 Punkte"], [10, "10 Punkte"], [20, "20 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_1_a_error_message(self, value): correct_answer = 0 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message control_question_1_b = models.IntegerField(choices=[[0, "0 Punkte"], [10, "10 Punkte"], [20, "20 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_1_b_error_message(self, value): correct_answer = 20 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message control_question_2_a = models.IntegerField(choices=[[0, "0 Punkte"], [10, "10 Punkte"], [20, "20 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_2_a_error_message(self, value): correct_answer = 32 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message control_question_2_b = models.IntegerField(choices=[[0, "0 Punkte"], [10, "10 Punkte"], [20, "20 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_2_b_error_message(self, value): correct_answer = 32 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message control_question_3_a = models.IntegerField(choices=[[8, "8 Punkte"], [12, "12 Punkte"], [18, "18 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_3_a_error_message(self, value): correct_answer = 12 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message control_question_3_b = models.IntegerField(choices=[[8, "8 Punkte"], [12, "12 Punkte"], [18, "18 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_3_b_error_message(self, value): correct_answer = 32 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message control_question_4_a = models.IntegerField(choices=[[0, "0 Punkte"], [8, "8 Punkte"], [13, "13 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_4_a_error_message(self, value): correct_answer = 8 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message control_question_4_b = models.IntegerField(choices=[[0, "0 Punkte"], [8, "8 Punkte"], [13, "13 Punkte"], [32, "32 Punkte"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_4_b_error_message(self, value): correct_answer = 13 if value != correct_answer: error_message = "Ihre Antwort ist falsch. Die richtige Antwort lautet " + str(correct_answer) + " Punkte. Bitte wählen Sie die richtige Antwort um fortzufahren." return error_message