from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Instructions_1(Page): form_model = 'player' form_fields = ['control_question_1_a', 'control_question_1_b', 'control_question_2_a', 'control_question_2_b', 'control_question_3_a', 'control_question_3_b', 'control_question_4_a', 'control_question_4_b' ] class Instructions_2(Page): pass class Unconditional_contribution(Page): form_model = 'player' form_fields = ['contribution_unconditional'] class Contribution_table(Page): form_model = "player" def get_form_fields(self): return ['contribution_conditional_{}'.format(i) for i in range(0, 21)] class Belief_contribution(Page): form_model = 'player' form_fields = ['guess_player_A', 'guess_player_B', ] def vars_for_template(self): reported_donation_of_assigned_player_A = self.participant.vars['reported_donation_of_assigned_player_A'] reported_donation_of_assigned_player_B = self.participant.vars['reported_donation_of_assigned_player_B'] reported_amount_kept_of_assigned_player_A = self.participant.vars['reported_amount_kept_of_assigned_player_A'] reported_amount_kept_of_assigned_player_B = self.participant.vars['reported_amount_kept_of_assigned_player_B'] guessed_donated_participant_A_public = self.participant.vars['guessed_donated_participant_A_public'] guessed_kept_participant_A_public = self.participant.vars['guessed_kept_participant_A_public'] guessed_donated_participant_A_private = self.participant.vars['guessed_donated_participant_A_private'] guessed_kept_participant_A_private = self.participant.vars['guessed_kept_participant_A_private'] guessed_donated_participant_B_public = self.participant.vars['guessed_donated_participant_B_public'] guessed_kept_participant_B_public = self.participant.vars['guessed_kept_participant_B_public'] guessed_donated_participant_B_private = self.participant.vars['guessed_donated_participant_B_private'] guessed_kept_participant_B_private = self.participant.vars['guessed_kept_participant_B_private'] return { 'reported_donation_of_assigned_player_A': round(reported_donation_of_assigned_player_A, 2), 'reported_donation_of_assigned_player_B': round(reported_donation_of_assigned_player_B, 2), 'reported_amount_kept_of_assigned_player_A': round(reported_amount_kept_of_assigned_player_A, 2), 'reported_amount_kept_of_assigned_player_B': round(reported_amount_kept_of_assigned_player_B, 2), 'guessed_donated_participant_A_public': guessed_donated_participant_A_public, 'guessed_kept_participant_A_public': guessed_kept_participant_A_public, 'guessed_donated_participant_A_private': guessed_donated_participant_A_private, 'guessed_kept_participant_A_private': guessed_kept_participant_A_private, 'guessed_donated_participant_B_public': guessed_donated_participant_B_public, 'guessed_kept_participant_B_public': guessed_kept_participant_B_public, 'guessed_donated_participant_B_private': guessed_donated_participant_B_private, 'guessed_kept_participant_B_private': guessed_kept_participant_B_private, } page_sequence = [Instructions_1, Instructions_2, Unconditional_contribution, Contribution_table, Belief_contribution]