from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random import itertools from random import shuffle # author = 'Dan Way' doc = """ Cost Reporting Task """ class Constants(BaseConstants): name_in_url = 'cost_reporting_task' players_per_group = 2 num_rounds = 1 class Subsession(BaseSubsession): def group_by_arrival_time_method(self, waiting_players): a_mgrs_1 = [p for p in waiting_players if p.participant.vars['type'] == 1 and p.participant.vars['condition'] == 5] a_mgrs_2 = [p for p in waiting_players if p.participant.vars['type'] == 1 and p.participant.vars['condition'] == 6] a_mgrs_3 = [p for p in waiting_players if p.participant.vars['type'] == 1 and p.participant.vars['condition'] == 7] a_mgrs_4 = [p for p in waiting_players if p.participant.vars['type'] == 1 and p.participant.vars['condition'] == 8] b_mgrs_1 = [p for p in waiting_players if p.participant.vars['type'] == 2 and p.participant.vars['condition'] == 5] b_mgrs_2 = [p for p in waiting_players if p.participant.vars['type'] == 2 and p.participant.vars['condition'] == 6] b_mgrs_3 = [p for p in waiting_players if p.participant.vars['type'] == 2 and p.participant.vars['condition'] == 7] b_mgrs_4 = [p for p in waiting_players if p.participant.vars['type'] == 2 and p.participant.vars['condition'] == 8] if len(a_mgrs_1) > 0 and len(b_mgrs_1) > 0: return [a_mgrs_1[0], b_mgrs_1[0]] if len(a_mgrs_2) > 0 and len(b_mgrs_2) > 0: return [a_mgrs_2[0], b_mgrs_2[0]] if len(a_mgrs_3) > 0 and len(b_mgrs_3) > 0: return [a_mgrs_3[0], b_mgrs_3[0]] if len(a_mgrs_4) > 0 and len(b_mgrs_4) > 0: return [a_mgrs_4[0], b_mgrs_4[0]] class Group(BaseGroup): pass class Player(BasePlayer): def role(self): if self.type == 1: return 'Manager A' else: return 'Manager B' def get_partner(self): return self.get_others_in_group()[0] def chat_channel_1(self): return '1-' + str(self.group_id) def chat_channel_2(self): return '2-' + str(self.group_id) def chat_channel_3(self): return '3-' + str(self.group_id) def chat_channel_4(self): return '4-' + str(self.group_id) def chat_channel_5(self): return '5-' + str(self.group_id) worker_id = models.CharField(initial='e') firm_id = models.IntegerField() #For data prep for employees/owners condition = models.IntegerField() type = models.IntegerField() partner_id = models.IntegerField() actual_1A = models.IntegerField() actual_1B = models.IntegerField() report_1A = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_1B = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_1A_partner = models.IntegerField() report_1B_partner = models.IntegerField() slack_1A = models.IntegerField() slack_1B = models.IntegerField() slack_dol_1A = models.DecimalField(max_digits=3, decimal_places=2) slack_dol_1B = models.DecimalField(max_digits=3, decimal_places=2) audit_flag_1A = models.IntegerField() audit_flag_1B = models.IntegerField() bust_1A = models.IntegerField() bust_1A_partner = models.IntegerField() bust_1B = models.IntegerField() bust_1B_partner = models.IntegerField() actual_2A = models.IntegerField() actual_2B = models.IntegerField() report_2A = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_2B = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_2A_partner = models.IntegerField() report_2B_partner = models.IntegerField() slack_2A = models.IntegerField() slack_2B = models.IntegerField() slack_dol_2A = models.DecimalField(max_digits=3, decimal_places=2) slack_dol_2B = models.DecimalField(max_digits=3, decimal_places=2) audit_flag_2A = models.IntegerField() audit_flag_2B = models.IntegerField() bust_2A = models.IntegerField() bust_2A_partner = models.IntegerField() bust_2B = models.IntegerField() bust_2B_partner = models.IntegerField() actual_3A = models.IntegerField() actual_3B = models.IntegerField() report_3A = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_3B = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_3A_partner = models.IntegerField() report_3B_partner = models.IntegerField() slack_3A = models.IntegerField() slack_3B = models.IntegerField() slack_dol_3A = models.DecimalField(max_digits=3, decimal_places=2) slack_dol_3B = models.DecimalField(max_digits=3, decimal_places=2) audit_flag_3A = models.IntegerField() audit_flag_3B = models.IntegerField() bust_3A = models.IntegerField() bust_3A_partner = models.IntegerField() bust_3B = models.IntegerField() bust_3B_partner = models.IntegerField() actual_4A = models.IntegerField() actual_4B = models.IntegerField() report_4A = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_4B = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_4A_partner = models.IntegerField() report_4B_partner = models.IntegerField() slack_4A = models.IntegerField() slack_4B = models.IntegerField() slack_dol_4A = models.DecimalField(max_digits=3, decimal_places=2) slack_dol_4B = models.DecimalField(max_digits=3, decimal_places=2) audit_flag_4A = models.IntegerField() audit_flag_4B = models.IntegerField() bust_4A = models.IntegerField() bust_4A_partner = models.IntegerField() bust_4B = models.IntegerField() bust_4B_partner = models.IntegerField() actual_5A = models.IntegerField() actual_5B = models.IntegerField() report_5A = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_5B = models.IntegerField(initial=None, choices=[(20000, '20,000'), (25000, '25,000'), (30000, '30,000'), (35000, '35,000'), (40000, '40,000'), (45000, '45,000'), (50000, '50,000'), (55000, '55,000'), (60000, '60,000'), (65000, '65,000'), (70000, '70,000'), (75000, '75,000'), (80000, '80,000'), (85000, '85,000'), (90000, '90,000'), (95000, '95,000'), (100000, '100,000')], verbose_name='') report_5A_partner = models.IntegerField() report_5B_partner = models.IntegerField() slack_5A = models.IntegerField() slack_5B = models.IntegerField() slack_dol_5A = models.DecimalField(max_digits=3, decimal_places=2) slack_dol_5B = models.DecimalField(max_digits=3, decimal_places=2) audit_flag_5A = models.IntegerField() audit_flag_5B = models.IntegerField() bust_5A = models.IntegerField() bust_5A_partner = models.IntegerField() bust_5B = models.IntegerField() bust_5B_partner = models.IntegerField() chat_time_1 = models.CharField() chat_time_2 = models.CharField() chat_time_3 = models.CharField() chat_time_4 = models.CharField() chat_time_5 = models.CharField() lira_1 = models.IntegerField() lira_2 = models.IntegerField() lira_3 = models.IntegerField() lira_4 = models.IntegerField() lira_5 = models.IntegerField() potential_comp_1 = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_2 = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_3 = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_4 = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_5 = models.DecimalField(max_digits=4, decimal_places=2) lira_1_partner = models.IntegerField() lira_2_partner = models.IntegerField() lira_3_partner = models.IntegerField() lira_4_partner = models.IntegerField() lira_5_partner = models.IntegerField() potential_comp_1_partner = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_2_partner = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_3_partner = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_4_partner = models.DecimalField(max_digits=4, decimal_places=2) potential_comp_5_partner = models.DecimalField(max_digits=4, decimal_places=2) pay_period = models.IntegerField() pay_period_lira = models.IntegerField() comp_1 = models.CharField()