from otree.api import * import time doc = """ Real effort task """ class C(BaseConstants): NAME_IN_URL = 'Task' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): team_account = models.IntegerField() both_continue = models.BooleanField() class Player(BasePlayer): get_timeout_seconds = models.IntegerField() task_understood = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, ) continuation_intention = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, ) quit_intention = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, ) # SURVEY STUFF # Relative Survey contract_clicked_rel = models.IntegerField(initial=0, label='1 if participant clicked on the contract information') procedure_rel_1 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Whose effort translates more easily into points?', widget=widgets.RadioSelectHorizontal, ) procedure_rel_2 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Whose effort is more likely to result in more points?', widget=widgets.RadioSelectHorizontal, ) procedure_rel_3 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Whose influence on earning points is greater?', widget=widgets.RadioSelectHorizontal, ) procedure_rel_4 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Whose contract is more closely aligned with the task?', widget=widgets.RadioSelectHorizontal, ) procedure_rel_5 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Whose contract is more appropriate for the task?', widget=widgets.RadioSelectHorizontal, ) understand_rel = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Whose contract is easier to understand?', widget=widgets.RadioSelectHorizontal, ) remember_rel = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Whose contract is easier to remember?', widget=widgets.RadioSelectHorizontal, ) attention = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Please select option (1) - Definitely mine', widget=widgets.RadioSelectHorizontal, ) # Absolute Survey contract_clicked_abs = models.IntegerField(initial=0, label='1 if participant clicked on the contract information') procedure_abs_1 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='My team-mate and I had the same contract rules', widget=widgets.RadioSelectHorizontal, ) procedure_abs_2 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='My team-mate and I had different contract rules', widget=widgets.RadioSelectHorizontal, ) procedure_abs_3 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='My and my team-mate\'s contracts will earn us equal points for the same effort', widget=widgets.RadioSelectHorizontal, ) procedure_abs_4 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='My team-mate and I have the same influence over the points we can earn', widget=widgets.RadioSelectHorizontal, ) procedure_abs_5 = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='My team-mate and I performed the same task', widget=widgets.RadioSelectHorizontal, ) overall_mine = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Overall, I understand my own contract', widget=widgets.RadioSelectHorizontal, ) overall_other = models.StringField( choices=[['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', '']], label='Overall, I understand my team-mate\'s contract', widget=widgets.RadioSelectHorizontal, ) # PRODUCTION number_K_1 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') # entries in formfield number_IK_1 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_1 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') # clicked sum_IK_1 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_1 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') # total correct in grid correct_IK_1 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_1 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_2 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_2 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_2 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_2 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_2 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_2 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_2 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_3 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_3 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_3 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_3 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_3 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_3 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_3 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_4 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_4 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_4 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_4 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_4 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_4 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_4 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_5 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_5 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_5 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_5 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_5 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_5 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_5 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_6 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_6 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_6 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_6 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_6 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_6 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_6 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_7 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_7 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_7 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_7 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_7 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_7 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_7 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_8 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_8 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_8 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_8 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_8 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_8 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_8 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_9 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_9 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_9 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_9 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_9 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_9 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_9 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_10 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_10 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_10 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_10 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_10 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_10 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_10 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_11 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_11 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_11 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_11 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_11 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_11 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_11 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_12 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_12 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_12 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_12 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_12 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_12 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_12 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_13 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_13 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_13 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_13 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_13 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_13 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_13 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_14 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_14 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_14 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_14 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_14 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_14 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_14 = models.IntegerField(initial=0, min=0, label='Payout for respective player') number_K_15 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_15 = models.IntegerField(initial=0, min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_15 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_15 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_15 = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_15 = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') payout_15 = models.IntegerField(initial=0, min=0, label='Payout for respective player') payout_total = models.IntegerField(initial=0, min=0, label='Sum of all payouts in the production round') test = models.BooleanField() # FUNCTIONS def payout_calculation(treatment, calc_num_K, calc_num_IK, calc_sum_K, calc_sum_IK, calc_cor_K, calc_cor_IK): if calc_cor_K == 0: calc_payout = 0; return (calc_payout) else: if treatment < 3: if calc_sum_K == calc_cor_K: sum_K_is_K = 1; else: sum_K_is_K = 0; if calc_sum_IK == calc_cor_IK: sum_IK_is_IK = 1; else: sum_IK_is_IK = 0; if calc_num_K == calc_cor_K: num_K_is_K = 1; else: num_K_is_K = 0; if calc_num_IK == calc_cor_IK: num_IK_is_IK = 1; else: num_IK_is_IK = 0; calc_payout = int((sum_K_is_K + sum_IK_is_IK + num_K_is_K + num_IK_is_IK) * 50) return (calc_payout) else: sum_Ks = calc_sum_K * 5 sum_IKs = calc_sum_IK * 7 if calc_num_K == calc_cor_K: a_K = 23; a_K_is_K = 1; else: a_K = 0; a_K_is_K = 0; if calc_num_IK == calc_cor_IK: a_IK = 17; a_IK_is_IK = 1; else: a_IK = 0; a_IK_is_IK = 0; calc_payout = int(round(sum_Ks + sum_IKs + a_K + a_IK + (0.25 * ( (sum_Ks * a_K_is_K) + (sum_IKs * a_IK_is_IK) + (sum_Ks * a_IK_is_IK) + ( sum_IKs * a_K_is_K))) * (1.2 * a_K_is_K * a_IK_is_IK), 0)) return (calc_payout) def get_timeout_seconds(player): participant = player.participant return participant.expiry - time.time() # PAGES class ProductionIntro(Page): form_model = 'player' form_fields = ['task_understood'] def error_message(player, values): if values['task_understood'] == 0 or values['task_understood'] == None: return 'You have to understand the task in order to continue with the experiment. Please read the instructions again.' class SurveyRelative(Page): form_model = 'player' form_fields = ['procedure_rel_1', 'procedure_rel_2', 'procedure_rel_3', 'procedure_rel_4', 'procedure_rel_5', 'attention', 'understand_rel', 'remember_rel'] @staticmethod def live_method(player, data): player.contract_clicked_rel = int(data['contract_clicked']); @staticmethod def before_next_page(player, timeout_happened): participant = player.participant participant.expiry = time.time() + 60 * 5 class SurveyAbsolute(Page): form_model = 'player' form_fields = ['procedure_abs_1', 'procedure_abs_3', 'procedure_abs_2', 'procedure_abs_4', 'procedure_abs_5', 'overall_mine', 'overall_other'] @staticmethod def live_method(player, data): player.contract_clicked_abs = int(data['contract_clicked']); class Task_1(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_1', 'number_IK_1'] @staticmethod def live_method(player, data): player.sum_K_1 = int(data['value_K']); player.sum_IK_1 = int(data['value_IK']); player.correct_K_1 = int(data['correct_K']); player.correct_IK_1 = int(data['correct_IK']); class Task_2(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_2', 'number_IK_2'] @staticmethod def live_method(player, data): player.sum_K_2 = int(data['value_K']); player.sum_IK_2 = int(data['value_IK']); player.correct_K_2 = int(data['correct_K']); player.correct_IK_2 = int(data['correct_IK']); class Task_3(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_3', 'number_IK_3'] @staticmethod def live_method(player, data): player.sum_K_3 = int(data['value_K']); player.sum_IK_3 = int(data['value_IK']); player.correct_K_3 = int(data['correct_K']); player.correct_IK_3 = int(data['correct_IK']); class Task_4(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_4', 'number_IK_4'] @staticmethod def live_method(player, data): player.sum_K_4 = int(data['value_K']); player.sum_IK_4 = int(data['value_IK']); player.correct_K_4 = int(data['correct_K']); player.correct_IK_4 = int(data['correct_IK']); class Task_5(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_5', 'number_IK_5'] @staticmethod def live_method(player, data): player.sum_K_5 = int(data['value_K']); player.sum_IK_5 = int(data['value_IK']); player.correct_K_5 = int(data['correct_K']); player.correct_IK_5 = int(data['correct_IK']); class Task_6(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_6', 'number_IK_6'] @staticmethod def live_method(player, data): player.sum_K_6 = int(data['value_K']); player.sum_IK_6 = int(data['value_IK']); player.correct_K_6 = int(data['correct_K']); player.correct_IK_6 = int(data['correct_IK']); class Task_7(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_7', 'number_IK_7'] @staticmethod def live_method(player, data): player.sum_K_7 = int(data['value_K']); player.sum_IK_7 = int(data['value_IK']); player.correct_K_7 = int(data['correct_K']); player.correct_IK_7 = int(data['correct_IK']); class Task_8(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_8', 'number_IK_8'] @staticmethod def live_method(player, data): player.sum_K_8 = int(data['value_K']); player.sum_IK_8 = int(data['value_IK']); player.correct_K_8 = int(data['correct_K']); player.correct_IK_8 = int(data['correct_IK']); class Task_9(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_9', 'number_IK_9'] @staticmethod def live_method(player, data): player.sum_K_9 = int(data['value_K']); player.sum_IK_9 = int(data['value_IK']); player.correct_K_9 = int(data['correct_K']); player.correct_IK_9 = int(data['correct_IK']); class Task_10(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_10', 'number_IK_10'] @staticmethod def live_method(player, data): player.sum_K_10 = int(data['value_K']); player.sum_IK_10 = int(data['value_IK']); player.correct_K_10 = int(data['correct_K']); player.correct_IK_10 = int(data['correct_IK']); class Task_11(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_11', 'number_IK_11'] @staticmethod def live_method(player, data): player.sum_K_11 = int(data['value_K']); player.sum_IK_11 = int(data['value_IK']); player.correct_K_11 = int(data['correct_K']); player.correct_IK_11 = int(data['correct_IK']); class Task_12(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_12', 'number_IK_12'] @staticmethod def live_method(player, data): player.sum_K_12 = int(data['value_K']); player.sum_IK_12 = int(data['value_IK']); player.correct_K_12 = int(data['correct_K']); player.correct_IK_12 = int(data['correct_IK']); class Task_13(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_13', 'number_IK_13'] @staticmethod def live_method(player, data): player.sum_K_13 = int(data['value_K']); player.sum_IK_13 = int(data['value_IK']); player.correct_K_13 = int(data['correct_K']); player.correct_IK_13 = int(data['correct_IK']); class Task_14(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_14', 'number_IK_14'] @staticmethod def live_method(player, data): player.sum_K_14 = int(data['value_K']); player.sum_IK_14 = int(data['value_IK']); player.correct_K_14 = int(data['correct_K']); player.correct_IK_14 = int(data['correct_IK']); class Task_15(Page): timer_text = 'Time left to complete the task round:' get_timeout_seconds = get_timeout_seconds def is_displayed(player): participant = player.participant return (participant.expiry - time.time()) > 1 form_model = 'player' form_fields = ['number_K_15', 'number_IK_15'] @staticmethod def live_method(player, data): player.sum_K_15 = int(data['value_K']); player.sum_IK_15 = int(data['value_IK']); player.correct_K_15 = int(data['correct_K']); player.correct_IK_15 = int(data['correct_IK']); class Results(Page): form_model = 'player' timeout_seconds = 30 @staticmethod def vars_for_template(player): participant = player.participant treatment = participant.contract_group player.payout_1 = payout_calculation(treatment, player.number_K_1, player.number_IK_1, player.sum_K_1, player.sum_IK_1, player.correct_K_1, player.correct_IK_1) player.payout_2 = payout_calculation(treatment, player.number_K_2, player.number_IK_2, player.sum_K_2, player.sum_IK_2, player.correct_K_2, player.correct_IK_2) player.payout_3 = payout_calculation(treatment, player.number_K_3, player.number_IK_3, player.sum_K_3, player.sum_IK_3, player.correct_K_3, player.correct_IK_3) player.payout_4 = payout_calculation(treatment, player.number_K_4, player.number_IK_4, player.sum_K_4, player.sum_IK_4, player.correct_K_4, player.correct_IK_4) player.payout_5 = payout_calculation(treatment, player.number_K_5, player.number_IK_5, player.sum_K_5, player.sum_IK_5, player.correct_K_5, player.correct_IK_5) player.payout_6 = payout_calculation(treatment, player.number_K_6, player.number_IK_6, player.sum_K_6, player.sum_IK_6, player.correct_K_6, player.correct_IK_6) player.payout_7 = payout_calculation(treatment, player.number_K_7, player.number_IK_7, player.sum_K_7, player.sum_IK_7, player.correct_K_7, player.correct_IK_7) player.payout_8 = payout_calculation(treatment, player.number_K_8, player.number_IK_8, player.sum_K_8, player.sum_IK_8, player.correct_K_8, player.correct_IK_8) player.payout_9 = payout_calculation(treatment, player.number_K_9, player.number_IK_9, player.sum_K_9, player.sum_IK_9, player.correct_K_9, player.correct_IK_9) player.payout_10 = payout_calculation(treatment, player.number_K_10, player.number_IK_10, player.sum_K_10, player.sum_IK_10, player.correct_K_10, player.correct_IK_10) player.payout_11 = payout_calculation(treatment, player.number_K_11, player.number_IK_11, player.sum_K_11, player.sum_IK_11, player.correct_K_11, player.correct_IK_11) player.payout_12 = payout_calculation(treatment, player.number_K_12, player.number_IK_12, player.sum_K_12, player.sum_IK_12, player.correct_K_12, player.correct_IK_12) player.payout_13 = payout_calculation(treatment, player.number_K_13, player.number_IK_13, player.sum_K_13, player.sum_IK_13, player.correct_K_13, player.correct_IK_13) player.payout_14 = payout_calculation(treatment, player.number_K_14, player.number_IK_14, player.sum_K_14, player.sum_IK_14, player.correct_K_14, player.correct_IK_14) player.payout_15 = payout_calculation(treatment, player.number_K_15, player.number_IK_15, player.sum_K_15, player.sum_IK_15, player.correct_K_15, player.correct_IK_15) player.payout_total = player.payout_1 + player.payout_2 + player.payout_3 + player.payout_4 + player.payout_5 + player.payout_6 + player.payout_7 + player.payout_8 + player.payout_9 + player.payout_10 + player.payout_11 + player.payout_12 + player.payout_13 + player.payout_14 + player.payout_15 participant.total_earnings_1 = player.payout_total class Continue(Page): form_model = 'player' form_fields = ['continuation_intention', 'quit_intention'] def error_message(player, values): if values['continuation_intention'] == 0 and values['quit_intention'] == 0: return 'You have to select one of the choices' if values['continuation_intention'] == 1 and values['quit_intention'] == 1: return 'Please select one of the options.' elif values['continuation_intention'] == None and values['quit_intention'] == None: return 'Please select one of the options.' @staticmethod def app_after_this_page(player, upcoming_apps): participant = player.participant print('upcoming_apps is', upcoming_apps) if participant.no_partner == True: return "Survey_App" @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.own_continue = player.continuation_intention class Wait_1(WaitPage): form_model = 'player' @staticmethod def set_payoffs(group): players = group.get_players() contributions = [p.payout_total for p in players] group.team_account = sum(contributions) continuations = [p.continuation_intention for p in players] if sum(continuations) == 2: group.both_continue = True; else: group.both_continue = False; for player in players: participant = player.participant participant.team_account_2 = 0 participant.team_continues = group.both_continue for player in players: participant = player.participant participant.team_account_1 = group.team_account participant.team_continues = group.both_continue after_all_players_arrive = set_payoffs @staticmethod def app_after_this_page(player, upcoming_apps): group = player.group print('upcoming_apps is', upcoming_apps) if group.both_continue == False: return "Survey_App" page_sequence = [ProductionIntro, SurveyRelative, Task_1, Task_2, Task_3, Task_4, Task_5, Task_6, Task_7, Task_8, Task_9, Task_10, Task_11, Task_12, Task_13, Task_14, Task_15, Results, SurveyAbsolute, Continue, Wait_1]