from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Maxim Ott' doc = """ Shows all the results to the participants. Only uses session.vars and participant.vars """ class Constants(BaseConstants): name_in_url = 'SI_exp_07_09_results' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def vars_for_admin_report(self): # This works because EVERYONE is in the same group here # For every experiment pick two players: paying_players = random.sample(self.get_players(),6) exp07_paying_players = paying_players[0:2] exp08_paying_players = paying_players[2:4] exp09_paying_players = paying_players[4:] print(exp09_paying_players) return { 'paying_player_1_exp07': [ exp07_paying_players[0].participant.label, exp07_paying_players[0].participant.vars['exp07_my_role'], exp07_paying_players[0].participant.vars['exp07_my_choice'], exp07_paying_players[0].participant.vars['exp07_my_payoff'], exp07_paying_players[0].participant.vars['exp07_others_role'], exp07_paying_players[0].participant.vars['exp07_others_choice'], exp07_paying_players[0].participant.vars['exp07_others_payoff'], exp07_paying_players[0].participant.vars['exp07_others_name'], ], 'paying_player_2_exp07': [ exp07_paying_players[1].participant.label, exp07_paying_players[1].participant.vars['exp07_my_role'], exp07_paying_players[1].participant.vars['exp07_my_choice'], exp07_paying_players[1].participant.vars['exp07_my_payoff'], exp07_paying_players[1].participant.vars['exp07_others_role'], exp07_paying_players[1].participant.vars['exp07_others_choice'], exp07_paying_players[1].participant.vars['exp07_others_payoff'], exp07_paying_players[1].participant.vars['exp07_others_name'], ], 'paying_player_1_exp08': [ exp08_paying_players[0].participant.label, exp08_paying_players[0].participant.vars['exp08_my_choice'], exp08_paying_players[0].participant.vars['exp08_my_payoff'], exp08_paying_players[0].participant.vars['exp08_others_choice'], exp08_paying_players[0].participant.vars['exp08_others_payoff'], exp08_paying_players[0].participant.vars['exp08_others_names'], ], 'paying_player_2_exp08': [ exp08_paying_players[1].participant.label, exp08_paying_players[1].participant.vars['exp08_my_choice'], exp08_paying_players[1].participant.vars['exp08_my_payoff'], exp08_paying_players[1].participant.vars['exp08_others_choice'], exp08_paying_players[1].participant.vars['exp08_others_payoff'], exp08_paying_players[1].participant.vars['exp08_others_names'], ], 'paying_player_1_exp09': [ exp09_paying_players[0].participant.label, exp09_paying_players[0].participant.vars['exp09_my_choice'], exp09_paying_players[0].participant.vars['exp09_my_payoff'], exp09_paying_players[0].participant.vars['exp09_others_choice'], exp09_paying_players[0].participant.vars['exp09_others_payoff'], exp09_paying_players[0].participant.vars['exp09_others_name'], ], 'paying_player_2_exp09': [ exp09_paying_players[1].participant.label, exp09_paying_players[1].participant.vars['exp09_my_choice'], exp09_paying_players[1].participant.vars['exp09_my_payoff'], exp09_paying_players[1].participant.vars['exp09_others_choice'], exp09_paying_players[1].participant.vars['exp09_others_payoff'], exp09_paying_players[1].participant.vars['exp09_others_name'], ], } class Group(BaseGroup): pass class Player(BasePlayer): pass