from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import numpy as np import random doc = """ JMP """ class Constants(BaseConstants): name_in_url = 'study' players_per_group = None num_rounds = 12 max_per_page = 6 color_blind1=8 color_blind2=35 color_blind3=74 bonus_per_round=c(0.1) max_skips=2 practice_periods=3 # 1st element original, 2nd easy version, 3rd hard version, 4th index Colors=[ ["#33691E","#19350f","#295418",1], #dark green 1 ["#45BF55","#21612a","#359b43",2], #light green 2 ["#1C3FFD","#01178b","#1155FF",3], #dark blue 3 ["#04BFBF","#04d4d4","#04b2b2",4], #light blue 4 ["#d50000","#9c0000","#aa0000",5], #dark red 5 ["#ff5252","#ff8686","#ff7575",6], #light red 6 ["#FF5722","#fa3c00","#ff6231",7], #dark orange 7 ["#FF8C00","#ffab44","#ff9b22",8], #light orange 8 ["#360259","#470374","#200135",9], #dark purple 9 ["#AB47BC","#672972","#c47ed0",10], #light purple 10 ["#FFBE00","#ffcb33","#eeb100",11], #dark yellow 11 ["#FFEA00","#fff266","#fff044",12], #light yellow 12 ] class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): if 'is_hard_condition' in self.session.config: p.participant.vars['is_hard_condition'] = self.session.config['is_hard_condition'] else: p.participant.vars['is_hard_condition'] = random.choice([True, False]) class Group(BaseGroup): supervisor_bonus = models.CurrencyField() payoff_supervisor = models.CurrencyField() payoff_employee = models.CurrencyField() profit = models.StringField( choices=[ "Low", "High"], ) treatment_info = models.IntegerField() treatment_confrontation = models.IntegerField() random_draw=models.IntegerField() random_period=models.IntegerField() def profit_random(self): self.random_draw=random.randrange(1,Constants.probability_total+1) return self.random_draw<=Constants.probability_min+self.effort #AGREE_CHOICES = ( # (1, 'I strongly believe this is FALSE'), # (2, 'I believe this is FALSE'), # (3, 'Neutral'), # (4, 'I believe this is TRUE'), # (5, 'I strongly believe this is TRUE') #) AGREE_CHOICES = ( (1, 'This will certainly NOT happen'), (2, 'This will probably NOT happen'), (3, 'Neutral'), (4, 'This will probably happen'), (5, 'This will certainly happen') ) def make_field(label): return models.IntegerField( choices=AGREE_CHOICES, label=label, widget=widgets.RadioSelect, ) class Player(BasePlayer): color_blind_1 = models.IntegerField() color_blind_2 = models.IntegerField() color_blind_3 = models.IntegerField() understanding_questions_wrong_attempts = models.PositiveIntegerField() quiz_fail = models.BooleanField() can_see_color = models.BooleanField() is_on_mobile = models.BooleanField() is_hard_condition = models.BooleanField() color_choosen = models.StringField() color_target = models.StringField() color_number = models.IntegerField() is_match_real = models.BooleanField() is_match_supervisor = models.BooleanField() supervisor_is_correct = models.BooleanField() player_did_not_choose = models.BooleanField() is_practice_period = models.BooleanField() total_with_practice = models.IntegerField() total_incentivized = models.IntegerField() peq_reasonable_disagreement = make_field("Imagine two participants doing the color comparison task. \ Both of these participants are paying attention and are motivated to give the correct answers.\ Can these two participants have a different opinion about whether a set of two colors are the same?") peq_different_hour = make_field("Imagine you completed the color comparison task at a different time of your workday. \ For example, if you actually completed the task at the beginning of your workday, imagine you completed the task at the end of your workday.\ Or, if you actually completed the task at the end of your workday, imagine you completed the task at the beginning of your workday.\ Do you think your answers in the color comparison task would be different if you completed it at a different time of your workday?") peq_different_emotion = make_field("Imagine you completed the color comparison task in a strong emotional state. \ For example, imagine you were angry while completing the task. \ Do you think your answers in the color comparison task would be different if you were in a different emotional state?") peq_accuracy_self = models.IntegerField( label="In how many periods that affected your bonus do you think you gave the correct answer (from 0 to {})?".format(Constants.num_rounds-Constants.practice_periods), min=0, max=Constants.num_rounds-Constants.practice_periods) peq_accuracy_other = models.IntegerField( label="On average, in how many periods that affected the bonus do you think other participants gave the correct answer (from 0 to {})?".format(Constants.num_rounds-Constants.practice_periods), min=0, max=Constants.num_rounds-Constants.practice_periods) risk = models.IntegerField( choices=[(0,"0 (NOT at all willing to take risks)"),(1,"1"),(2,"2"),(3,"3"),(4,"4"),(5,"5"),(6,"6"),(7,"7"),(8,"8"),(9,"9"),(10,"10 (VERY willing to take risks)")], label='How do you see yourself: are you generally a person who is fully prepared to take RISKS or do you try to avoid taking RISKS? Please choose an option on the scale from 0 (NOT at all willing to take risks) to 10 (VERY willing to take risks).', widget=widgets.RadioSelectHorizontal) gender = models.IntegerField( choices=[(1,'Male'), (2,'Female'), (3,'Other'), (4,'Prefer not to say')], label='What is your gender?', widget=widgets.RadioSelect) education = models.IntegerField( choices=[(1,"No formal education"), (2,"Primary education"), (3,"Secondary education"), (4,"GED") ,(5,"Vocational qualification"), (6,"Bachelor's degree"), (7,"Master's degree"), (8,"Doctorate or higher")], label='What is the highest level of education attained?', widget=widgets.RadioSelect) work_experience = models.IntegerField( label='How many years of work experience do you have?', min=0, max=125) def role(self): return {1: 'Supervisor', 2: 'Employee'}[self.id_in_group]