from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants import random from random import shuffle import itertools from decimal import * def vars_for_all_templates(self): return { 'condition': self.participant.vars['condition'], 'type': self.participant.vars['type'] } class PEQ1(Page): form_model = models.Player form_fields = ['reporting_control', 'other_mgr_trust', 'vertical_trust', 'other_mgr_influence', 'individual_reporting_dif', 'shared_interest_infl', 'owner_concern', 'entitled_misreporting', 'company_attachment', 'company_exit', 'company_attractiveness', 'firm_member_similarity', 'relational_identification', 'total_wait_time'] def before_next_page(self): self.player.worker_id = self.participant.vars['worker_id'] self.player.condition = self.participant.vars['condition'] self.player.type = self.participant.vars['type'] self.player.pay_period = self.participant.vars['pay_period'] self.player.pay_period_lira = self.participant.vars['pay_lira'] self.player.comp_1 = self.participant.vars['comp_1'] class TaskInstructions2(Page): pass class DecisionTask(Page): form_model = models.Player form_fields = ['individual_points', 'duo_points', 'firm_points', 'decision_time'] def before_next_page(self): if self.player.condition > 2: comp2 = (self.player.individual_points*0.04) + (self.player.duo_points*0.03) + (self.player.firm_points*0.02) else: comp2 = (self.player.individual_points*0.04) + (self.player.duo_points*0.03) self.player.comp_2 = comp2 #wait time if self.player.total_wait_time > 610: wait_time = 610 else: wait_time = self.player.total_wait_time self.player.wait_bonus = round((int(wait_time) / 60) * 0.20, 2) self.player.total_comp = 2.00 + float(self.player.comp_1) + self.player.comp_2 + self.player.wait_bonus class PEQ2(Page): form_model = models.Player form_fields = ['group_expectations', 'mgr_carryover', 'compensatory_behavior', 'peq_attention', 'comp_sat_1', 'comp_sat_2', 'peq_turk_income', 'peq_affect_happy', 'peq_affect_sad', 'peq_affect_excited', 'peq_affect_upset', 'peq_affect_proud', 'peq_affect_irritable', 'peq_affect_inspired', 'peq_affect_nervous', 'gender', 'age_range', 'work_experience', 'education'] class Results(Page): def vars_for_template(self): return { 'pay_period': self.player.pay_period, 'pay_profit': self.player.pay_period_lira, 'bonus_1': self.player.comp_1, 'bonus_2': '{0:.2f}'.format(self.player.comp_2), 'wait_bonus': '{0:.2f}'.format(self.player.wait_bonus), 'bonus_total': '{0:.2f}'.format(self.player.total_comp) } page_sequence = [ PEQ1, TaskInstructions2, DecisionTask, PEQ2, Results ]