oTree Forum >

Modifying the Simple Public Goods game to show the highest and lowest individual contribution

#1 by Ctesiph

Hello,

I'm very new to oTree as part of my doctoral studies and as part of my training, I wanted to do a modification to the Public Goods Game, which is avialable in the library.

I would like to modify this game to the Open Public Goods Game, where each participant sees the highest and lowest contribution from his/her group on the results page.

I'm sure it's quite simple thing, but as I beginner I would really welcome some help, as scouring the forums and tutorials didn't help.

Thank you!

#2 by Ctesiph

A bit of a development. 

I found part of HTML code which I copied into the Results page, which should bring up a table where the contribution of each participant is displayed:

        <table>
        {% for p in subsession.get_players %}
        <tr>
        <td>{{ p.id_in_group }}</td>
        <td>{{ player.contribution }}</td>
        </tr>
        {% endfor %}
        </table>
        
The issue is that the table is not displaying the contributions of every player and instead it displays the player's contribution as contribution of every player. Consider this example of a "player" who contributed 60 pts. 

While all other players contributed 10, 20, 30, 40, 50 and 60 points respectively, the player who contributed 60 sees the table as such. Similarly for other players (they see all 50s, 40s, etc.)

1    60 points
2    60 points
3    60 points
4    60 points
5    60 points
6    60 points
    
Would anyone have a fix for this?

Thanks!

#3 by xindamate_xyz

Hi

It’s easy.
Use p.contribution rather than player.contribution 

Thanks 
Tina

Write a reply

Set forum username