#1
by
boma
(edited )
Hi everyone I use oTree studio. After several rounds of games where players could get payoffs, I add a new app where I want the participants to see their cumulated payoff. I show them the variable {{ participant.payoff }} and {{ participant.payoff_plus_participation_fee() }}. In addition, I show them the rounded payoff up to 10 cents, for which I created the following variable with def vars_for_template: import math rounded_to_10_cents = math.ceil(player.participant.payoff_plus_participation_fee() * 10) / 10 player.rounded_payoff = rounded_to_10_cents return { } When I look at the demo version, the payments are identical to the variable participant.payoff_plus_participation_fee(). However, my variable rounded_payoff is completely wrong for some players. For 50% of the players it's the correctly rounded number of participant.payoff_plus_participation_fee(), for 25% it is 20cents to 1.20euro too high, for 25% it is 20cents to 1euro too low. It seems random. Do you have an idea what the problem could be? Maybe because I used vars_for_template? Thank you very much for your help in advance!
#2 by Daniel_Frey
I think something goes wrong in your math.ceil() line. For example, if the total payoff is 1.01 euro, rounded_to_10_cents will be 1.1 (since math.ceil(1.01 * 10) / 10 = math.ceil(10.1) / 10 = 11 / 10 = 1.1 Is this expected? If I remember correctly (but I haven't tested it), you can directly change the decimal places of the currency in SESSION_CONFIG_DEFAULTS when you add the variable real_world_currency_decimal_places = 1
#3
by
boma
Thank you!