from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) from decimal import Decimal author = 'Magnus Strobel' doc = """ Your app description """ def create_conditional_contribution_question(label): return models.FloatField( # blank = True, min=0, max=Constants.endowment, label = label, ) class Constants(BaseConstants): name_in_url = 'public_goods_game' players_per_group = None num_rounds = 1 endowment = 4 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): guess_player_A = models.FloatField( label="" ) guess_player_B = models.FloatField( label="" ) contribution_unconditional = models.FloatField( min=0, max=Constants.endowment, label="How much would you like to pay into the project?" ) def contribution_unconditional_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_0 = create_conditional_contribution_question("") def contribution_conditional_0_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_1 = create_conditional_contribution_question("") def contribution_conditional_1_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_2 = create_conditional_contribution_question("") def contribution_conditional_2_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_3 = create_conditional_contribution_question("") def contribution_conditional_3_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_4 = create_conditional_contribution_question("") def contribution_conditional_4_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_5 = create_conditional_contribution_question("") def contribution_conditional_5_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_6 = create_conditional_contribution_question("") def contribution_conditional_6_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_7 = create_conditional_contribution_question("") def contribution_conditional_7_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_8 = create_conditional_contribution_question("") def contribution_conditional_8_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_9 = create_conditional_contribution_question("") def contribution_conditional_9_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_10 = create_conditional_contribution_question("") def contribution_conditional_10_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_11 = create_conditional_contribution_question("") def contribution_conditional_11_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_12 = create_conditional_contribution_question("") def contribution_conditional_12_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_13 = create_conditional_contribution_question("") def contribution_conditional_13_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_14 = create_conditional_contribution_question("") def contribution_conditional_14_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_15 = create_conditional_contribution_question("") def contribution_conditional_15_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_16 = create_conditional_contribution_question("") def contribution_conditional_16_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_17 = create_conditional_contribution_question("") def contribution_conditional_17_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_18 = create_conditional_contribution_question("") def contribution_conditional_18_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_19 = create_conditional_contribution_question("") def contribution_conditional_19_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' contribution_conditional_20 = create_conditional_contribution_question("") def contribution_conditional_20_error_message(self, value): if Decimal(str(value)) % Decimal(str(0.2)) != 0: return 'Please choose a value which is divisible by 0.2!' ### Control questions ### control_question_1_a = models.FloatField(choices=[[0, "€0"], [2, "€2"], [4, "€4"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_1_a_error_message(self, value): correct_answer = 0 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message control_question_1_b = models.FloatField(choices=[[0, "€0"], [2, "€2"], [4, "€4"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_1_b_error_message(self, value): correct_answer = 4 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message control_question_2_a = models.FloatField(choices=[[0, "€0"], [2.4, "€2.4"], [4.8, "€4.8"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_2_a_error_message(self, value): correct_answer = 2.4 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message control_question_2_b = models.FloatField(choices=[[0, "€0"], [2.4, "€2.4"], [4.8, "€4.8"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_2_b_error_message(self, value): correct_answer = 2.4 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message control_question_3_a = models.FloatField(choices=[[0, "€0"], [2.4, "€2.4"], [4.8, "€4.8"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_3_a_error_message(self, value): correct_answer = 2.4 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message control_question_3_b = models.FloatField(choices=[[0, "€0"], [2.4, "€2.4"], [4.8, "€4.8"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_3_b_error_message(self, value): correct_answer = 6.4 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message control_question_4_a = models.FloatField(choices=[[0, "€0"], [2.4, "€2.4"], [4.8, "€4.8"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_4_a_error_message(self, value): correct_answer = 4.8 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message control_question_4_b = models.FloatField(choices=[[0, "€0"], [2.4, "€2.4"], [4.8, "€4.8"], [6.4, "€6.4"]], widget=widgets.RadioSelectHorizontal, label="") def control_question_4_b_error_message(self, value): correct_answer = 4.8 if value != correct_answer: error_message = "Your answer is wrong. The correct answer is: €" + str(correct_answer) + ". Please choose the correct answer to proceed." return error_message