from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Mounir and Maren' doc = """ This app is for the seggregate portfolio building and portfolio selection part of the experiement. """ class Constants(BaseConstants): name_in_url = 'SegS' players_per_group = None num_rounds = 1 candidate_utilities = tuple([50, 99, 105, 81, 114, 80, 55, 120, 70]) team_utilities = tuple([314, 294, 276]) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Control Question # Here are the formfield used for the control question, which evaluates whether the participants understood the instructions control1=models.StringField( label="Candidate 1 is ... Candidate 2", widget=widgets.RadioSelect, choices=[ 'better than', 'worse than', 'equally good as', ] ) control2=models.StringField( label="Candidate 1 is ... Candidate 2", widget=widgets.RadioSelect, choices=[ 'better than', 'worse than', 'equally good as', ] ) control3=models.StringField( label="Candidate 1 is ... Candidate 2", widget=widgets.RadioSelect, choices=[ 'better than', 'worse than', 'equally good as', ] ) # Here are the variables that show if the respective part of the control question was answered correctly control1_correct = models.BooleanField(initial = None) control2_correct = models.BooleanField(initial = None) control3_correct = models.BooleanField(initial = None) # This is the variable that will give a player's overall score on the control question and a boolean that indicates whether all subquestions were answered correctly control_score = models.PositiveIntegerField() control_passed = models.BooleanField(initial = None) # Here we set the correct answers for each subquestion def set_is_control1_correct(self): self.control1_correct = self.control1 == 'worse than' def set_is_control2_correct(self): self.control2_correct = self.control2 == 'equally good as' def set_is_control3_correct(self): self.control3_correct = self.control3 == 'worse than' def set_control_score(self): self.control_score = getattr(self, 'control1_correct') + getattr(self, 'control2_correct') + getattr(self, 'control3_correct') def set_control_passed(self): self.control_passed = self.control_score == 3 #Personnel Task # Here are all the formfields that save the player's decisions about the selected candidates and team choice1 = models.IntegerField( label="Please choose your candidate for position 1 out of the candidates 1-3 (e.g. 1):", min=1, max=3 ) choice2 = models.IntegerField( label="Please choose your candidate for position 1 out of the candidates 4-6 (e.g. 4):", min=4, max=6 ) choice3 = models.IntegerField( label="Please choose your candidate for position 1 out of the candidates 7-9 (e.g. 7):", min=7, max=9) choice_selectPortfolio = models.IntegerField( label="Please choose your preferred team to hire (e.g. 1):", min=1, max=3 ) # Here are the formfields that save the player's perceived complexity complex_buildPortfolio = models.FloatField( label="I would rate the complexity/difficulty of this task as (0% simple – 100% difficult). Type your answer without the percentage sign:", min=0, max=100 ) complex_selectPortfolio = models.FloatField( label="I would rate the complexity/difficulty of this task as (0% simple – 100% difficult). Type your answer without the percentage sign:", min=0, max=100) # Here are the variables that save the achieved utility of a player's built/chosen team u_buildPortfolio = models.FloatField( initial=0 ) u_selectPortfolio = models.FloatField( initial=0 ) # Here are the variables for tracking the changes of the player's decision in the seggregate portfolio building part current_C1 = models.IntegerField() all_C1 = models.StringField() all_C2 = models.StringField() all_C3 = models.StringField() # Here are the variables for tracking the changes of the player's decision in the portfolio selection part current_team = models.IntegerField() all_teams = models.StringField()