from otree.api import * c = cu doc = 'In this app, the consultant will also be participant, for all the participants in this app, half of them will be manager, half of them will be consultant. ' class C(BaseConstants): NAME_IN_URL = 'Human_BeforeChat' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 MANAGER_ROLE = 'Manager' CONSULTANT_ROLE = 'Consultant' APPROVAL_CAP = 6 BASE_SALARY = 1000 UNITS = 1000 ACTUAL_COST = 5 POINTS_CUSTOM_NAME = 'dimra' class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): manager_count = 0 for player in subsession.get_players(): if player.id_in_subsession % 2 == 1: player.participant.assigned_role = C.MANAGER_ROLE player.assigned_role = C.MANAGER_ROLE if manager_count % 2 == 0: rf = 'tool' else: rf = 'partner' player.participant.roleframe = rf player.roleframe = rf manager_count += 1 else: player.participant.assigned_role = C.CONSULTANT_ROLE player.assigned_role = C.CONSULTANT_ROLE player.participant.roleframe = None player.roleframe = '' class Group(BaseGroup): pass class Player(BasePlayer): prolific_id = models.StringField(default=" ") assigned_role = models.StringField() roleframe = models.StringField(blank=True) quiz_q1 = models.BooleanField( blank=True, choices=[[True, 'True'], [False, 'False']], label='1. You can consult an internal consultant when making the budget decision.' ) quiz_q2 = models.BooleanField( blank=True, choices=[[True, 'True'], [False, 'False']], label='2. In addition to the base pay, you also keep the difference between the funds received and the actual cost.' ) quiz_q3 = models.BooleanField( blank=True, choices=[[True, 'True'], [False, 'False']], label='1. I should reply to the manager using only the provided responses.' ) quiz_q4 = models.BooleanField( blank=True, choices=[[True, 'True'], [False, 'False']], label='2. I should wait for the manager to leave the chat before proceeding to the next page.' ) @property def role(self): return self.assigned_role def quiz_q1_error_message(player: Player, value): if value is not True: return "Yes, you can consult an internal consultant when making the budget decision." def quiz_q2_error_message(player: Player, value): if value is not True: return "In addition to the base pay, you will keep the difference between the funds received and the actual cost." def quiz_q3_error_message(player: Player, value): if value is not True: return "Please use only the responses provided when replying to the manager." def quiz_q4_error_message(player: Player, value): if value is not True: return "Please stay on the chat page until receiving the message 'the other player has left the chat.'" class GeneralInfo(Page): form_model = 'player' class Background(Page): form_model = 'player' class Instruction_Manager(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.role == C.MANAGER_ROLE @staticmethod def before_next_page(self, timeout_happened): self.prolific_id = self.participant.label pass class Quiz(Page): form_model = 'player' form_fields = ['quiz_q1', 'quiz_q2'] @staticmethod def is_displayed(player: Player): return player.participant.assigned_role == C.MANAGER_ROLE class QuizConsultant(Page): form_model = 'player' form_fields = ['quiz_q3', 'quiz_q4'] @staticmethod def is_displayed(player: Player): return player.participant.assigned_role == C.CONSULTANT_ROLE class Instruction_Consultant(Page): form_model = 'player','group' @staticmethod def is_displayed(player: Player): return player.participant.assigned_role == C.CONSULTANT_ROLE @staticmethod def before_next_page(self, timeout_happened): self.prolific_id = self.participant.label pass class InformationAcqusition(Page): form_model = 'player','group' @staticmethod def is_displayed(player: Player): return player.participant.assigned_role == C.MANAGER_ROLE page_sequence = [GeneralInfo,Background, Instruction_Manager,Instruction_Consultant, Quiz, QuizConsultant, InformationAcqusition]