from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import math class Belief(Page): form_model = "player" form_fields = ["guess_donation_participant_A_public", "guess_donation_participant_A_private", "guess_donation_participant_B_public", "guess_donation_participant_B_private", "button_show_me_team_project_clicked", "button_remind_me_what_I_did_1_clicked"] def vars_for_template(self): reported_donation_of_assigned_player_A = Constants.id_reported_donation_list.get(self.player.id_of_assigned_player_A) reported_donation_of_assigned_player_B = Constants.id_reported_donation_list.get(self.player.id_of_assigned_player_B) reported_amount_kept_of_assigned_player_A = round(4 - reported_donation_of_assigned_player_A / 1.1, 2) reported_amount_kept_of_assigned_player_B = round(4 - reported_donation_of_assigned_player_B / 1.1, 2) amount_kept_strategic = round(4 - self.participant.vars["donation_strategic"] / 1.1, 2) amount_kept_non_strategic = round(4 - self.participant.vars["donation_non_strategic"] / 1.1, 2) return { 'reported_donation_of_assigned_player_A': reported_donation_of_assigned_player_A, 'reported_donation_of_assigned_player_B': reported_donation_of_assigned_player_B, 'reported_amount_kept_of_assigned_player_A': reported_amount_kept_of_assigned_player_A, 'reported_amount_kept_of_assigned_player_B': reported_amount_kept_of_assigned_player_B, 'donation_strategic': self.participant.vars["donation_strategic"], 'donation_non_strategic': self.participant.vars["donation_non_strategic"], 'amount_kept_strategic': amount_kept_strategic, 'amount_kept_non_strategic': amount_kept_non_strategic, } class Choice(Page): form_model = "player" form_fields = ["teammate_choice", "button_remind_me_what_I_did_2_clicked"] def vars_for_template(self): reported_donation_of_assigned_player_A = Constants.id_reported_donation_list.get(self.player.id_of_assigned_player_A) reported_donation_of_assigned_player_B = Constants.id_reported_donation_list.get(self.player.id_of_assigned_player_B) reported_amount_kept_of_assigned_player_A = round(4 - reported_donation_of_assigned_player_A / 1.1, 2) reported_amount_kept_of_assigned_player_B = round(4 - reported_donation_of_assigned_player_B / 1.1, 2) amount_kept_strategic = round(4 - self.participant.vars["donation_strategic"] / 1.1, 2) amount_kept_non_strategic = round(4 - self.participant.vars["donation_non_strategic"] / 1.1, 2) guessed_donated_participant_A_public = self.player.guess_donation_participant_A_public guessed_kept_participant_A_public = (4.4 - self.player.guess_donation_participant_A_public) / 1.1 guessed_donated_participant_A_private = self.player.guess_donation_participant_A_private guessed_kept_participant_A_private = (4.4 - self.player.guess_donation_participant_A_private) / 1.1 guessed_donated_participant_B_public = self.player.guess_donation_participant_B_public guessed_kept_participant_B_public = (4.4 - self.player.guess_donation_participant_B_public) / 1.1 guessed_donated_participant_B_private = self.player.guess_donation_participant_B_private guessed_kept_participant_B_private = (4.4 - self.player.guess_donation_participant_B_private) / 1.1 return { 'donation_of_assigned_player_A': round(reported_donation_of_assigned_player_A, 2), 'donation_of_assigned_player_B': round(reported_donation_of_assigned_player_B, 2), 'amount_kept_of_assigned_player_A': round(reported_amount_kept_of_assigned_player_A, 2), 'amount_kept_of_assigned_player_B': round(reported_amount_kept_of_assigned_player_B, 2), 'donation_strategic': self.participant.vars["donation_strategic"], 'donation_non_strategic': self.participant.vars["donation_non_strategic"], 'amount_kept_strategic': amount_kept_strategic, 'amount_kept_non_strategic': amount_kept_non_strategic, '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, } def before_next_page(self): reported_donation_of_assigned_player_A = Constants.id_reported_donation_list.get(self.player.id_of_assigned_player_A) reported_donation_of_assigned_player_B = Constants.id_reported_donation_list.get(self.player.id_of_assigned_player_B) reported_amount_kept_of_assigned_player_A = round(4 - reported_donation_of_assigned_player_A / 1.1, 2) reported_amount_kept_of_assigned_player_B = round(4 - reported_donation_of_assigned_player_B / 1.1, 2) guessed_donated_participant_A_public = self.player.guess_donation_participant_A_public guessed_kept_participant_A_public = (4.4 - self.player.guess_donation_participant_A_public) / 1.1 guessed_donated_participant_A_private = self.player.guess_donation_participant_A_private guessed_kept_participant_A_private = (4.4 - self.player.guess_donation_participant_A_private) / 1.1 guessed_donated_participant_B_public = self.player.guess_donation_participant_B_public guessed_kept_participant_B_public = (4.4 - self.player.guess_donation_participant_B_public) / 1.1 guessed_donated_participant_B_private = self.player.guess_donation_participant_B_private guessed_kept_participant_B_private = (4.4 - self.player.guess_donation_participant_B_private) / 1.1 self.participant.vars['reported_donation_of_assigned_player_A'] = reported_donation_of_assigned_player_A self.participant.vars['reported_donation_of_assigned_player_B'] = reported_donation_of_assigned_player_B self.participant.vars['reported_amount_kept_of_assigned_player_A'] = reported_amount_kept_of_assigned_player_A self.participant.vars['reported_amount_kept_of_assigned_player_B'] = reported_amount_kept_of_assigned_player_B self.participant.vars['guessed_donated_participant_A_public'] = guessed_donated_participant_A_public self.participant.vars['guessed_kept_participant_A_public'] = guessed_kept_participant_A_public self.participant.vars['guessed_donated_participant_A_private'] = guessed_donated_participant_A_private self.participant.vars['guessed_kept_participant_A_private'] = guessed_kept_participant_A_private self.participant.vars['guessed_donated_participant_B_public'] = guessed_donated_participant_B_public self.participant.vars['guessed_kept_participant_B_public'] = guessed_kept_participant_B_public self.participant.vars['guessed_donated_participant_B_private'] = guessed_donated_participant_B_private self.participant.vars['guessed_kept_participant_B_private'] = guessed_kept_participant_B_private page_sequence = [Belief, Choice]