import csv from otree.api import * author = 'Your name here' doc = """ """ class C(BaseConstants): NAME_IN_URL = 'Exit' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 PAY_PER_ROUND = cu(15) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): pass # FUNCTIONS # PAGES class kicked_for_quiz(Page): @staticmethod def is_displayed(player: Player): return 'quiz_fail' in player.participant.vars class kicked_for_time_out(Page): @staticmethod def is_displayed(player: Player): return 'participant_left' in player.participant.vars class kicked_for_VPN(Page): @staticmethod def is_displayed(player: Player): return 'kicked_for_VPN' in player.participant.vars class kicked_for_collegue(Page): @staticmethod def is_displayed(player: Player): return ( 'collegue_left' in player.participant.vars and 'participant_left' not in player.participant.vars ) @staticmethod def vars_for_template(player: Player): add_payment = (player.participant.vars["kicked_out_period"] - 1) * C.PAY_PER_ROUND player.participant.payoff = add_payment return dict( usd_payoff=player.participant.payoff_plus_participation_fee().to_real_world_currency( player.session ), no_periods=player.participant.vars["kicked_out_period"] - 1, is_first=player.participant.vars["kicked_out_period"] == 1, add_payment=add_payment.to_real_world_currency(player.session), participation_fee=player.session.config['participation_fee'], ) class final_page(Page): @staticmethod def vars_for_template(player: Player): return dict( payoff=player.participant.payoff_plus_participation_fee(), payoff_usd=player.participant.payoff_plus_participation_fee().to_real_world_currency( player.session ), fixed_usd=player.session.config['participation_fee'].to_real_world_currency( player.session ), bonus_usd=player.participant.payoff.to_real_world_currency(player.session), ) page_sequence = [kicked_for_VPN,kicked_for_quiz, kicked_for_time_out, kicked_for_collegue, final_page]