class Player(BasePlayer): be01a_man = models.IntegerField( label="", min=0, max=40, widget=widgets.Slider(attrs={'step': '1'}, show_value=False), ) be01b_man = models.IntegerField( label="", min=0, max=50, widget=widgets.Slider(attrs={'step': '5'}), ) be02a_man = models.IntegerField( label="", min=0, max=40, widget=widgets.Slider(attrs={'step': '1'}, show_value=False), ) be02b_man = models.IntegerField( label="", min=0, max=50, widget=widgets.Slider(attrs={'step': '5'}), ) dump_order = models.StringField( doc= 'Only to see that randomization is correcttly set in participant.vars') dump_participant_vars = models.StringField( doc='only to see that slider decisons dumps correclty')
class Player(BasePlayer): self_rating1 = models.IntegerField( widget=widgets.Slider(show_value=True, attrs={'step': '1'}), max=10, min=0, blank=False, initial=random_initial1(), label=translation_dict["pre_slider"]["self_rating_Q"][LANGUAGE_CODE]) answer = models.IntegerField( choices=[1, 2, 3, 4, 5, 6, 7, 8], widget=widgets.RadioSelectHorizontal, label=translation_dict["raven_question"]["question"][LANGUAGE_CODE]) ans_correct = models.BooleanField() self_rating2 = models.IntegerField( widget=widgets.Slider(show_value=True, attrs={'step': '1'}), max=10, min=0, blank=False, initial=random_initial1(), label=translation_dict["post_slider"]["self_rating_Q"][LANGUAGE_CODE]) probability = models.IntegerField( widget=widgets.Slider(show_value=True, attrs={'step': '1'}), max=100, min=0, blank=False, initial=random_initial2(), label=translation_dict["pre_info"]["probability_Q"][LANGUAGE_CODE])
class Player(BasePlayer): ''' Class used to define the things that need to be stored in the database and parameters for the inputs. Here, we're storing all the slider inputs, whether the user is a dictator or a receiver, and whether they're in the Klee or the Kandinsky group. They're all part of the Player object. ''' level1 = models.IntegerField(widget=widgets.Slider(show_value=False)) level2 = models.IntegerField(widget=widgets.Slider(show_value=False)) level3 = models.IntegerField(widget=widgets.Slider(show_value=False)) level4 = models.IntegerField(widget=widgets.Slider(show_value=False)) level5 = models.IntegerField(widget=widgets.Slider(show_value=False)) situation = models.CharField() artist_group = models.CharField() actual_group_id = models.IntegerField() ### Control Questions average_question_1 = models.IntegerField(label="Frage 3: Was ist der Durchschnitt von 30 und 40?") average_question_2 = models.IntegerField(label="Frage 4: Was ist der Durchschnitt von 37 und 43?") percentage_question_1 = models.FloatField(label="Frage 1: Wie viel sind 10% von 65?") percentage_question_2 = models.FloatField(label="Frage 2: Wie viel sind 5% von 80?") lottery_question_1 = models.IntegerField(label="Wie hoch ist die Wahrscheinlichkeit 40 Punkte zu gewinnen?", choices=[[70, "70%"], [50, "50%"], [30, "30%"], [10, "10%"]], widget=widgets.RadioSelect) lottery_question_2 = models.BooleanField( label="Welche Lotterie sollten Sie auswählen, wenn Sie zwischen diesen beiden Lotterien wählen müssen und dabei die Chance einen höheren Betrag zu gewinnen maximieren sollen", choices=[[0, "Lotterie A"], [1, "Lotterie B"]], widget=widgets.RadioSelect)
class Player(BasePlayer): transfer_will = models.IntegerField( min=2500, max=5000, initial=0, label=questions.transfer_message, widget=widgets.Slider(), blank=True, ) transfer_will_yn = models.BooleanField( label="이직의사 없음", widget=widgets.CheckboxInput, choices=Constants.BINARY_CHOICES, blank=True, ) transfer_will_alt = models.IntegerField( min=5000, max=10000, initial=0, label=questions.transfer_message_alt, widget=widgets.Slider(), ) transfer_will_alt_yn = models.BooleanField( label="이직의사 없음", widget=widgets.CheckboxInput, choices=Constants.BINARY_CHOICES, blank=True, ) sm_1_1 = make_field_sm(1) sm_1_2 = make_field_sm(2) sm_1_3 = make_field_sm(3) sm_1_4 = make_field_sm(4) sm_1_5 = make_field_sm(5) sm_1_6 = make_field_sm(6) sm_1_7 = make_field_sm(7) sm_1_8 = make_field_sm(8) # todo 아래 둘 중 최소 하나는 확실히 입력받게 만들것. sm_2_chan = models.StringField( label="찬성(이유 직접 입력)", blank=True, ) sm_2_ban = models.StringField( label="반대(이유 직접 입력)", blank=True, ) sm_3 = models.IntegerField( label="", widget=widgets.RadioSelect, choices=Constants.sm3_choices, )
class Player(BasePlayer): k = models.IntegerField() content = models.StringField() believe1 = models.StringField( choices=['Sincere', 'Random'], widget=widgets.RadioSelect, label= "Do you believe that your card was a sincere card or a random card? ") believe2 = models.StringField( choices=['Yes', 'No'], widget=widgets.RadioSelect, label= " After having observed the statement of your card, do you believe that you have performed better than the median?" ) scale1 = models.IntegerField( widget=widgets.Slider(attrs={ 'min': '0', 'max': '10' }), label="How sure are you? (Rate on a 10-point scale.)") scale2 = models.IntegerField( widget=widgets.Slider(attrs={ 'min': '0', 'max': '10' }), label="How sure are you? (Rate on a 10-point scale.)") final_payoff = models.FloatField() def set_k(self): self.k = random.randint(5, 10) def card_content(self): if_sincere = numpy.random.choice(numpy.arange(1, 3), p=[self.k / 10, 1 - self.k / 10 ]) # 1 sincere, 2 random if if_sincere == 1: return 0 # True message else: random_true = random.randint(0, 1) # 0: random false, 1:random true if random_true == 0: return 1 # False message else: return 0 # True message def get_msg(self): if self.participant.vars['median'] <= self.participant.vars[ 'n_correct']: return [ "You performed better than the median", "You performed worse than the median " ] else: return [ "You performed worse than the median ", "You performed better than the median" ]
class Player(BasePlayer): age = models.IntegerField(blank=True, min=0) sex = models.StringField(choices=['F', 'M'], blank=True) laterality = models.StringField( choices=['Right-handed', 'Left-handed', 'Ambidextrous', 'N/A'], blank=True) education = models.StringField( blank=True, label='Education (completed)', choices=[ 'Elementary school', 'Middle school', 'High school', ] + ['Higher ed. %dy' % y for y in range(1, 10)] + [ 'Higher ed. 10y+', ]) prob = models.FloatField() outcome = models.IntegerField() response = models.FloatField(widget=widgets.Slider(attrs={ 'step': '0.001', 'list': 'tickmarks', 'class': 'myslider' }, show_value=False), min=0.001, max=0.999, label='')
class Group(BaseGroup): p1_share = models.PositiveIntegerField( max=Constants.pie_size, widget=widgets.Slider(attrs={'step': '1'})) p2_share = models.PositiveIntegerField(max=Constants.pie_size) def set_p2_share(self): self.p2_share = Constants.pie_size - self.p1_share
class Player(BasePlayer): def other_player(self): return self.get_others_in_group()[0] output_request = models.FloatField( label='How many units would you like to buy?', max=Constants.q_bar, min=0) implicit_price = models.FloatField() offer_accept = models.BooleanField(choices=[[True, 'Accept'], [False, 'Reject']], label='Do you accept this offer?', widget=widgets.RadioSelect) tokens_begin = models.FloatField() tokens_end = models.FloatField() tokens_end_lump = models.FloatField() tokens_end_end = models.FloatField() money = models.FloatField() payoff1 = models.FloatField() payoff2 = models.FloatField() interest = models.FloatField() choose = models.StringField( label='', choices=[['Buyer', 'Consumer (earn Points, spend Tokens)'], ['Seller', 'Producer (earn Tokens, spend Points)']], doc="""This player's decision""", widget=widgets.RadioSelect) prediction1 = models.FloatField() token_offer = models.FloatField( label='How many Tokens would you like to offer for those units?') def token_offer_max(self): return self.tokens_begin #cm_output_offer = models.FloatField(label='', max=Constants.q_bar, min=0) cm_output_offer = models.FloatField(label='', min=0) def cm_output_offer_max(self): return self.participant.payoff + Constants.point_endowment + self.payoff1 #cm_bid = models.FloatField(label='', max=Constants.token_endowment, min=0) cm_bid = models.FloatField(label='', min=0, widget=widgets.Slider(attrs={'step': '0.01'}, show_value=True)) def cm_bid_max(self): return self.tokens_end_lump def role(self): if self.id_in_group == 1: return 'buyer' if self.id_in_group == 2: return 'seller'
class Player(BasePlayer): probability = models.FloatField( widget=widgets.Slider(show_value=True, attrs={'step': '1'}), max=100, min=0, blank=False, initial=random_initial(), label=translation_dict["pre_info"]["probability_Q"][LANGUAGE_CODE])
def slider_field(label): return models.IntegerField( min=0, max=100, widget=widgets.Slider(), default=0, label=label, )
class Player(BasePlayer): altedu = models.IntegerField( min=0, max=100, widget=widgets.Slider(attrs={'step': '1'}), label="부정적 0<------------50------------>100 긍정적", ) treatment = models.IntegerField(initial=0) # treatment 0
class Player(BasePlayer): name = models.StringField() age = models.IntegerField() a = models.IntegerField() test = models.IntegerField(min=0, max=Constants.endowment, widget=widgets.Slider(attrs={'step': '1'}), default=0, blank=True)
class Player(BasePlayer): Q1 = models.BooleanField( blank=True, choices=[[True, "Yes"], [False, "No"]], widget=widgets.RadioSelectHorizontal, label="Q1", ) Q2 = models.IntegerField( blank=True, choices=[[1, "A"], [2, "B"], [3, "C"]], label="Q2", widget=widgets.RadioSelect, ) Q3 = models.IntegerField( blank=True, choices=[[1, "A"], [2, "B"], [3, "C"], [4, "D"]], label="Q3", ) Q4 = models.FloatField( widget=widgets.Slider(show_value=True, attrs={'step': '1'}), max=100, min=0, blank=True, initial=random_initial(), label="Q4" ) Q5 = models.IntegerField(label="Q5", max=100, min=0, blank=True) Q6 = models.FloatField(label="Q6", max=100, min=0, blank=True) Q7 = models.StringField(label="Q7", blank=True) Q8 = models.CurrencyField( label="Q8", blank=True ) Q9 = models.LongStringField ( label="Q9", blank=True, ) Q10 = models.TextField( label="Q10", blank=True, )
class Player(BasePlayer): talents = models.IntegerField() opponent = models.IntegerField() records = models.FloatField() round_results = models.FloatField() efforts = models.IntegerField(choices=range(0, 11), widget=widgets.Slider(attrs={'max': '10'})) ability_revelation = models.BooleanField(widget=widgets.RadioSelect, choices=[ [False, '不要'], [True, '要'], ]) victory_revelation = models.BooleanField(widget=widgets.RadioSelect, choices=[ [False, '不要'], [True, '要'], ]) def get_id(self): return self.participant.vars['id'] def set_opponent(self, rival): self.opponent = rival def get_opponent(self): return self.opponent def get_ori_opponent_id(self): new_id = self.get_opponent() return self.session.vars['new_id_to_ori_id'][ f'{self.group.id_in_subsession}-{new_id}'] def get_opponent_ranking(self): return self.group.get_player_by_id( self.opponent).participant.vars['ranking'] def get_personal_records(self): return np.round(np.mean(self.participant.vars['records']), 2) def get_personal_ranking(self): return self.participant.vars['ranking'] def get_personal_talents(self): return self.participant.vars['talents'] def get_players_prev_fields(self, field_str): prev_fields = list() # for player in self.group.get_players(): # p1, .... ,p10 for prevSelf in self.in_previous_rounds(): prev_fields.append(getattr(prevSelf, field_str)) return prev_fields def print_round_result(self): if self.round_results == 1: outcome = "勝" elif self.round_results == 0.5: outcome = "平手" else: outcome = "敗" return outcome def print_round_payoff(self): if self.round_results == 1: payout = Constants.REWARD elif self.round_results == 0.5: payout = Constants.REWARD * 0.5 else: payout = 0 return payout def process_reveal_ability(self): if self.ability_revelation: my_opponent = self.group.get_player_by_id(self.opponent) answer = my_opponent.participant.vars[ 'talents'] # ???? why not start with self here? efforts_allowed = 10 else: answer = "不透露" efforts_allowed = 0 return answer, efforts_allowed def process_reveal_victory(self): if self.victory_revelation: my_opponent = self.group.get_player_by_id(self.opponent) answer = my_opponent.get_personal_records() else: answer = "不透露" return answer def calculate_reveal_decisions(self): if self.round_number > 1: past_egos = self.in_previous_rounds() frequency_ability_reveal = [] frequency_records_reveal = [] for p in past_egos: frequency_ability_reveal.append(p.ability_revelation) frequency_records_reveal.append(p.ability_revelation) frequency_ability_reveal = sum(frequency_ability_reveal) frequency_records_reveal = sum(frequency_records_reveal) else: frequency_ability_reveal = "暫無紀錄" frequency_records_reveal = "暫無紀錄" return frequency_ability_reveal, frequency_records_reveal
class Player(BasePlayer): def unfill_snack_list(self): ''' entferne erste Index-Zahl aus Teilnehmer-Snack-Liste ''' self.participant.vars['num_snacks'].pop(0) def fill_BDM_dict(self): # key: abgefragter Snack # value: willingness-to-pay if self.slider_value == "": # Now define the pairs that we want to show participants in step 2 and 3 # Idea: Taking a random subset of all possible pairs for each participant # self.participant.vars['num_snacks'] sind indexzahlen, die von 0 bis zu num_snacks-1 läuft, # wobei bei jeder runde immer die erste Indexzahl weggenommen wird, sodass self.participant.vars['num_snacks'][0] # immer das nächste Gut ist. [Constants.list_snacks[self.participant.vars['num_snacks'][0]] gibt somit immer den Namen des nächsten Guts # Dadurch dass es ein dictionary ist, wird der BDM value immer an die Seite des entsprechenden Guts geschrieben self.participant.vars['BDM'][Constants.list_snacks[ self.participant.vars['num_snacks'][0]]] = '0' else: self.participant.vars['BDM'][Constants.list_snacks[ self.participant.vars['num_snacks'][0]]] = self.slider_value def pick_pairs_to_show(self): step2_list_of_pairs_to_show = [] # Shuffling the list of all possible pairs shuffled_all_possible_pairs_step2 = Constants.list_of_all_pairs.copy() random.shuffle(shuffled_all_possible_pairs_step2) # Now taking the first x pairs of the list of all possible tuple pairs, # where x is number of decisions for step 2 that is defines in Constants. # Remember, die index 0:2 goes 0,1 (excluding 2) for random_pair in shuffled_all_possible_pairs_step2[ 0:Constants.num_decisions_step2]: step2_list_of_pairs_to_show.append(random_pair) self.participant.vars[ 'step2_list_of_pairs_to_show'] = step2_list_of_pairs_to_show # Now doing the same for step 3 --> Taking another random subset step3_list_of_pairs_to_show = [] shuffled_all_possible_pairs_step3 = Constants.list_of_all_pairs.copy() random.shuffle(shuffled_all_possible_pairs_step3) # Now taking the first x pairs, i.e. the Number of decisions for step 2 for random_pair in shuffled_all_possible_pairs_step3[ 0:Constants.num_decisions_step3]: step3_list_of_pairs_to_show.append(random_pair) self.participant.vars[ 'step3_list_of_pairs_to_show'] = step3_list_of_pairs_to_show # print('List of pairs to show for participant ', self.id, ' is:', step2_list_of_pairs_to_show, 'in Step 2 and ', # step3_list_of_pairs_to_show, 'in Step 3') #### DATA-fields: # Kontrollfragen - dem Experimentator wird mit "HILFE" eine falsche Antwort signalisiert ''' auskommentiert: Kontrollfragen werden stattdessen händisch gemacht control_1 = models.StringField(verbose_name="Welche Ihrer Entscheidungen sind für Ihre Auszahlung relevant?", choices=[ ['HILFE', 'Jede Entscheidung zählt.'], ['HILFE', 'Eine der Entscheidungen in Stufe 1 wird zufällig zur Auszahlung ausgewählt.'], ['ok', 'Eine der Entscheidungen aus einer der vier Stufen des Experiments wird zufällig zur Auszahlung ausgewählt.']], widget=widgets.RadioSelect()) control_2 = models.StringField(verbose_name="Wenn ich immer eine Zahlungsbereitschaft von 0 Euro angebe und Stufe 1 oder 4 zur Auszahlung ausgewählt wird, erhalte ich eine garantierte Auszahlung von 5 Euro.", choices=[['ok', 'korrekt'], ['HILFE', 'nicht korrekt']], widget=widgets.RadioSelect()) control_3 = models.StringField(verbose_name="Wenn eine der Stufen 2 oder 3 zur Auszahlung ausgewählt wird, erhalte ich dennoch die garantierte Auszahlung von 5 Euro aus Stufe 1 oder 4.", choices=[['HILFE', 'korrekt'], ['ok', 'nicht korrekt']], widget=widgets.RadioSelect()) control_4 = models.StringField(verbose_name="Ich erwerbe maximal ein Gut.", choices=[['ok', 'korrekt'], ['HILFE', 'nicht korrekt']], widget=widgets.RadioSelect()) control_5 = models.StringField(verbose_name="Indem ich eine niedrigere Zahlungsbereitschaft angebe, kann ich einen niedrigeren Preis erhalten, als wenn ich meine wahre Zahlungsbereitschaft angeben würde.", choices=[['HILFE', 'korrekt'], ['ok', 'nicht korrekt']], widget=widgets.RadioSelect()) control_6 = models.StringField(verbose_name="Indem ich eine niedrigere Zahlungsbereitschaft angebe, kann ich nicht beeinflussen, welchen Preis ich zahle wenn ich das Gut kaufe, da der Preis zufällig bestimmt wird. Ich zahle diesen zufällig gezogenen Preis nur, falls er nicht höher als meine Zahlungsbereitschaft ist.", choices=[['ok', 'korrekt'], ['HILFE', 'nicht korrekt']], widget=widgets.RadioSelect()) control_7 = models.StringField(verbose_name="Indem ich eine niedrigere Zahlungsbereitschaft angebe, kann es passieren, dass der zufällig gezogene Preis oberhalb dieser angegebenen, aber unterhalb meiner tatsächlichen Zahlungsbereitschaft liegt. Ich würde dann das Gut nicht bekommen, obwohl ich es zu einem Preis hätte kaufen können, der unter meiner tatsächlichen Zahlungsbereitschaft liegt.", choices=[['ok', 'korrekt'], ['HILFE', 'nicht korrekt']], widget=widgets.RadioSelect()) ''' # Label des PCs p_label = models.StringField(widget=widgets.HiddenInput(), verbose_name='') # was der Teilnehmer mit dem Schieberegler wählt slider_value = models.StringField(widget=widgets.Slider()) # welchen Snack der Teilnehmer gerade bewertet rated_snack = models.StringField(widget=widgets.HiddenInput(), verbose_name='') # Treatment variable treatment = models.StringField(widget=widgets.HiddenInput(), verbose_name='')
class Player(BasePlayer): my_group_id = models.PositiveIntegerField( doc="Gives each player his group ID (see subsession)") random_number = models.IntegerField( doc= "Turns either 1 or 2 (see subsession) and is used to randomly assign roles in the experiment (see def role)." ) compensation = models.CharField( doc="Compensation scheme put in place for agents (see Settings).") participation_fee = models.CurrencyField( doc="Participation fee for all agents (can be modified in Settings).") def role(self): return "Principal" if self.id_in_group == self.random_number else "Agent" # Everyone chooses the category: category = models.CharField( choices=Constants.category_names, verbose_name= "ein Berater soll mein Vermögen wie folgt für mich anlegen:", doc= "Principals choose the category which is communicated to their agent") category_from_principal = models.CharField( doc= "Category that agents receive from their principals indicating how they want their agent to invest." ) def get_category(self): self.category_from_principal = self.get_others_in_group()[0].category # Everyone takes the investment decision for their principal: decision_for_p1 = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset.") investment = models.CurrencyField( doc= "Indicates for everyone the investment decision as taken by their agents." ) def get_investment(self): agent = self.get_others_in_group()[0] self.investment = agent.decision_for_p1 # principals can send messages to their agents: message = models.CharField( choices=[ "Ich bin sehr zufrieden mit Ihrer Entscheidung", "Ich bin zufrieden mit Ihrer Entscheidung", "Ich bin unzufrieden mit Ihrer Entscheidung", "Ich bin sehr unzufrieden mit Ihrer Entscheidung" ], widget=widgets.RadioSelect(), verbose_name= "Wählen Sie dazu eine der vorgefertigten Mitteilungen aus:", doc="Principals choose the message to send to the agents.") message_from_principal = models.CharField( doc="Message that agents receive from their principals.") # Payoffs: def calculate_payoffs_principals(self): if self.role() == "Principal": if self.group.investment_success: self.payoff = self.investment * 3.5 + ( Constants.endowment_principals - self.investment) self.profit = self.investment * 2.5 else: self.payoff = Constants.endowment_principals - self.investment self.profit = 0 profit = models.CurrencyField(doc="Gives the profit of the principal.") payoff_of_principal = models.CurrencyField( doc="Gives for each agent the payoff of his principal.") profit_of_principal = models.CurrencyField( doc="Gives for each agent the payoff of his principal.") def get_msg_payoff_profit(self): principal = self.get_others_in_group()[0] self.profit_of_principal = principal.profit self.payoff_of_principal = principal.payoff self.message_from_principal = principal.message def calculate_payoffs_agents(self): if self.role() == "Agent": if self.compensation == "fixed": self.payoff = Constants.fixed_payment if self.compensation == "variable_result": self.payoff = Constants.fixed_payment + Constants.share_result / 100 * self.payoff_of_principal if self.compensation == "variable_profit": self.payoff = Constants.fixed_payment + Constants.share_profit / 100 * self.profit_of_principal # Comprehension Questions question_1 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) question_2 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) question_3 = models.CurrencyField() question_4 = models.CurrencyField() question_5 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) question_6 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) # Questionnaire: age = models.PositiveIntegerField( max=100, verbose_name="Wie alt sind Sie?", doc="We ask participants for their age between 0 and 100 years") gender = models.CharField(choices=["männlich", "weiblich", "anderes"], widget=widgets.RadioSelectHorizontal(), verbose_name="Was ist Ihr Geschlecht?", doc="gender indication") studies = models.CharField(blank=True, verbose_name="Was studieren Sie im Hauptfach?", doc="field of studies indication.") nonstudent = models.BooleanField( widget=widgets.CheckboxInput(), verbose_name="Kein Student", doc="Ticking the checkbox means that the participant is a non-student." ) financial_advice = models.BooleanField( choices=[(True, "Ja"), (False, "Nein")], widget=widgets.RadioSelectHorizontal(), verbose_name= "Haben Sie bereits eine Bankberatung in Anspruch genommen?", doc="We ask participants if they ever made use of financial advice.") income = models.CurrencyField( verbose_name="Wie viel Geld im Monat steht Ihnen frei zur Verfügung?", doc= "We ask participants how much money they have freely available each month." ) # fields for risk elicitation cat_end_rel_1 = models.FloatField( doc="Indicates the end point of the first category in relative size.") cat_end_rel_2 = models.FloatField( doc="Indicates the end point of the second category in relative size.") cat_end_rel_3 = models.FloatField( doc="Indicates the end point of the third category in relative size.") cat_end_rel_4 = models.FloatField( doc="Indicates the end point of the fourth category in relative size.") cat_end_rel_5 = models.FloatField( doc="Indicates the end point of the fifth category in relative size.") cat_end_abs_1 = models.PositiveIntegerField( doc="Indicates the end point of the first category in pixels.") cat_end_abs_2 = models.PositiveIntegerField( doc="Indicates the end point of the second category in pixels.") cat_end_abs_3 = models.PositiveIntegerField( doc="Indicates the end point of the third category in pixels.") cat_end_abs_4 = models.PositiveIntegerField( doc="Indicates the end point of the fourth category in pixels.") cat_end_abs_5 = models.PositiveIntegerField( doc="Indicates the end point of the fifth category in pixels.") # Dummies für Stata: female = models.BooleanField( doc="Turns True if the participant is a woman.") male = models.BooleanField(doc="Turns True if the participant is a man.") other_gender = models.BooleanField( doc="Turns True if the participant indicates other.") econ_student = models.BooleanField( doc="Turns True if the participant is an economics student.") follow_customer = models.BooleanField( doc= "Turns True if the agent chooses the communicated category of his customer according to his OWN elicited categories." ) higher_than_customer = models.BooleanField( doc= "Turns True if the investment of the agent is in a higher category than the one communicated by the principal according to his OWN elicited categories." ) lower_than_customer = models.BooleanField( doc= "Turns True if the investment of the agent is in a lower category than the one communicated by the principal according to his OWN elicited categories." ) def create_gender_dummies(self): if self.gender == "weiblich": self.female = True self.male = False self.other_gender = False elif self.gender == "männlich": self.female = False self.male = True self.other_gender = False elif self.gender == "anderes": self.female = False self.male = False self.other_gender = True def create_econ_dummy(self): if self.studies: subject = self.studies.lower() if "econ" in subject: self.econ_student = True elif "vwl" in subject: self.econ_student = True elif "ökono" in subject: self.econ_student = True else: self.econ_student = False else: self.econ_student = False def create_category_dummies(self): if self.category_from_principal == "sehr konservativ": if 0 <= self.decision_for_p1 < self.cat_end_rel_1 * 10: self.follow_customer = True self.higher_than_customer = False self.lower_than_customer = False else: self.follow_customer = False if self.decision_for_p1 >= self.cat_end_rel_1 * 10: self.higher_than_customer = True self.lower_than_customer = False elif self.decision_for_p1 < 0: self.lower_than_customer = True self.higher_than_customer = False if self.category_from_principal == "sicherheitsorientiert": if self.cat_end_rel_1 * 10 <= self.decision_for_p1 < self.cat_end_rel_2 * 10: self.follow_customer = True self.higher_than_customer = False self.lower_than_customer = False else: self.follow_customer = False if self.decision_for_p1 >= self.cat_end_rel_2 * 10: self.higher_than_customer = True self.lower_than_customer = False if self.decision_for_p1 < self.cat_end_rel_1 * 10: self.lower_than_customer = True self.higher_than_customer = False if self.category_from_principal == "ausgeglichen": if self.cat_end_rel_2 * 10 <= self.decision_for_p1 < self.cat_end_rel_3 * 10: self.follow_customer = True self.higher_than_customer = False self.lower_than_customer = False else: self.follow_customer = False if self.decision_for_p1 >= self.cat_end_rel_3 * 10: self.higher_than_customer = True self.lower_than_customer = False if self.decision_for_p1 < self.cat_end_rel_2 * 10: self.lower_than_customer = True self.higher_than_customer = False if self.category_from_principal == "wachstumsorientiert": if self.cat_end_rel_3 * 10 <= self.decision_for_p1 < self.cat_end_rel_4 * 10: self.follow_customer = True self.higher_than_customer = False self.lower_than_customer = False else: self.follow_customer = False if self.decision_for_p1 >= self.cat_end_rel_4 * 10: self.higher_than_customer = True self.lower_than_customer = False elif self.decision_for_p1 < self.cat_end_rel_3 * 10: self.lower_than_customer = True self.higher_than_customer = False if self.category_from_principal == "offensiv": if self.cat_end_rel_4 * 10 <= self.decision_for_p1 <= 10: self.follow_customer = True self.higher_than_customer = False self.lower_than_customer = False else: self.follow_customer = False if self.decision_for_p1 > 1: self.higher_than_customer = True self.lower_than_customer = False elif self.decision_for_p1 < self.cat_end_rel_4 * 10: self.lower_than_customer = True self.higher_than_customer = False
class Player(BasePlayer): my_group_id = models.IntegerField() random_number = models.IntegerField() compensation = models.CharField( doc="Compensation scheme put in place for agents (see Settings)." ) participation_fee = models.CurrencyField( doc="Participation fee for all agents." ) # Gerade Nummern sind Prinzipale und ungerade Agenten def role(self): return "Principal" if self.id_in_group % 2 == 0 else "Agent" # Assign partners (i.e. build principal agent couples: 1-2, 3-4, 5-6) partner = models.IntegerField( doc="Gives the ID in Group of the partner.") def find_partners(self): if self.id_in_group == 1: self.partner = 2 elif self.id_in_group == 2: self.partner = 1 elif self.id_in_group == 3: self.partner = 4 elif self.id_in_group == 4: self.partner = 3 elif self.id_in_group == 5: self.partner = 6 elif self.id_in_group == 6: self.partner = 5 # Everyone chooses the category: category = models.CharField( choices=Constants.category_names, widget=widgets.RadioSelect(), verbose_name="Bitte wählen Sie nun einen der fünf Begriffe:", doc="Principals choose the category which is communicated to their agent" ) category_from_principal = models.CharField( doc="Category that agents receive from their principals indicating how they want their agent to invest. Only for the agent who is payoff relevant." ) def get_category(self): if self.role() == "Agent": principal = self.get_others_in_group()[int(self.partner)-2] self.category_from_principal = principal.category # Part II: Investment for Group members c_principal_1 = models.IntegerField() c_principal_2 = models.IntegerField() c_principal_3 = models.IntegerField() c_principal_4 = models.IntegerField() c_principal_5 = models.IntegerField() def find_principals(self): # c for corresponding if self.id_in_group == 1: self.c_principal_1 = 2 self.c_principal_2 = 3 self.c_principal_3 = 4 self.c_principal_4 = 5 self.c_principal_5 = 6 elif self.id_in_group == 2: self.c_principal_1 = 1 self.c_principal_2 = 3 self.c_principal_3 = 4 self.c_principal_4 = 5 self.c_principal_5 = 6 elif self.id_in_group == 3: self.c_principal_1 = 1 self.c_principal_2 = 2 self.c_principal_3 = 4 self.c_principal_4 = 5 self.c_principal_5 = 6 elif self.id_in_group == 4: self.c_principal_1 = 1 self.c_principal_2 = 2 self.c_principal_3 = 3 self.c_principal_4 = 5 self.c_principal_5 = 6 elif self.id_in_group == 5: self.c_principal_1 = 1 self.c_principal_2 = 2 self.c_principal_3 = 3 self.c_principal_4 = 4 self.c_principal_5 = 6 elif self.id_in_group == 6: self.c_principal_1 = 1 self.c_principal_2 = 2 self.c_principal_3 = 3 self.c_principal_4 = 4 self.c_principal_5 = 5 decision_for_p1 = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset." ) decision_for_p2 = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset." ) decision_for_p3 = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset." ) decision_for_p4 = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset." ) decision_for_p5 = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset." ) # principals can send messages to their agents: message = models.CharField( choices=["Ich bin sehr zufrieden mit Ihrer Entscheidung", "Ich bin zufrieden mit Ihrer Entscheidung", "Ich bin unzufrieden mit Ihrer Entscheidung", "Ich bin sehr unzufrieden mit Ihrer Entscheidung"], widget=widgets.RadioSelect(), verbose_name="Wählen Sie dazu eine der vorgefertigten Mitteilungen aus:", doc="Principals choose the message to send to the agents." ) message_from_principal = models.CharField( doc="Message that agents receive from their principals." ) # Payoffs: investment = models.CurrencyField( doc="Indicates for everyone the investment decision as taken by their agents." ) def get_investment(self): if self.role() == "Principal": agent = self.get_others_in_group()[int(self.partner)-1] if self.id_in_group == 2: self.investment = agent.decision_for_p1 if self.id_in_group == 4: self.investment = agent.decision_for_p3 if self.id_in_group == 6: self.investment = agent.decision_for_p5 # Damit die Agenten ihre Investitionen für den für die Auszahlung relevanten Prinzipal sehen: invested_amount = models.CurrencyField( doc="For agents, this gives us the investment in the risky option for their relevant principal (agents own decision).") def get_invested_amount(self): if self.role() == "Agent": principal = self.get_others_in_group()[int(self.partner)-2] self.invested_amount = principal.investment # Investition in risky asset: Erfolgreich oder nicht erfolgreich: def determine_outcome(self): randomizer = random.randint(1,3) if self.role() == "Principal": if randomizer == 1: self.investment_outcome = 1 else: self.investment_outcome = 0 investment_outcome = models.IntegerField( doc="Turns 1 if the investment was successful and 0 in case it was not." ) # Get outcome of the principals as a variable for the agents: outcome_of_principal = models.IntegerField( doc="Message that agents receive from their principals." ) def get_outcome_of_principal(self): if self.role() == "Agent": principal = self.get_others_in_group()[int(self.partner)-2] self.outcome_of_principal = principal.investment_outcome def calculate_payoffs_principals(self): if self.role() == "Principal": if self.investment_outcome == 1: self.payoff = self.investment * 3.5 + (Constants.endowment_principals - self.investment) self.profit = self.investment * 2.5 elif self.investment_outcome == 0: self.payoff = Constants.endowment_principals - self.investment self.profit = 0 profit = models.CurrencyField( doc="Gives the profit of the principal." ) payoff_of_principal = models.CurrencyField( doc="Gives for each agent the payoff of his principal." ) profit_of_principal = models.CurrencyField( doc="Gives for each agent the payoff of his principal." ) def get_msg_payoff_profit(self): if self.role() == "Agent": principal = self.get_others_in_group()[int(self.partner)-2] self.profit_of_principal = principal.profit self.payoff_of_principal = principal.payoff self.message_from_principal = principal.message def calculate_payoffs_agents(self): if self.role() == "Agent": if self.compensation == "fixed": self.payoff = Constants.fixed_payment if self.compensation == "variable_result": self.payoff = Constants.variable_payment + Constants.share_result/100 * self.payoff_of_principal if self.compensation == "variable_profit": self.payoff = Constants.variable_payment + Constants.share_profit/100 * self.profit_of_principal # Comprehension Questions question_1 = models.CharField( widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) question_2 = models.CharField( widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) question_3 = models.CurrencyField() question_4 = models.CurrencyField() question_5 = models.CharField( widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) question_6 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) # Questionnaire: age = models.PositiveIntegerField( max=100, verbose_name="Wie alt sind Sie?", doc="We ask participants for their age between 0 and 100 years" ) gender = models.CharField( choices=["männlich", "weiblich", "anderes"], widget=widgets.RadioSelect(), verbose_name="Was ist Ihr Geschlecht?", doc="gender indication" ) studies = models.CharField( blank=True, verbose_name="Was studieren Sie im Hauptfach?", doc="field of studies indication." ) nonstudent = models.BooleanField( widget=widgets.CheckboxInput(), verbose_name="Kein Student", doc="Ticking the checkbox means that the participant is a non-student.") financial_advice = models.BooleanField( choices=[(True, "Ja"),(False, "Nein")], widget=widgets.RadioSelect(), verbose_name="Haben Sie bereits eine Bankberatung in Anspruch genommen?", doc="We ask participants if they ever made use of financial advice.") income = models.CurrencyField( verbose_name="Wie viel Geld im Monat steht Ihnen frei zur Verfügung?", doc="We ask participants how much money they have freely available each month.") # fields for risk elicitation cat_end_rel_1 = models.FloatField( doc="Indicates the end point of the first category in relative size.") cat_end_rel_2 = models.FloatField( doc="Indicates the end point of the second category in relative size.") cat_end_rel_3 = models.FloatField( doc="Indicates the end point of the third category in relative size.") cat_end_rel_4 = models.FloatField( doc="Indicates the end point of the fourth category in relative size.") cat_end_rel_5 = models.FloatField( doc="Indicates the end point of the fifth category in relative size.") cat_end_abs_1 = models.PositiveIntegerField( doc="Indicates the end point of the first category in pixels.") cat_end_abs_2 = models.PositiveIntegerField( doc="Indicates the end point of the second category in pixels.") cat_end_abs_3 = models.PositiveIntegerField( doc="Indicates the end point of the third category in pixels.") cat_end_abs_4 = models.PositiveIntegerField( doc="Indicates the end point of the fourth category in pixels.") cat_end_abs_5 = models.PositiveIntegerField( doc="Indicates the end point of the fifth category in pixels.") # Dummies für Stata: female = models.BooleanField( doc="Turns True if the participant is a woman." ) male = models.BooleanField( doc="Turns True if the participant is a man." ) other_gender = models.BooleanField( doc="Turns True if the participant indicates other." ) econ_student = models.BooleanField( doc="Turns True if the participant is an economics student." ) follow_customer_1 = models.BooleanField( doc="Turns True if the agent chooses the communicated category of his first customer according to his OWN elicited categories." ) follow_customer_2 = models.BooleanField( doc="Turns True if the agent chooses the communicated category of his second customer according to his OWN elicited categories." ) follow_customer_3 = models.BooleanField( doc="Turns True if the agent chooses the communicated category of his third customer according to his OWN elicited categories." ) follow_customer_4 = models.BooleanField( doc="Turns True if the agent chooses the communicated category of his fourth customer according to his OWN elicited categories." ) follow_customer_5 = models.BooleanField( doc="Turns True if the agent chooses the communicated category of his fifth customer according to his OWN elicited categories." ) higher_than_customer_1 = models.BooleanField( doc="Turns True if the investment of the agent is in a higher category than the one communicated by the first principal according to his OWN elicited categories." ) higher_than_customer_2 = models.BooleanField( doc="Turns True if the investment of the agent is in a higher category than the one communicated by the second principal according to his OWN elicited categories." ) higher_than_customer_3 = models.BooleanField( doc="Turns True if the investment of the agent is in a higher category than the one communicated by the third principal according to his OWN elicited categories." ) higher_than_customer_4 = models.BooleanField( doc="Turns True if the investment of the agent is in a higher category than the one communicated by the fourth principal according to his OWN elicited categories." ) higher_than_customer_5 = models.BooleanField( doc="Turns True if the investment of the agent is in a higher category than the one communicated by the fifth principal according to his OWN elicited categories." ) lower_than_customer_1 = models.BooleanField( doc="Turns True if the investment of the agent is in a lower category than the one communicated by the principal according to his OWN elicited categories." ) lower_than_customer_2 = models.BooleanField( doc="Turns True if the investment of the agent is in a lower category than the one communicated by the principal according to his OWN elicited categories." ) lower_than_customer_3 = models.BooleanField( doc="Turns True if the investment of the agent is in a lower category than the one communicated by the principal according to his OWN elicited categories." ) lower_than_customer_4 = models.BooleanField( doc="Turns True if the investment of the agent is in a lower category than the one communicated by the principal according to his OWN elicited categories." ) lower_than_customer_5 = models.BooleanField( doc="Turns True if the investment of the agent is in a lower category than the one communicated by the principal according to his OWN elicited categories." ) category_from_p1 = models.CharField( doc="Category received from every clients first principal." ) category_from_p2 = models.CharField( doc="Category received from every clients second principal." ) category_from_p3 = models.CharField( doc="Category received from every clients third principal." ) category_from_p4 = models.CharField( doc="Category received from every clients fourth principal." ) category_from_p5 = models.CharField( doc="Category received from every clients fifth principal." ) def create_gender_dummies(self): if self.gender == "weiblich": self.female = True self.male = False self.other_gender = False elif self.gender == "männlich": self.female = False self.male = True self.other_gender = False elif self.gender == "anderes": self.female = False self.male = False self.other_gender = True def create_econ_dummy(self): if self.studies: subject = self.studies.lower() if "econ" in subject: self.econ_student = True elif "vwl" in subject: self.econ_student = True elif "ökono" in subject: self.econ_student = True else: self.econ_student = False else: self.econ_student = False def get_categories(self): player_list = self.get_others_in_group() player_list.append(self) player_list.sort(key=lambda p: p.id_in_group) # for player in player_list: # print(player.id_in_group) self.category_from_p1=player_list[int(self.c_principal_1)-1].category self.category_from_p2=player_list[int(self.c_principal_2)-1].category self.category_from_p3=player_list[int(self.c_principal_3)-1].category self.category_from_p4=player_list[int(self.c_principal_4)-1].category self.category_from_p5=player_list[int(self.c_principal_5)-1].category def create_category_dummies_1(self): if self.category_from_p1 == "sehr konservativ": if 0 <= self.decision_for_p1 < self.cat_end_rel_1*10: self.follow_customer_1 = True self.higher_than_customer_1 = False self.lower_than_customer_1 = False else: self.follow_customer_1 = False if self.decision_for_p1 >= self.cat_end_rel_1*10: self.higher_than_customer_1 = True self.lower_than_customer_1 = False elif self.decision_for_p1 < 0: self.lower_than_customer_1 = True self.higher_than_customer_1 = False if self.category_from_p1 == "sicherheitsorientiert": if self.cat_end_rel_1*10 <= self.decision_for_p1 < self.cat_end_rel_2*10: self.follow_customer_1 = True self.higher_than_customer_1 = False self.lower_than_customer_1 = False else: self.follow_customer_1 = False if self.decision_for_p1 >= self.cat_end_rel_2*10: self.higher_than_customer_1 = True self.lower_than_customer_1 = False if self.decision_for_p1 < self.cat_end_rel_1*10: self.lower_than_customer_1 = True self.higher_than_customer_1 = False if self.category_from_p1 == "ausgeglichen": if self.cat_end_rel_2*10 <= self.decision_for_p1 < self.cat_end_rel_3*10: self.follow_customer_1 = True self.higher_than_customer_1 = False self.lower_than_customer_1 = False else: self.follow_customer_1 = False if self.decision_for_p1 >= self.cat_end_rel_3*10: self.higher_than_customer_1 = True self.lower_than_customer_1 = False if self.decision_for_p1 < self.cat_end_rel_2*10: self.lower_than_customer_1 = True self.higher_than_customer_1 = False if self.category_from_p1 == "wachstumsorientiert": if self.cat_end_rel_3*10 <= self.decision_for_p1 < self.cat_end_rel_4*10: self.follow_customer_1 = True self.higher_than_customer_1 = False self.lower_than_customer_1 = False else: self.follow_customer_1 = False if self.decision_for_p1 >= self.cat_end_rel_4*10: self.higher_than_customer_1 = True self.lower_than_customer_1 = False elif self.decision_for_p1 < self.cat_end_rel_3*10: self.lower_than_customer_1 = True self.higher_than_customer_1 =False if self.category_from_p1 == "offensiv": if self.cat_end_rel_4*10 <= self.decision_for_p1 <= 10: self.follow_customer_1 = True self.higher_than_customer_1 = False self.lower_than_customer_1 = False else: self.follow_customer_1 = False if self.decision_for_p1 > 1: self.higher_than_customer_1 = True self.lower_than_customer_1 = False elif self.decision_for_p1 < self.cat_end_rel_4*10: self.lower_than_customer_1 = True self.higher_than_customer_1 = False def create_category_dummies_2(self): if self.category_from_p2 == "sehr konservativ": if 0 <= self.decision_for_p2 < self.cat_end_rel_1*10: self.follow_customer_2 = True self.higher_than_customer_2 = False self.lower_than_customer_2 = False else: self.follow_customer_2 = False if self.decision_for_p2 >= self.cat_end_rel_1*10: self.higher_than_customer_2 = True self.lower_than_customer_2 = False elif self.decision_for_p2 < 0: self.lower_than_customer_2 = True self.higher_than_customer_2 = False if self.category_from_p2 == "sicherheitsorientiert": if self.cat_end_rel_1*10 <= self.decision_for_p2 < self.cat_end_rel_2*10: self.follow_customer_2 = True self.higher_than_customer_2 = False self.lower_than_customer_2 = False else: self.follow_customer_2 = False if self.decision_for_p2 >= self.cat_end_rel_2*10: self.higher_than_customer_2 = True self.lower_than_customer_2 = False if self.decision_for_p2 < self.cat_end_rel_1*10: self.lower_than_customer_2 = True self.higher_than_customer_2 = False if self.category_from_p2 == "ausgeglichen": if self.cat_end_rel_2*10 <= self.decision_for_p2 < self.cat_end_rel_3*10: self.follow_customer_2 = True self.higher_than_customer_2 = False self.lower_than_customer_2 = False else: self.follow_customer_2 = False if self.decision_for_p2 >= self.cat_end_rel_3*10: self.higher_than_customer_2 = True self.lower_than_customer_2 = False if self.decision_for_p2 < self.cat_end_rel_2*10: self.lower_than_customer_2 = True self.higher_than_customer_2 = False if self.category_from_p2 == "wachstumsorientiert": if self.cat_end_rel_3*10 <= self.decision_for_p2 < self.cat_end_rel_4*10: self.follow_customer_2 = True self.higher_than_customer_2 = False self.lower_than_customer_2 = False else: self.follow_customer_2 = False if self.decision_for_p2 >= self.cat_end_rel_4*10: self.higher_than_customer_2 = True self.lower_than_customer_2 = False elif self.decision_for_p2 < self.cat_end_rel_3*10: self.lower_than_customer_2 = True self.higher_than_customer_2 =False if self.category_from_p2 == "offensiv": if self.cat_end_rel_4*10 <= self.decision_for_p2 <= 10: self.follow_customer_2 = True self.higher_than_customer_2 = False self.lower_than_customer_2 = False else: self.follow_customer_2 = False if self.decision_for_p2 > 1: self.higher_than_customer_2 = True self.lower_than_customer_2 = False elif self.decision_for_p2 < self.cat_end_rel_4*10: self.lower_than_customer_2 = True self.higher_than_customer_2 = False def create_category_dummies_3(self): if self.category_from_p3 == "sehr konservativ": if 0 <= self.decision_for_p3 < self.cat_end_rel_1*10: self.follow_customer_3 = True self.higher_than_customer_3 = False self.lower_than_customer_3 = False else: self.follow_customer_3 = False if self.decision_for_p3 >= self.cat_end_rel_1*10: self.higher_than_customer_3 = True self.lower_than_customer_3 = False elif self.decision_for_p3 < 0: self.lower_than_customer_3 = True self.higher_than_customer_3 = False if self.category_from_p3 == "sicherheitsorientiert": if self.cat_end_rel_1*10 <= self.decision_for_p3 < self.cat_end_rel_2*10: self.follow_customer_3 = True self.higher_than_customer_3 = False self.lower_than_customer_3 = False else: self.follow_customer_3 = False if self.decision_for_p3 >= self.cat_end_rel_2*10: self.higher_than_customer_3 = True self.lower_than_customer_3 = False if self.decision_for_p3 < self.cat_end_rel_1*10: self.lower_than_customer_3 = True self.higher_than_customer_3 = False if self.category_from_p3 == "ausgeglichen": if self.cat_end_rel_2*10 <= self.decision_for_p3 < self.cat_end_rel_3*10: self.follow_customer_3 = True self.higher_than_customer_3 = False self.lower_than_customer_3 = False else: self.follow_customer_3 = False if self.decision_for_p3 >= self.cat_end_rel_3*10: self.higher_than_customer_3 = True self.lower_than_customer_3 = False if self.decision_for_p3 < self.cat_end_rel_2*10: self.lower_than_customer_3 = True self.higher_than_customer_3 = False if self.category_from_p3 == "wachstumsorientiert": if self.cat_end_rel_3*10 <= self.decision_for_p3 < self.cat_end_rel_4*10: self.follow_customer_3 = True self.higher_than_customer_3 = False self.lower_than_customer_3 = False else: self.follow_customer_3 = False if self.decision_for_p3 >= self.cat_end_rel_4*10: self.higher_than_customer_3 = True self.lower_than_customer_3 = False elif self.decision_for_p3 < self.cat_end_rel_3*10: self.lower_than_customer_3 = True self.higher_than_customer_3 =False if self.category_from_p3 == "offensiv": if self.cat_end_rel_4*10 <= self.decision_for_p3 <= 10: self.follow_customer_3 = True self.higher_than_customer_3 = False self.lower_than_customer_3 = False else: self.follow_customer_3 = False if self.decision_for_p3 > 1: self.higher_than_customer_3 = True self.lower_than_customer_3 = False elif self.decision_for_p3 < self.cat_end_rel_4*10: self.lower_than_customer_3 = True self.higher_than_customer_3 = False def create_category_dummies_4(self): if self.category_from_p4 == "sehr konservativ": if 0 <= self.decision_for_p4 < self.cat_end_rel_1*10: self.follow_customer_4 = True self.higher_than_customer_4 = False self.lower_than_customer_4 = False else: self.follow_customer_4 = False if self.decision_for_p4 >= self.cat_end_rel_1*10: self.higher_than_customer_4 = True self.lower_than_customer_4 = False elif self.decision_for_p4 < 0: self.lower_than_customer_4 = True self.higher_than_customer_4 = False if self.category_from_p4 == "sicherheitsorientiert": if self.cat_end_rel_1*10 <= self.decision_for_p4 < self.cat_end_rel_2*10: self.follow_customer_4 = True self.higher_than_customer_4 = False self.lower_than_customer_4 = False else: self.follow_customer_4 = False if self.decision_for_p4 >= self.cat_end_rel_2*10: self.higher_than_customer_4 = True self.lower_than_customer_4 = False if self.decision_for_p4 < self.cat_end_rel_1*10: self.lower_than_customer_4 = True self.higher_than_customer_4 = False if self.category_from_p4 == "ausgeglichen": if self.cat_end_rel_2*10 <= self.decision_for_p4 < self.cat_end_rel_3*10: self.follow_customer_4 = True self.higher_than_customer_4 = False self.lower_than_customer_4 = False else: self.follow_customer_4 = False if self.decision_for_p4 >= self.cat_end_rel_3*10: self.higher_than_customer_4 = True self.lower_than_customer_4 = False if self.decision_for_p4 < self.cat_end_rel_2*10: self.lower_than_customer_4 = True self.higher_than_customer_4 = False if self.category_from_p4 == "wachstumsorientiert": if self.cat_end_rel_3*10 <= self.decision_for_p4 < self.cat_end_rel_4*10: self.follow_customer_4 = True self.higher_than_customer_4 = False self.lower_than_customer_4 = False else: self.follow_customer_4 = False if self.decision_for_p4 >= self.cat_end_rel_4*10: self.higher_than_customer_4 = True self.lower_than_customer_4 = False elif self.decision_for_p4 < self.cat_end_rel_3*10: self.lower_than_customer_4 = True self.higher_than_customer_4 =False if self.category_from_p4 == "offensiv": if self.cat_end_rel_4*10 <= self.decision_for_p4 <= 10: self.follow_customer_4 = True self.higher_than_customer_4 = False self.lower_than_customer_4 = False else: self.follow_customer_4 = False if self.decision_for_p4 > 1: self.higher_than_customer_4 = True self.lower_than_customer_4 = False elif self.decision_for_p4 < self.cat_end_rel_4*10: self.lower_than_customer_4 = True self.higher_than_customer_4 = False def create_category_dummies_5(self): if self.category_from_p5 == "sehr konservativ": if 0 <= self.decision_for_p5 < self.cat_end_rel_1*10: self.follow_customer_5 = True self.higher_than_customer_5 = False self.lower_than_customer_5 = False else: self.follow_customer_5 = False if self.decision_for_p5 >= self.cat_end_rel_1*10: self.higher_than_customer_5 = True self.lower_than_customer_5 = False elif self.decision_for_p5 < 0: self.lower_than_customer_5 = True self.higher_than_customer_5 = False if self.category_from_p5 == "sicherheitsorientiert": if self.cat_end_rel_1*10 <= self.decision_for_p5 < self.cat_end_rel_2*10: self.follow_customer_5 = True self.higher_than_customer_5 = False self.lower_than_customer_5 = False else: self.follow_customer_5 = False if self.decision_for_p5 >= self.cat_end_rel_2*10: self.higher_than_customer_5 = True self.lower_than_customer_5 = False if self.decision_for_p5 < self.cat_end_rel_1*10: self.lower_than_customer_5 = True self.higher_than_customer_5 = False if self.category_from_p5 == "ausgeglichen": if self.cat_end_rel_2*10 <= self.decision_for_p5 < self.cat_end_rel_3*10: self.follow_customer_5 = True self.higher_than_customer_5 = False self.lower_than_customer_5 = False else: self.follow_customer_5 = False if self.decision_for_p5 >= self.cat_end_rel_3*10: self.higher_than_customer_5 = True self.lower_than_customer_5 = False if self.decision_for_p5 < self.cat_end_rel_2*10: self.lower_than_customer_5 = True self.higher_than_customer_5 = False if self.category_from_p5 == "wachstumsorientiert": if self.cat_end_rel_3*10 <= self.decision_for_p5 < self.cat_end_rel_4*10: self.follow_customer_5 = True self.higher_than_customer_5 = False self.lower_than_customer_5 = False else: self.follow_customer_5 = False if self.decision_for_p5 >= self.cat_end_rel_4*10: self.higher_than_customer_5 = True self.lower_than_customer_5 = False elif self.decision_for_p5 < self.cat_end_rel_3*10: self.lower_than_customer_5= True self.higher_than_customer_5 =False if self.category_from_p5 == "offensiv": if self.cat_end_rel_4*10 <= self.decision_for_p5 <= 10: self.follow_customer_5 = True self.higher_than_customer_5 = False self.lower_than_customer_5 = False else: self.follow_customer_5 = False if self.decision_for_p5 > 1: self.higher_than_customer_5 = True self.lower_than_customer_5 = False elif self.decision_for_p5 < self.cat_end_rel_4*10: self.lower_than_customer_5 = True self.higher_than_customer_5 = False
class Player(BasePlayer): treatment = models.BooleanField() choice = models.StringField(widget=widgets.RadioSelectHorizontal) selection = models.IntegerField(verbose_name="Choose your political position from 0 to 10, 0 being left", widget=widgets.Slider(attrs={'step': '1', }), min=0, max=10)
class Player(BasePlayer): age = models.IntegerField(label="Wie alt sind Sie?") gender = models.IntegerField(choices=[[1, 'Männlich'], [2, 'Weiblich'], [3, 'Divers']], label="Was ist Ihr Geschlecht?", widget=widgets.RadioSelect) sibling_number = models.IntegerField( label="Wie viele Geschwister haben Sie?") program = models.CharField(label="Welchen Studiengang belegen Sie?") grad_or_undergrad_choices = (('Bachelor', 'Bachelor'), ('Master', 'Master')) graduate_or_undergraduate = models.CharField( choices=grad_or_undergrad_choices, label='Studieren Sie im Bachelor oder im Master?', widget=widgets.RadioSelect) year_of_program = models.IntegerField( label= "Im wievielten Semester Ihres aktuellen Studiums befinden Sie sich?") previous_experiments = OtherModelField( choices=['Nein'], label= "Haben Sie vorher jemals an ökonomischen oder psychologischen Experimenten teilgenommen?", other_label='Ja (Bitte geben Sie an wie häufig)', other_value='Ja_', blank=True) importance_of_religion = models.IntegerField( label= "Auf einer Skala von 0 (Überhaupt nicht wichtig) bis 10 (sehr wichtig), wie wichtig ist Religion in Ihrem Leben?", widget=widgets.Slider(show_value=True, attrs={ 'min': 0, 'max': 10, 'step': 1 })) nationality = models.CharField(choices=['Deutsch', 'Nicht-Deutsch'], label='Was ist Ihre Nationalität?', widget=widgets.RadioSelect) volunteer_work = OtherModelField( choices=['Nein'], label= "Haben Sie in den letzten 12 Monaten ehrenamtlich für Hochschulgruppen, Vereine oder andere gemeinnützige Organisationen gearbeitet?", other_label= 'Ja (Bitte geben Sie an wie viele Stunden Sie dort insgesamt gearbeitet haben)', other_value='Ja_', blank=True) helpfulness_of_communication = models.IntegerField( label= "Auf einer Skala von 0 (Überhaupt nicht hilfreich) bis 10 (äußerst hilfreich), bewerten Sie bitte wie hilfreich Sie die Kommunikation mit Ihren Gruppenmitgliedern empfunden haben um die beiden extra Fragen bezüglich der Bilder zu beantworten", widget=widgets.Slider(show_value=True, attrs={ 'class': 'helpfulness_of_communication', 'min': 0, 'max': 10, 'step': 1 })) attachment_level = models.IntegerField( label= "Auf einer Skala von 0 (überhaupt nicht verbunden) bis 10 (äußerst verbunden), bewerten Sie bitte, wie eng Sie sich während des gesamten Experiments mit Ihrer eigenen Gruppe verbunden gefühlt haben", widget=widgets.Slider(show_value=True, attrs={ 'min': 0, 'max': 10, 'step': 1 })) ease_of_instruction = models.IntegerField( label= "Auf einer Skala von 0 (überhaupt nicht einfach) bis 10 (äußerst einfach), wie einfach konnten Sie den Instruktionen folgen und die Aufgaben im Experiment erledigen?", widget=widgets.Slider(show_value=True, attrs={ 'min': 0, 'max': 10, 'step': 1 })) hard_to_follow_instructions = models.TextField( label= "Gab es irgendwelche Instruktionen die Sie schwer verstanden haben? Wenn ja, listen Sie diese bitte auf.", blank=True) familiarity_with_klee = models.IntegerField( label= "Bitte bewerten Sie auf einer Skala von 0 (überhaupt nicht vertraut) bis 10 (äußerst vertraut), wie vertraut Sie mit den Gemälden von Klee vor diesem Experiment waren.", widget=widgets.Slider(show_value=True, attrs={ 'min': 0, 'max': 10, 'step': 1 })) familiarity_with_kandinsky = models.IntegerField( label= "Bitte bewerten Sie auf einer Skala von 0 (überhaupt nicht vertraut) bis 10 (äußerst vertraut), wie vertraut Sie mit den Gemälden von Kandinsky vor diesem Experiment waren.", widget=widgets.Slider(show_value=True, attrs={ 'min': 0, 'max': 10, 'step': 1 })) dictator_strategy_no_risk_choices = (( 'equally', 'a) Versuch, Punkte gleichmäßig zwischen beiden aufteilen.' ), ( 'more_to_own_group', 'b) Versuch, dem Teilnehmer Ihrer eigenen Gruppe mehr Punkte zuzuteilen.' ), ('more_to_other_group', 'c) Versuch, dem Teilnehmer der anderen Gruppe mehr Punkte zuzuteilen.' ), ('random', 'd) Zufällig.')) dictator_strategy_risk_choices = (( 'equally', 'a) Versuch, Punkte gleichmäßig zwischen beiden aufteilen.' ), ( 'more_to_own_group', 'b) Versuch, dem Teilnehmer Ihrer eigenen Gruppe mehr Punkte zuzuteilen.' ), ( 'more_to_other_group', 'c) Versuch, dem Teilnehmer der anderen Gruppe mehr Punkte zuzuteilen.' ), ('maximise_my_earning', 'd) Versuch, unter Berücksichtigung des Risikos Ihre Auszahlung zu erhöhen.' ), ('both_a_and_d', 'e) Sowohl a) als auch d).'), ('both_b_and_d', 'f) Sowohl b) als auch d).'), ('both_c_and_d', 'g) Sowohl c) als auch d).'), ('random', 'h) Zufällig.')) dictator_strategy_no_risk = OtherModelField( label= 'Im zweiten Teil des Experiments sollten Sie Punkte zwischen den anderen beiden Teilnehmern verteilen und waren keinem Risiko bezüglich Ihrer eigenen Zuteilung ausgesetzt, wie würden Sie die von Ihnen angewendete Strategie beschreiben?', choices=dictator_strategy_no_risk_choices, other_label='e) Sonstige (Bitte spezifizieren Sie)', blank=True) dictator_strategy_risk = OtherModelField( label= "Im zweiten Teil des Experiments sollten Sie Punkte zwischen den anderen beiden Teilnehmern verteilen und waren einem Risiko bezüglich Ihrer eigenen Zuteilung ausgesetzt, wie würden Sie die von Ihnen angewendete Strategie beschreiben?", choices=dictator_strategy_risk_choices, other_label='i) Sonstige (Bitte spezifizieren Sie)', blank=True) group_dynamic_influence = models.TextField( label= "Wie hat die Gruppendynamik Ihre Entscheidungen insgesamt beeinflusst?" ) payoff = models.FloatField() payoff_in_euros = models.FloatField() f_p = models.FloatField()
class Player(BasePlayer): contribution = models.CurrencyField(choices=currency_range( c(0), c(Constants.endowment), c(1)), label="あなたはいくら貢献しますか?", widget=widgets.Slider())
class Player(BasePlayer): mindestreichweite_sofort = models.FloatField( label='Bitte geben Sie Ihre Mindestreichweite sofort an', widget=widgets.Slider(attrs={'step': '1'}), min=Constants.aktuell_kilometer, max=Constants.max_kilometer) mindestreichweite_spaeter = models.FloatField( label='Bitte geben Sie Ihre Mindestreichweite später an', widget=widgets.Slider(attrs={'step': '1'}), min=Constants.aktuell_kilometer, max=Constants.max_kilometer) gewuenschte_abfahrt = models.FloatField( label= 'Bitte geben Sie an bis wann die Mindestreichweite später geladen sein soll', widget=widgets.Slider(attrs={'step': '0.5'}), min=0.5, max=24) ladeflexibilitaet = models.FloatField() geladene_kilometer = models.FloatField() treatment_group = models.StringField() aktuelle_gewinnchance = models.FloatField() minutes = models.IntegerField() hours = models.IntegerField() gewuenschte_abfahrt_minutes = models.IntegerField() gewuenschte_abfahrt_hours = models.IntegerField() # crt_zufriedenheit_vor_realisation = models.IntegerField(widget=widgets.RadioSelect, # label='Wie zufrieden sind Sie mit Ihrer Entscheidung?', # choices=[[1, 'Völlig unzufrieden'], # [2, 'Weitgehend unzufrieden'], # [3, 'Eher unzufrieden'], # [4, 'Weder noch'], # [5, 'Eher zufrieden'], # [6, 'Weitgehend zufrieden'], # [7, 'Völlig zufrieden']]) crt_zufriedenheit_vor_realisation = models.IntegerField( widget=widgets.RadioSelectHorizontal, label='Wie zufrieden sind Sie mit Ihrer Entscheidung?', choices=[[1, 'Völlig unzufrieden'], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, 'Völlig zufrieden']]) # crt_zufriedenheit_nach_Realisation = models.IntegerField(widget=widgets.RadioSelect, # label='Wie zufrieden sind Sie mit Ihrer Entscheidung?', # choices=[[1, 'Völlig unzufrieden'], # [2, 'Weitgehend unzufrieden'], # [3, 'Eher unzufrieden'], # [4, 'Weder noch'], # [5, 'Eher zufrieden'], # [6, 'Weitgehend zufrieden'], # [7, 'Völlig zufrieden']]) crt_zufriedenheit_nach_Realisation = models.IntegerField( widget=widgets.RadioSelectHorizontal, label='Wie zufrieden sind Sie mit Ihrer Entscheidung?', choices=[[1, 'Völlig unzufrieden'], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, 'Völlig zufrieden']]) crt_grafik_verstaendnis = models.IntegerField( widget=widgets.RadioSelectHorizontal, label= 'Wie verständlich war die auf der vorherigen Seite angezeigte Grafik für Sie?', choices=[[1, 'Völlig unverständlich'], [2, ''], [3, ''], [4, ''], [5, ''], [6, ''], [7, 'Völlig verständlich']]) alte_punkte = models.CurrencyField() def set_ladeflexibilitaet(self): ladedauer_maximal = min( self.gewuenschte_abfahrt, (Constants.max_kilometer - Constants.aktuell_kilometer) / Constants.max_laderate) mindestreichweite_sofort_dauer = min( self.gewuenschte_abfahrt, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: self.ladeflexibilitaet = 0 else: gewichtungsfaktor_zaehler = max( 0, max( 0, self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / (self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer)) gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate if gewichtungsfaktor >= 1: self.ladeflexibilitaet = 0 else: mindestreichweite_spaeter_dauer = max( 0, (self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / Constants.max_laderate) self.ladeflexibilitaet = round( (1 - (mindestreichweite_sofort_dauer + gewichtungsfaktor * mindestreichweite_spaeter_dauer) / ladedauer_maximal) * 100, 0) def set_payoff(self): if Constants.to_drive <= self.geladene_kilometer: self.payoff = c(self.payoff + self.ladeflexibilitaet) else: self.payoff = c(self.payoff - self.ladeflexibilitaet) def charge_up(self): # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Sollte die Zeit nicht ausreichen wird die gewünschte Abfahrt genommen mindestreichweite_sofort_dauer = min( self.gewuenschte_abfahrt, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) # dieser Block ist neu: if Constants.abfahrt >= self.gewuenschte_abfahrt: # Die gewünschte Abfahrt ist kleiner gleich der gezogenen Abfahrt, der Ladevorgang kann also wie geplant vorgenommen werden if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite sofort aufzuladen dauert länger oder genauso lange wie das Auto steht. Es wird daher die gesamte Standzeit mit maximaler Laderate geladen. Die Ladeflexibilität sollte bei diesem Fall bei 0 liegen. self.geladene_kilometer = round( Constants.aktuell_kilometer + (self.gewuenschte_abfahrt * Constants.max_laderate), 2) else: # Die gewünschte Mindestreichweite sofort aufzuladen nimmt nicht die gesamte Standdauer in Anspruch if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die geforderte Mindestreichweite sofort ist größer als die geforderte Mindestreichweite später. Es werden also einfach so viele Kilometer geladen wie in der Mindestreichweite sofort gefordert self.geladene_kilometer = self.mindestreichweite_sofort else: # Jetzt der etwas kompliziertere Fall: Die Mindestreichweite sofort wird aufgeladen, aber die geforderte Mindestreichweite später ist größer. Nach Erreichen der Mindestreichweite sofort wird also noch mit einer verringerten Laderate geladen. gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort ) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer ) # wir wissen, dass die mindestreichweite später größer ist als die mindestreichweite sofort, muss daher größer 0 sein # Nenner kann nicht 0 werden, da bereits festgestellt wurde, dass die Mindestreichweite sofort aufzuladen nicht die gesamte Standdauer benötigt # Insgesamt (die Variable die hier mit gewichtungsfaktor_zaehler bezeichnet wird) wird hier also berechnet wie viele Kilometer pro Stunde geladen werden müssen um die Mindestreichweite später vor Ende der Standzeit zu erreichen gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate # Der Gewichtungsfaktor überprüft ob die maximale Laderate ausreicht um die noch zu ladenden Kilometer aufzuladen. Ist er > 1 reicht die Zeit nicht aus. Es muss also die gesamte restliche Zeit mit maximaler Laderate geladen werden if gewichtungsfaktor <= 1: # Erst der einfache Fall: der gewichtungsfaktor ist kleiner oder gleich 1: damit reicht die Zeit aus um das Autoa auf die geforderte Mindestreichweite später zu laden (auch wenn es sein kann, dass der Gewichtungsfaktor genau 1 ist und somit die gesamte Zeit mit maximaler Laderate aufgeladen werden muss - die Ladeflexibilität also 0 ist) self.geladene_kilometer = self.mindestreichweite_spaeter else: # Hier reicht die restliche Zeit nicht aus. Es wird daher erst berechnet wie viel Zeit nach erreichen der Mindestreichweite sofort noch übrig ist restliche_zeit = self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer # Diese verbleibende Zeit wird mit maximaler Laderate geladen self.geladene_kilometer = round( self.mindestreichweite_sofort + (restliche_zeit * Constants.max_laderate), 2) else: # Die gewünschte Abfahrt ist liegt nach der tatsächlichen Abfahrtszeit. Es kann also vorkommen, dass der Ladevorgang unterbrochen werden muss # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Falls die Mindestreichweite sofort nicht in der tatsächlichen (hier: gezogenen) Standdauer erreicht werden kann wird dies signalisiert indem die dauer auf die (hier:gezogene) Standdauer gesetzt wird. mindestreichweite_sofort_dauer_drawn = min( Constants.abfahrt, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite kann nicht erreicht werden. Allerdings muss das Auto jetzt sogar noch früher los. Deswegen wird hier die restliche Zeit nicht über die gewünschte Abfahrtszeit bestimmt sondern über die tatsächliche, gezogene Abfahrtszeit self.geladene_kilometer = round( Constants.aktuell_kilometer + (Constants.abfahrt * Constants.max_laderate), 2) else: # Die Mindestreichweite sofort aufzuladen würde nicht die gesamte Standdauer in Anspruch nehmen. if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die gewünschte Mindestreichweite sofort ist größer als die Mindestreichweite später. Die Mindestreichweite später kann also ignoriert werden. if mindestreichweite_sofort_dauer > mindestreichweite_sofort_dauer_drawn: # Dauert es länger die Mindestreichweite sofort zu laden als Zeit bis zur tatsächlichen Abfahrt zur Verfügung steht, wird der Ladeprozess unterbrochen sobald die tatsächliche Abfahrtszeit erreicht ist self.geladene_kilometer = round( Constants.aktuell_kilometer + (Constants.abfahrt * Constants.max_laderate), 2) else: # Die Mindesterichweite sofort dauer und die Mindestreichweite sofort dauer drawn sollten jetzt gleich sein # Die Zeit sollte auch mit dem früheren Abfahrtstermin ausreichen die geforderte Mindestreichweite sofort zu erreichen. Zusätzlich muss nicht weiter geladen werden. self.geladene_kilometer = self.mindestreichweite_sofort else: # Die Mindestreichweite später kann nicht einfach ignoriert werden gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer) gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate if gewichtungsfaktor <= 1: # Erst der einfachere Fall: Der Gewichtungsfaktor ist kleiner gleich 1, die restliche Zeit (gemessen an der gewünschten Abfahrtszeit) reicht also aus um die Mindestreichweite später zu laden if mindestreichweite_sofort_dauer_drawn == Constants.abfahrt: # Die gezogene Abfahrtszeit liegt so, dass noch nicht einmal die Mindestreichweite sofort aufgelden werden kann. Das Auto denkt aber es hat Zeit erst die Mindestreichweite sofort zu laden und dann noch die Mindestreichweite später self.geladene_kilometer = round( Constants.aktuell_kilometer + (Constants.abfahrt * Constants.max_laderate), 2) else: # Die gezogene Abfahrtszeit reicht aus um die gewünschte Mindestreichweite sofort aufzuladen # Reicht die Zeit auch um die Mindestreichweite später aufzuladen (Gewichtungfaktor <= 1) wird angenommen, dass die gesamte Restzeit mit einer verringerten Laderate geladen wird. D.h. hier wird erst die Mindestreichweite sofort aufgeladen um dann mit verringerter Laderate die restlich Zeit aufzuladen restliche_zeit = Constants.abfahrt - mindestreichweite_sofort_dauer_drawn self.geladene_kilometer = round( self.mindestreichweite_sofort + (restliche_zeit * gewichtungsfaktor_zaehler), 2) else: # Der Gewichtungsfaktor ist > 1, also würde die urpsrüngliche Zeit nicht ausreichen um die Mindestreichweite später zu laden # Hier würde auch normalerweise die gesamte Standdauer über mit der maximalen Laderate aufgeladen werden. Also muss nicht erst noch überprüft werden ob die Standdauer ausreicht um die Mindestreichweite sofort aufzuladen self.geladene_kilometer = round( Constants.aktuell_kilometer + (Constants.abfahrt * Constants.max_laderate), 2) def calculate_minutes(self): self.minutes = int((Constants.abfahrt % 1) * 60) def calculate_hours(self): self.hours = int(Constants.abfahrt) def calculate_gewuenscht_abfahrt_minutes(self): self.gewuenschte_abfahrt_minutes = int( (self.gewuenschte_abfahrt % 1) * 60) def calculate_gewuenschte_abfahrt_hours(self): self.gewuenschte_abfahrt_hours = int(self.gewuenschte_abfahrt) def reset_payoff(self): if self.payoff < 0: self.alte_punkte = self.payoff self.payoff = 0
class Player(BasePlayer): mindestreichweite_sofort = models.FloatField( label='Bitte geben Sie Ihre Mindestreichweite sofort an', widget=widgets.Slider(attrs={'step': '1'}), min=Constants.aktuell_kilometer, max=Constants.max_kilometer) mindestreichweite_spaeter = models.FloatField( label='Bitte geben Sie Ihre Mindestreichweite später an', widget=widgets.Slider(attrs={'step': '1'}), min=Constants.aktuell_kilometer, max=Constants.max_kilometer) gewuenschte_abfahrt = models.FloatField( label= 'Bitte geben Sie an bis wann die Mindestreichweite später geladen sein soll', widget=widgets.Slider(attrs={'step': '0.5'}), min=0.5, max=24) ladeflexibilitaet = models.FloatField() geladene_kilometer1 = models.FloatField() geladene_kilometer2 = models.FloatField() geladene_kilometer3 = models.FloatField() treatment_group = models.StringField() minutes1 = models.IntegerField() hours1 = models.IntegerField() minutes2 = models.IntegerField() hours2 = models.IntegerField() minutes3 = models.IntegerField() hours3 = models.IntegerField() gewuenschte_abfahrt_minutes = models.IntegerField() gewuenschte_abfahrt_hours = models.IntegerField() punkte1 = models.IntegerField() punkte2 = models.IntegerField() punkte3 = models.IntegerField() def charge_up1(self): # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Sollte die Zeit nicht ausreichen wird die gewünschte Abfahrt genommen mindestreichweite_sofort_dauer = min( self.gewuenschte_abfahrt, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) # dieser Block ist neu: if Constants.abfahrt1 >= self.gewuenschte_abfahrt: # Die gewünschte Abfahrt ist kleiner gleich der gezogenen Abfahrt, der Ladevorgang kann also wie geplant vorgenommen werden if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite sofort aufzuladen dauert länger oder genauso lange wie das Auto steht. Es wird daher die gesamte Standzeit mit maximaler Laderate geladen. Die Ladeflexibilität sollte bei diesem Fall bei 0 liegen. self.geladene_kilometer1 = round( Constants.aktuell_kilometer + (self.gewuenschte_abfahrt * Constants.max_laderate), 2) else: # Die gewünschte Mindestreichweite sofort aufzuladen nimmt nicht die gesamte Standdauer in Anspruch if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die geforderte Mindestreichweite sofort ist größer als die geforderte Mindestreichweite später. Es werden also einfach so viele Kilometer geladen wie in der Mindestreichweite sofort gefordert self.geladene_kilometer1 = self.mindestreichweite_sofort else: # Jetzt der etwas kompliziertere Fall: Die Mindestreichweite sofort wird aufgeladen, aber die geforderte Mindestreichweite später ist größer. Nach Erreichen der Mindestreichweite sofort wird also noch mit einer verringerten Laderate geladen. gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort ) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer ) # wir wissen, dass die mindestreichweite später größer ist als die mindestreichweite sofort, muss daher größer 0 sein # Nenner kann nicht 0 werden, da bereits festgestellt wurde, dass die Mindestreichweite sofort aufzuladen nicht die gesamte Standdauer benötigt # Insgesamt (die Variable die hier mit gewichtungsfaktor_zaehler bezeichnet wird) wird hier also berechnet wie viele Kilometer pro Stunde geladen werden müssen um die Mindestreichweite später vor Ende der Standzeit zu erreichen gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate # Der Gewichtungsfaktor überprüft ob die maximale Laderate ausreicht um die noch zu ladenden Kilometer aufzuladen. Ist er > 1 reicht die Zeit nicht aus. Es muss also die gesamte restliche Zeit mit maximaler Laderate geladen werden if gewichtungsfaktor <= 1: # Erst der einfache Fall: der gewichtungsfaktor ist kleiner oder gleich 1: damit reicht die Zeit aus um das Autoa auf die geforderte Mindestreichweite später zu laden (auch wenn es sein kann, dass der Gewichtungsfaktor genau 1 ist und somit die gesamte Zeit mit maximaler Laderate aufgeladen werden muss - die Ladeflexibilität also 0 ist) self.geladene_kilometer1 = self.mindestreichweite_spaeter else: # Hier reicht die restliche Zeit nicht aus. Es wird daher erst berechnet wie viel Zeit nach erreichen der Mindestreichweite sofort noch übrig ist restliche_zeit = self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer # Diese verbleibende Zeit wird mit maximaler Laderate geladen self.geladene_kilometer1 = round( self.mindestreichweite_sofort + (restliche_zeit * Constants.max_laderate), 2) else: # Die gewünschte Abfahrt ist liegt nach der tatsächlichen Abfahrtszeit. Es kann also vorkommen, dass der Ladevorgang unterbrochen werden muss # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Falls die Mindestreichweite sofort nicht in der tatsächlichen (hier: gezogenen) Standdauer erreicht werden kann wird dies signalisiert indem die dauer auf die (hier:gezogene) Standdauer gesetzt wird. mindestreichweite_sofort_dauer_drawn = min( Constants.abfahrt1, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite kann nicht erreicht werden. Allerdings muss das Auto jetzt sogar noch früher los. Deswegen wird hier die restliche Zeit nicht über die gewünschte Abfahrtszeit bestimmt sondern über die tatsächliche, gezogene Abfahrtszeit self.geladene_kilometer1 = round( Constants.aktuell_kilometer + (Constants.abfahrt1 * Constants.max_laderate), 2) else: # Die Mindestreichweite sofort aufzuladen würde nicht die gesamte Standdauer in Anspruch nehmen. if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die gewünschte Mindestreichweite sofort ist größer als die Mindestreichweite später. Die Mindestreichweite später kann also ignoriert werden. if mindestreichweite_sofort_dauer > mindestreichweite_sofort_dauer_drawn: # Dauert es länger die Mindestreichweite sofort zu laden als Zeit bis zur tatsächlichen Abfahrt zur Verfügung steht, wird der Ladeprozess unterbrochen sobald die tatsächliche Abfahrtszeit erreicht ist self.geladene_kilometer1 = round( Constants.aktuell_kilometer + (Constants.abfahrt1 * Constants.max_laderate), 2) else: # Die Mindesterichweite sofort dauer und die Mindestreichweite sofort dauer drawn sollten jetzt gleich sein # Die Zeit sollte auch mit dem früheren Abfahrtstermin ausreichen die geforderte Mindestreichweite sofort zu erreichen. Zusätzlich muss nicht weiter geladen werden. self.geladene_kilometer1 = self.mindestreichweite_sofort else: # Die Mindestreichweite später kann nicht einfach ignoriert werden gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer) gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate if gewichtungsfaktor <= 1: # Erst der einfachere Fall: Der Gewichtungsfaktor ist kleiner gleich 1, die restliche Zeit (gemessen an der gewünschten Abfahrtszeit) reicht also aus um die Mindestreichweite später zu laden if mindestreichweite_sofort_dauer_drawn == Constants.abfahrt1: # Die gezogene Abfahrtszeit liegt so, dass noch nicht einmal die Mindestreichweite sofort aufgelden werden kann. Das Auto denkt aber es hat Zeit erst die Mindestreichweite sofort zu laden und dann noch die Mindestreichweite später self.geladene_kilometer1 = round( Constants.aktuell_kilometer + (Constants.abfahrt1 * Constants.max_laderate), 2) else: # Die gezogene Abfahrtszeit reicht aus um die gewünschte Mindestreichweite sofort aufzuladen # Reicht die Zeit auch um die Mindestreichweite später aufzuladen (Gewichtungfaktor <= 1) wird angenommen, dass die gesamte Restzeit mit einer verringerten Laderate geladen wird. D.h. hier wird erst die Mindestreichweite sofort aufgeladen um dann mit verringerter Laderate die restlich Zeit aufzuladen restliche_zeit = Constants.abfahrt1 - mindestreichweite_sofort_dauer_drawn self.geladene_kilometer1 = round( self.mindestreichweite_sofort + (restliche_zeit * gewichtungsfaktor_zaehler), 2) else: # Der Gewichtungsfaktor ist > 1, also würde die urpsrüngliche Zeit nicht ausreichen um die Mindestreichweite später zu laden # Hier würde auch normalerweise die gesamte Standdauer über mit der maximalen Laderate aufgeladen werden. Also muss nicht erst noch überprüft werden ob die Standdauer ausreicht um die Mindestreichweite sofort aufzuladen self.geladene_kilometer1 = round( Constants.aktuell_kilometer + (Constants.abfahrt1 * Constants.max_laderate), 2) def charge_up2(self): # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Sollte die Zeit nicht ausreichen wird die gewünschte Abfahrt genommen mindestreichweite_sofort_dauer = min( self.gewuenschte_abfahrt, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) # dieser Block ist neu: if Constants.abfahrt2 >= self.gewuenschte_abfahrt: # Die gewünschte Abfahrt ist kleiner gleich der gezogenen Abfahrt, der Ladevorgang kann also wie geplant vorgenommen werden if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite sofort aufzuladen dauert länger oder genauso lange wie das Auto steht. Es wird daher die gesamte Standzeit mit maximaler Laderate geladen. Die Ladeflexibilität sollte bei diesem Fall bei 0 liegen. self.geladene_kilometer2 = round( Constants.aktuell_kilometer + (self.gewuenschte_abfahrt * Constants.max_laderate), 2) else: # Die gewünschte Mindestreichweite sofort aufzuladen nimmt nicht die gesamte Standdauer in Anspruch if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die geforderte Mindestreichweite sofort ist größer als die geforderte Mindestreichweite später. Es werden also einfach so viele Kilometer geladen wie in der Mindestreichweite sofort gefordert self.geladene_kilometer2 = self.mindestreichweite_sofort else: # Jetzt der etwas kompliziertere Fall: Die Mindestreichweite sofort wird aufgeladen, aber die geforderte Mindestreichweite später ist größer. Nach Erreichen der Mindestreichweite sofort wird also noch mit einer verringerten Laderate geladen. gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort ) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer ) # wir wissen, dass die mindestreichweite später größer ist als die mindestreichweite sofort, muss daher größer 0 sein # Nenner kann nicht 0 werden, da bereits festgestellt wurde, dass die Mindestreichweite sofort aufzuladen nicht die gesamte Standdauer benötigt # Insgesamt (die Variable die hier mit gewichtungsfaktor_zaehler bezeichnet wird) wird hier also berechnet wie viele Kilometer pro Stunde geladen werden müssen um die Mindestreichweite später vor Ende der Standzeit zu erreichen gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate # Der Gewichtungsfaktor überprüft ob die maximale Laderate ausreicht um die noch zu ladenden Kilometer aufzuladen. Ist er > 1 reicht die Zeit nicht aus. Es muss also die gesamte restliche Zeit mit maximaler Laderate geladen werden if gewichtungsfaktor <= 1: # Erst der einfache Fall: der gewichtungsfaktor ist kleiner oder gleich 1: damit reicht die Zeit aus um das Autoa auf die geforderte Mindestreichweite später zu laden (auch wenn es sein kann, dass der Gewichtungsfaktor genau 1 ist und somit die gesamte Zeit mit maximaler Laderate aufgeladen werden muss - die Ladeflexibilität also 0 ist) self.geladene_kilometer2 = self.mindestreichweite_spaeter else: # Hier reicht die restliche Zeit nicht aus. Es wird daher erst berechnet wie viel Zeit nach erreichen der Mindestreichweite sofort noch übrig ist restliche_zeit = self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer # Diese verbleibende Zeit wird mit maximaler Laderate geladen self.geladene_kilometer2 = round( self.mindestreichweite_sofort + (restliche_zeit * Constants.max_laderate), 2) else: # Die gewünschte Abfahrt ist liegt nach der tatsächlichen Abfahrtszeit. Es kann also vorkommen, dass der Ladevorgang unterbrochen werden muss # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Falls die Mindestreichweite sofort nicht in der tatsächlichen (hier: gezogenen) Standdauer erreicht werden kann wird dies signalisiert indem die dauer auf die (hier:gezogene) Standdauer gesetzt wird. mindestreichweite_sofort_dauer_drawn = min( Constants.abfahrt2, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite kann nicht erreicht werden. Allerdings muss das Auto jetzt sogar noch früher los. Deswegen wird hier die restliche Zeit nicht über die gewünschte Abfahrtszeit bestimmt sondern über die tatsächliche, gezogene Abfahrtszeit self.geladene_kilometer2 = round( Constants.aktuell_kilometer + (Constants.abfahrt2 * Constants.max_laderate), 2) else: # Die Mindestreichweite sofort aufzuladen würde nicht die gesamte Standdauer in Anspruch nehmen. if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die gewünschte Mindestreichweite sofort ist größer als die Mindestreichweite später. Die Mindestreichweite später kann also ignoriert werden. if mindestreichweite_sofort_dauer > mindestreichweite_sofort_dauer_drawn: # Dauert es länger die Mindestreichweite sofort zu laden als Zeit bis zur tatsächlichen Abfahrt zur Verfügung steht, wird der Ladeprozess unterbrochen sobald die tatsächliche Abfahrtszeit erreicht ist self.geladene_kilometer2 = round( Constants.aktuell_kilometer + (Constants.abfahrt2 * Constants.max_laderate), 2) else: # Die Mindesterichweite sofort dauer und die Mindestreichweite sofort dauer drawn sollten jetzt gleich sein # Die Zeit sollte auch mit dem früheren Abfahrtstermin ausreichen die geforderte Mindestreichweite sofort zu erreichen. Zusätzlich muss nicht weiter geladen werden. self.geladene_kilometer2 = self.mindestreichweite_sofort else: # Die Mindestreichweite später kann nicht einfach ignoriert werden gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer) gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate if gewichtungsfaktor <= 1: # Erst der einfachere Fall: Der Gewichtungsfaktor ist kleiner gleich 1, die restliche Zeit (gemessen an der gewünschten Abfahrtszeit) reicht also aus um die Mindestreichweite später zu laden if mindestreichweite_sofort_dauer_drawn == Constants.abfahrt2: # Die gezogene Abfahrtszeit liegt so, dass noch nicht einmal die Mindestreichweite sofort aufgelden werden kann. Das Auto denkt aber es hat Zeit erst die Mindestreichweite sofort zu laden und dann noch die Mindestreichweite später self.geladene_kilometer2 = round( Constants.aktuell_kilometer + (Constants.abfahrt2 * Constants.max_laderate), 2) else: # Die gezogene Abfahrtszeit reicht aus um die gewünschte Mindestreichweite sofort aufzuladen # Reicht die Zeit auch um die Mindestreichweite später aufzuladen (Gewichtungfaktor <= 1) wird angenommen, dass die gesamte Restzeit mit einer verringerten Laderate geladen wird. D.h. hier wird erst die Mindestreichweite sofort aufgeladen um dann mit verringerter Laderate die restlich Zeit aufzuladen restliche_zeit = Constants.abfahrt2 - mindestreichweite_sofort_dauer_drawn self.geladene_kilometer2 = round( self.mindestreichweite_sofort + (restliche_zeit * gewichtungsfaktor_zaehler), 2) else: # Der Gewichtungsfaktor ist > 1, also würde die urpsrüngliche Zeit nicht ausreichen um die Mindestreichweite später zu laden # Hier würde auch normalerweise die gesamte Standdauer über mit der maximalen Laderate aufgeladen werden. Also muss nicht erst noch überprüft werden ob die Standdauer ausreicht um die Mindestreichweite sofort aufzuladen self.geladene_kilometer2 = round( Constants.aktuell_kilometer + (Constants.abfahrt2 * Constants.max_laderate), 2) def charge_up3(self): # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Sollte die Zeit nicht ausreichen wird die gewünschte Abfahrt genommen mindestreichweite_sofort_dauer = min( self.gewuenschte_abfahrt, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) # dieser Block ist neu: if Constants.abfahrt3 >= self.gewuenschte_abfahrt: # Die gewünschte Abfahrt ist kleiner gleich der gezogenen Abfahrt, der Ladevorgang kann also wie geplant vorgenommen werden if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite sofort aufzuladen dauert länger oder genauso lange wie das Auto steht. Es wird daher die gesamte Standzeit mit maximaler Laderate geladen. Die Ladeflexibilität sollte bei diesem Fall bei 0 liegen. self.geladene_kilometer3 = round( Constants.aktuell_kilometer + (self.gewuenschte_abfahrt * Constants.max_laderate), 2) else: # Die gewünschte Mindestreichweite sofort aufzuladen nimmt nicht die gesamte Standdauer in Anspruch if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die geforderte Mindestreichweite sofort ist größer als die geforderte Mindestreichweite später. Es werden also einfach so viele Kilometer geladen wie in der Mindestreichweite sofort gefordert self.geladene_kilometer3 = self.mindestreichweite_sofort else: # Jetzt der etwas kompliziertere Fall: Die Mindestreichweite sofort wird aufgeladen, aber die geforderte Mindestreichweite später ist größer. Nach Erreichen der Mindestreichweite sofort wird also noch mit einer verringerten Laderate geladen. gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort ) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer ) # wir wissen, dass die mindestreichweite später größer ist als die mindestreichweite sofort, muss daher größer 0 sein # Nenner kann nicht 0 werden, da bereits festgestellt wurde, dass die Mindestreichweite sofort aufzuladen nicht die gesamte Standdauer benötigt # Insgesamt (die Variable die hier mit gewichtungsfaktor_zaehler bezeichnet wird) wird hier also berechnet wie viele Kilometer pro Stunde geladen werden müssen um die Mindestreichweite später vor Ende der Standzeit zu erreichen gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate # Der Gewichtungsfaktor überprüft ob die maximale Laderate ausreicht um die noch zu ladenden Kilometer aufzuladen. Ist er > 1 reicht die Zeit nicht aus. Es muss also die gesamte restliche Zeit mit maximaler Laderate geladen werden if gewichtungsfaktor <= 1: # Erst der einfache Fall: der gewichtungsfaktor ist kleiner oder gleich 1: damit reicht die Zeit aus um das Autoa auf die geforderte Mindestreichweite später zu laden (auch wenn es sein kann, dass der Gewichtungsfaktor genau 1 ist und somit die gesamte Zeit mit maximaler Laderate aufgeladen werden muss - die Ladeflexibilität also 0 ist) self.geladene_kilometer3 = self.mindestreichweite_spaeter else: # Hier reicht die restliche Zeit nicht aus. Es wird daher erst berechnet wie viel Zeit nach erreichen der Mindestreichweite sofort noch übrig ist restliche_zeit = self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer # Diese verbleibende Zeit wird mit maximaler Laderate geladen self.geladene_kilometer3 = round( self.mindestreichweite_sofort + (restliche_zeit * Constants.max_laderate), 2) else: # Die gewünschte Abfahrt ist liegt nach der tatsächlichen Abfahrtszeit. Es kann also vorkommen, dass der Ladevorgang unterbrochen werden muss # Erst muss ausgerechnet werden wie lange es dauert die gewünschte Mindestreichweite sofort aufzuladen. Falls die Mindestreichweite sofort nicht in der tatsächlichen (hier: gezogenen) Standdauer erreicht werden kann wird dies signalisiert indem die dauer auf die (hier:gezogene) Standdauer gesetzt wird. mindestreichweite_sofort_dauer_drawn = min( Constants.abfahrt3, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: # Die gewünschte Mindestreichweite kann nicht erreicht werden. Allerdings muss das Auto jetzt sogar noch früher los. Deswegen wird hier die restliche Zeit nicht über die gewünschte Abfahrtszeit bestimmt sondern über die tatsächliche, gezogene Abfahrtszeit self.geladene_kilometer3 = round( Constants.aktuell_kilometer + (Constants.abfahrt3 * Constants.max_laderate), 2) else: # Die Mindestreichweite sofort aufzuladen würde nicht die gesamte Standdauer in Anspruch nehmen. if self.mindestreichweite_sofort >= self.mindestreichweite_spaeter: # Erst der einfache Fall: die gewünschte Mindestreichweite sofort ist größer als die Mindestreichweite später. Die Mindestreichweite später kann also ignoriert werden. if mindestreichweite_sofort_dauer > mindestreichweite_sofort_dauer_drawn: # Dauert es länger die Mindestreichweite sofort zu laden als Zeit bis zur tatsächlichen Abfahrt zur Verfügung steht, wird der Ladeprozess unterbrochen sobald die tatsächliche Abfahrtszeit erreicht ist self.geladene_kilometer3 = round( Constants.aktuell_kilometer + (Constants.abfahrt3 * Constants.max_laderate), 2) else: # Die Mindesterichweite sofort dauer und die Mindestreichweite sofort dauer drawn sollten jetzt gleich sein # Die Zeit sollte auch mit dem früheren Abfahrtstermin ausreichen die geforderte Mindestreichweite sofort zu erreichen. Zusätzlich muss nicht weiter geladen werden. self.geladene_kilometer3 = self.mindestreichweite_sofort else: # Die Mindestreichweite später kann nicht einfach ignoriert werden gewichtungsfaktor_zaehler = ( self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / ( self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer) gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate if gewichtungsfaktor <= 1: # Erst der einfachere Fall: Der Gewichtungsfaktor ist kleiner gleich 1, die restliche Zeit (gemessen an der gewünschten Abfahrtszeit) reicht also aus um die Mindestreichweite später zu laden if mindestreichweite_sofort_dauer_drawn == Constants.abfahrt3: # Die gezogene Abfahrtszeit liegt so, dass noch nicht einmal die Mindestreichweite sofort aufgelden werden kann. Das Auto denkt aber es hat Zeit erst die Mindestreichweite sofort zu laden und dann noch die Mindestreichweite später self.geladene_kilometer3 = round( Constants.aktuell_kilometer + (Constants.abfahrt3 * Constants.max_laderate), 2) else: # Die gezogene Abfahrtszeit reicht aus um die gewünschte Mindestreichweite sofort aufzuladen # Reicht die Zeit auch um die Mindestreichweite später aufzuladen (Gewichtungfaktor <= 1) wird angenommen, dass die gesamte Restzeit mit einer verringerten Laderate geladen wird. D.h. hier wird erst die Mindestreichweite sofort aufgeladen um dann mit verringerter Laderate die restlich Zeit aufzuladen restliche_zeit = Constants.abfahrt3 - mindestreichweite_sofort_dauer_drawn self.geladene_kilometer3 = round( self.mindestreichweite_sofort + (restliche_zeit * gewichtungsfaktor_zaehler), 2) else: # Der Gewichtungsfaktor ist > 1, also würde die urpsrüngliche Zeit nicht ausreichen um die Mindestreichweite später zu laden # Hier würde auch normalerweise die gesamte Standdauer über mit der maximalen Laderate aufgeladen werden. Also muss nicht erst noch überprüft werden ob die Standdauer ausreicht um die Mindestreichweite sofort aufzuladen self.geladene_kilometer3 = round( Constants.aktuell_kilometer + (Constants.abfahrt3 * Constants.max_laderate), 2) def set_ladeflexibilitaet(self): ladedauer_maximal = min( self.gewuenschte_abfahrt, (Constants.max_kilometer - Constants.aktuell_kilometer) / Constants.max_laderate) mindestreichweite_sofort_dauer = min( self.gewuenschte_abfahrt, (self.mindestreichweite_sofort - Constants.aktuell_kilometer) / Constants.max_laderate) if mindestreichweite_sofort_dauer == self.gewuenschte_abfahrt: self.ladeflexibilitaet = 0 else: gewichtungsfaktor_zaehler = max( 0, max( 0, self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / (self.gewuenschte_abfahrt - mindestreichweite_sofort_dauer)) gewichtungsfaktor = gewichtungsfaktor_zaehler / Constants.max_laderate if gewichtungsfaktor >= 1: self.ladeflexibilitaet = 0 else: mindestreichweite_spaeter_dauer = max( 0, (self.mindestreichweite_spaeter - self.mindestreichweite_sofort) / Constants.max_laderate) self.ladeflexibilitaet = round( (1 - (mindestreichweite_sofort_dauer + gewichtungsfaktor * mindestreichweite_spaeter_dauer) / ladedauer_maximal) * 100, 0) def set_payoff1(self): if Constants.to_drive1 <= self.geladene_kilometer1: self.punkte1 = int(0 + self.ladeflexibilitaet) else: self.punkte1 = int(0 - self.ladeflexibilitaet) def set_payoff2(self): if Constants.to_drive2 <= self.geladene_kilometer2: self.punkte2 = int(0 + self.ladeflexibilitaet) else: self.punkte2 = int(0 - self.ladeflexibilitaet) def set_payoff3(self): if Constants.to_drive3 <= self.geladene_kilometer3: self.punkte3 = int(0 + self.ladeflexibilitaet) else: self.punkte3 = int(0 - self.ladeflexibilitaet) def reset_payoff(self): self.participant.payoff = 0 def calculate_minutes1(self): self.minutes1 = int((Constants.abfahrt1 % 1) * 60) def calculate_hours1(self): self.hours1 = int(Constants.abfahrt1) def calculate_minutes2(self): self.minutes2 = int((Constants.abfahrt2 % 1) * 60) def calculate_hours2(self): self.hours2 = int(Constants.abfahrt2) def calculate_minutes3(self): self.minutes3 = int((Constants.abfahrt3 % 1) * 60) def calculate_hours3(self): self.hours3 = int(Constants.abfahrt3) def calculate_gewuenscht_abfahrt_minutes(self): self.gewuenschte_abfahrt_minutes = int( (self.gewuenschte_abfahrt % 1) * 60) def calculate_gewuenschte_abfahrt_hours(self): self.gewuenschte_abfahrt_hours = int(self.gewuenschte_abfahrt)
class Group(BaseGroup): amb1A_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb1A win?", min=0, max=1) amb1B_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb1B win?", min=0, max=1) amb2A_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb2A win?", min=0, max=1) amb2B_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb2B win?", min=0, max=1) red1A_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for red1A win?", min=0, max=1) red1B_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for red1B win?", min=0, max=1) amb1mA_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb1mA win?", min=0, max=1) amb1mB_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb1mB win?", min=0, max=1) amb2mA_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb2mA win?", min=0, max=1) amb2mB_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for amb2mB win?", min=0, max=1) red1mA_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for red1mA win?", min=0, max=1) red1mB_WIN = models.PositiveIntegerField( widget=widgets.Slider(), verbose_name="Did the draw for red1mB win?", min=0, max=1)
class Player(BasePlayer): contribution1 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_0 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute an average of 0 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_2 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 1 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_4 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 2 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_6 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 3 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_8 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 4 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_10 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 5 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_12 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 6 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_14 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 7 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_16 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 8 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_18 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 9 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_1_20 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 10 quarters?', widget=widgets.Slider(attrs={'step': '1'})) contribution2 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_0 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 0 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_2 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 1 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_4 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 2 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_6 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 3 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_8 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 4 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_10 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 5 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_12 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 6 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_14 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 7 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_16 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 8 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_18 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 9 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_2_20 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 10 quarters?', widget=widgets.Slider(attrs={'step': '1'})) contribution3 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_0 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 0 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_2 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 1 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_4 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 2 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_6 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 3 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_8 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 4 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_10 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 5 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_12 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 6 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_14 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 7 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_16 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 8 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_18 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 9 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_3_20 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 10 quarters?', widget=widgets.Slider(attrs={'step': '1'})) contribution4 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_0 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 0 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_2 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 1 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_4 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 2 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_6 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 3 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_8 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 4 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_10 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 5 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_12 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 6 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_14 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 7 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_16 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 8 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_18 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 9 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_4_20 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 10 quarters?', widget=widgets.Slider(attrs={'step': '1'})) contribution5 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_0 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 0 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_2 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 1 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_4 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 2 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_6 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 3 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_8 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 4 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_10 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 5 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_12 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 6 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_14 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 7 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_16 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 8 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_18 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 9 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_5_20 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 10 quarters?', widget=widgets.Slider(attrs={'step': '1'})) contribution6 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_0 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 0 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_2 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 1 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_4 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 2 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_6 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 3 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_8 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 4 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_10 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 5 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_12 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 6 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_14 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 7 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_16 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 8 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_18 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 9 quarters?', widget=widgets.Slider(attrs={'step': '1'})) Cond_contribution_6_20 = models.IntegerField( min=0, max=10, label='How many quarters from ' 'your endowment would you like to contribute to the group account if the other members contribute and average of 10 quarters?', widget=widgets.Slider(attrs={'step': '1'})) belief1 = models.IntegerField( min=0, max=10, label= 'What do you believe a participant who has never been accused of taking ANY ' 'amount of money from their partner will contribute to the group account on average?', widget=widgets.Slider(attrs={'step': '1'})) belief2 = models.IntegerField( min=0, max=10, label= 'What do you believe a participant who HAS been accused of taking some amount of money from their ' 'partner, ' 'but never found ' 'guilty, ' 'will contribute to the group account on average?', widget=widgets.Slider(attrs={'step': '1'})) belief3 = models.IntegerField( min=0, max=10, label= 'What do you believe a participant who HAS been accused and HAS been found guilty ' 'of taking some amount of money from their ' 'partner will contribute to the group account on average?', widget=widgets.Slider(attrs={'step': '1'})) quiz1 = models.IntegerField( choices= [[1, '(a) You are each endowed with with 5.'], [ 2, '(b) You are endowed with 10 and your partners endowed with with 0.' ], [3, '(c) Your partners are endowed with 10 and you start with 0.'], [4, '(d) You are each endowed with 10.']], widget=widgets.RadioSelect, label= "Question 1: How many quarters are you and your partners endowed with for this part of the experiment?" ) quiz2 = models.IntegerField( choices=[ [ 1, '(a) Everyone will earn $2 ($4 x 0.5) from your contribution.' ], [ 2, '(b) Everyone will earn $4 ($4 x 1.0) from your contribution.' ], [ 3, '(c) Everyone will earn $1 ($4 x 0.25) from your contribution.' ], ], widget=widgets.RadioSelect, label="Question 2: If you contribute $4 to the Group Account ") quiz3 = models.IntegerField( choices=[ [1, '(a) $0 is held in your Private Account.'], [2, '(b) $4 is held in your Private Account.'], [3, '(c) $6 is held is your Private Account.'], ], widget=widgets.RadioSelect, label="Question 3: If you contribute $4 to the Group Account ") quiz4 = models.IntegerField(choices=[ [ 1, '(a) All partners you could interact with in this part of the experiment are guaranteed to have ' 'taken money from others previously.' ], [ 2, '(b) Some partners who were truly innocent may have been found guilty of taking money from another ' 'subject.' ], [ 3, '(c) Partners who were found guilty of taking money from another participant faced no monetary ' 'penalty from their guilty finding.' ], ], widget=widgets.RadioSelect, label= "Question 4: Which of the following is true ") chosen_one = models.BooleanField() def keep_role(self): self.participant.vars['module1role'] = self.id_in_group def keep_contributions(self): self.participant.vars['contribution1'] = self.contribution1 self.participant.vars[ 'Cond_contribution_1_0'] = self.Cond_contribution_1_0 self.participant.vars[ 'Cond_contribution_1_2'] = self.Cond_contribution_1_2 self.participant.vars[ 'Cond_contribution_1_4'] = self.Cond_contribution_1_4 self.participant.vars[ 'Cond_contribution_1_6'] = self.Cond_contribution_1_6 self.participant.vars[ 'Cond_contribution_1_8'] = self.Cond_contribution_1_8 self.participant.vars[ 'Cond_contribution_1_10'] = self.Cond_contribution_1_10 self.participant.vars[ 'Cond_contribution_1_12'] = self.Cond_contribution_1_12 self.participant.vars[ 'Cond_contribution_1_14'] = self.Cond_contribution_1_14 self.participant.vars[ 'Cond_contribution_1_16'] = self.Cond_contribution_1_16 self.participant.vars[ 'Cond_contribution_1_18'] = self.Cond_contribution_1_18 self.participant.vars[ 'Cond_contribution_1_20'] = self.Cond_contribution_1_20 self.participant.vars['contribution2'] = self.contribution2 self.participant.vars[ 'Cond_contribution_2_0'] = self.Cond_contribution_2_0 self.participant.vars[ 'Cond_contribution_2_2'] = self.Cond_contribution_2_2 self.participant.vars[ 'Cond_contribution_2_4'] = self.Cond_contribution_2_4 self.participant.vars[ 'Cond_contribution_2_6'] = self.Cond_contribution_2_6 self.participant.vars[ 'Cond_contribution_2_8'] = self.Cond_contribution_2_8 self.participant.vars[ 'Cond_contribution_2_10'] = self.Cond_contribution_2_10 self.participant.vars[ 'Cond_contribution_2_12'] = self.Cond_contribution_2_12 self.participant.vars[ 'Cond_contribution_2_14'] = self.Cond_contribution_2_14 self.participant.vars[ 'Cond_contribution_2_16'] = self.Cond_contribution_2_16 self.participant.vars[ 'Cond_contribution_2_18'] = self.Cond_contribution_2_18 self.participant.vars[ 'Cond_contribution_2_20'] = self.Cond_contribution_2_20 self.participant.vars['contribution3'] = self.contribution3 self.participant.vars[ 'Cond_contribution_3_0'] = self.Cond_contribution_3_0 self.participant.vars[ 'Cond_contribution_3_2'] = self.Cond_contribution_3_2 self.participant.vars[ 'Cond_contribution_3_4'] = self.Cond_contribution_3_4 self.participant.vars[ 'Cond_contribution_3_6'] = self.Cond_contribution_3_6 self.participant.vars[ 'Cond_contribution_3_8'] = self.Cond_contribution_3_8 self.participant.vars[ 'Cond_contribution_3_10'] = self.Cond_contribution_3_10 self.participant.vars[ 'Cond_contribution_3_12'] = self.Cond_contribution_3_12 self.participant.vars[ 'Cond_contribution_3_14'] = self.Cond_contribution_3_14 self.participant.vars[ 'Cond_contribution_3_16'] = self.Cond_contribution_3_16 self.participant.vars[ 'Cond_contribution_3_18'] = self.Cond_contribution_3_18 self.participant.vars[ 'Cond_contribution_3_20'] = self.Cond_contribution_3_20 self.participant.vars['contribution4'] = self.contribution4 self.participant.vars[ 'Cond_contribution_4_0'] = self.Cond_contribution_4_0 self.participant.vars[ 'Cond_contribution_4_2'] = self.Cond_contribution_4_2 self.participant.vars[ 'Cond_contribution_4_4'] = self.Cond_contribution_4_4 self.participant.vars[ 'Cond_contribution_4_6'] = self.Cond_contribution_4_6 self.participant.vars[ 'Cond_contribution_4_8'] = self.Cond_contribution_4_8 self.participant.vars[ 'Cond_contribution_4_10'] = self.Cond_contribution_4_10 self.participant.vars[ 'Cond_contribution_4_12'] = self.Cond_contribution_4_12 self.participant.vars[ 'Cond_contribution_4_14'] = self.Cond_contribution_4_14 self.participant.vars[ 'Cond_contribution_4_16'] = self.Cond_contribution_4_16 self.participant.vars[ 'Cond_contribution_4_18'] = self.Cond_contribution_4_18 self.participant.vars[ 'Cond_contribution_4_20'] = self.Cond_contribution_4_20 self.participant.vars['contribution5'] = self.contribution5 self.participant.vars[ 'Cond_contribution_5_0'] = self.Cond_contribution_5_0 self.participant.vars[ 'Cond_contribution_5_2'] = self.Cond_contribution_5_2 self.participant.vars[ 'Cond_contribution_5_4'] = self.Cond_contribution_5_4 self.participant.vars[ 'Cond_contribution_5_6'] = self.Cond_contribution_5_6 self.participant.vars[ 'Cond_contribution_5_8'] = self.Cond_contribution_5_8 self.participant.vars[ 'Cond_contribution_5_10'] = self.Cond_contribution_5_10 self.participant.vars[ 'Cond_contribution_5_12'] = self.Cond_contribution_5_12 self.participant.vars[ 'Cond_contribution_5_14'] = self.Cond_contribution_5_14 self.participant.vars[ 'Cond_contribution_5_16'] = self.Cond_contribution_5_16 self.participant.vars[ 'Cond_contribution_5_18'] = self.Cond_contribution_5_18 self.participant.vars[ 'Cond_contribution_5_20'] = self.Cond_contribution_5_20 self.participant.vars['contribution6'] = self.contribution6 self.participant.vars[ 'Cond_contribution_6_0'] = self.Cond_contribution_6_0 self.participant.vars[ 'Cond_contribution_6_2'] = self.Cond_contribution_6_2 self.participant.vars[ 'Cond_contribution_6_4'] = self.Cond_contribution_6_4 self.participant.vars[ 'Cond_contribution_6_6'] = self.Cond_contribution_6_6 self.participant.vars[ 'Cond_contribution_6_8'] = self.Cond_contribution_6_8 self.participant.vars[ 'Cond_contribution_6_10'] = self.Cond_contribution_6_10 self.participant.vars[ 'Cond_contribution_6_12'] = self.Cond_contribution_6_12 self.participant.vars[ 'Cond_contribution_6_14'] = self.Cond_contribution_6_14 self.participant.vars[ 'Cond_contribution_6_16'] = self.Cond_contribution_6_16 self.participant.vars[ 'Cond_contribution_6_18'] = self.Cond_contribution_6_18 self.participant.vars[ 'Cond_contribution_6_20'] = self.Cond_contribution_6_20 def role(self): if self.participant.id_in_session % 2 == 0: return 'primed' else: return 'unprimed' def chosen_one_selector(self): if self.id_in_group == 1: self.chosen_one = True else: self.chosen_one = False def record_number(self): self.participant.vars['thefirstone'] = [ self.session.config['app_sequence'].index('criminal_VCM') ]
class Player(BasePlayer): initial_choices = models.StringField( ) # records all button clicks on the two initial options of a participant initial_decision = models.StringField() # final initial decision initial_expectation1 = models.IntegerField(widget=widgets.RadioSelect, choices=[1, 2, 3, 4, 5, 6, 7]) initial_expectation2 = models.IntegerField(widget=widgets.RadioSelect, choices=[1, 2, 3, 4, 5, 6, 7]) sub_decision = models.IntegerField( label="", min=0, max=100, widget=widgets.Slider( attrs={'step': '1'}, show_value=True)) # from 0 (termination) to 100 (continuation) slider_inputs = models.StringField( ) #store all slider inputs after mouse-release #quiz page quiz1 = quiz("Im Unternehmen Kitchen World bin ich ...", [[ 1, "der entscheidungsverantwortliche Manager der Abteilung „Projekte“" ], [2, "der Controller der Abteilung „Operatives“" ], [3, "der Leiter der Marketingabteilung"]]) quiz2 = quiz( "Meine Aufgabe ist es zunächst ...", [[1, "zwei Innovationsprojekte auszuwählen"], [2, "eine neue Produktidee zu entwickeln"], [3, "eins von zwei potentiellen Innovationsprojekten auszuwählen"]]) quiz3a = quiz( "Was ist der Geschäftsführung von Kitchen World besonders wichtig?", [[ 1, "Die neue Geschäftsführung möchte überhaupt nichts an der bisherigen strategischen Ausrichtung von Kitchen World ändern" ], [ 2, "Die Geschäftsführung legt großen Wert darauf, dass Mitarbeiter alles dafür tun, um jegliche Fehler zu verhindern" ], [ 3, "Die Geschäftsführung legt großen Wert darauf, dass Mitarbeiter mögliche Fehlentscheidungen akzeptieren und aus diesen lernen" ]]) quiz3b = quiz( "Was ist der Geschäftsführung von Kitchen World besonders wichtig?", [[ 1, "Die neue Geschäftsführung möchte überhaupt nichts an der bisherigen strategischen Ausrichtung von Kitchen World ändern" ], [ 2, "Die Geschäftsführung legt großen Wert darauf, dass Mitarbeiter alles dafür tun, um jegliche Fehler zu verhindern" ], [ 3, "Die Geschäftsführung legt großen Wert darauf, dass Mitarbeiter mögliche Fehlentscheidungen akzeptieren und aus diesen lernen" ]]) quiz4 = models.StringField( label= "Wie hoch ist im folgenden Beispiel das Guthaben auf dem Projektkonto nach Abschluss des Projekts (in Mio. Lira)?" ) quiz5 = models.StringField( label= "Wie hoch ist die variable Vergütung in Lira, wenn das Guthaben des Projektkontos nach Projektabschluss 5 Mio. Lira beträgt?" ) quiz6 = models.StringField(label="Wie viel Euro entsprechen 35.000 Lira?") quiz7 = quiz("Woraus setzt sich Ihre Gesamtvergütung zusammen?", [[ 1, "Fixe Vergütung + Variable Vergütung aus der Hauptaufgabe + Auszahlung aus der Lotterieaufgabe" ], [2, "Fixe Vergütung + Variable Vergütung aus der Hauptaufgabe" ], [3, "Fixe Vergütung + Auszahlung aus der Lotterieaufgabe"]]) quiz8a = quiz( "Wie geht die Geschäftsführung mit Projekten um, die keinen Erfolg erzielen?", [[ 1, "Die Geschäftsführung deutet solche Projektergebnisse als Anzeichen von Inkompetenz, die sich entsprechend negativ auf die jährliche Leistungsbewertung auswirken können" ], [ 2, "Solange Projekte, die keinen Erfolg erzielen, als Lernmöglichkeit genutzt werden, haben diese keinen Einfluss auf die jährliche Leistungsbewertung" ], [ 3, "Es gibt keine Informationen darüber, wie die Geschäfsführung zu Misserfolgen steht" ]]) quiz8b = quiz( "Wie geht die Geschäftsführung mit Projekten um, die keinen Erfolg erzielen?", [[ 3, "Die Geschäftsführung deutet solche Projektergebnisse als Anzeichen von Inkompetenz, die sich entsprechend negativ auf die jährliche Leistungsbewertung auswirken können" ], [ 2, "Solange Projekte, die keinen Erfolg erzielen, als Lernmöglichkeit genutzt werden, haben diese keinen Einfluss auf die jährliche Leistungsbewertung" ], [ 3, "Es gibt keine Informationen darüber, wie die Geschäfsführung zu Projekten steht, die keine Erfolge erzielen" ]]) quiz_totalwronganswers = models.IntegerField( initial=0 ) #increases, as long as atleast one answers is incorrect when page is submitted quiz1_answers = models.StringField( initial="FirstTry" ) #records all incorrect answers after FirstTry in an array (--> stringfield). stays FirstTry, if first answers chosen is the correct one quiz2_answers = models.StringField(initial="FirstTry") quiz3_answers = models.StringField( initial="FirstTry") #if Subsession.culture == "streng" quiz4_answers = models.StringField(initial="FirstTry") quiz5_answers = models.StringField(initial="FirstTry") quiz6_answers = models.StringField(initial="FirstTry") quiz7_answers = models.StringField(initial="FirstTry") quiz8_answers = models.StringField(initial="FirstTry") #timers timer_instructions = models.StringField() timer_quiz = models.StringField( ) # has to be a stringfield, since multiple attempts are possible which have to be stored in an array. intfields cant easily store arrays timer_initialdecision = models.StringField() timer_subinfo = models.StringField() timer_DA1 = models.IntegerField() timer_DA2 = models.IntegerField() timer_subdecision = models.StringField() starttime = models.StringField( ) #get time of participant when welcome page is loaded endtime = models.StringField( ) #get time of participant when last page is loaded def get_time(self, start_or_end): if start_or_end == "start": self.starttime = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M:%S") else: self.endtime = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M:%S") timespent = models.StringField( ) #get time of participant when last page is loaded def time_spent(self): duration = datetime.datetime.strptime( self.endtime, "%d/%m/%Y %H:%M:%S") - datetime.datetime.strptime( self.starttime, "%d/%m/%Y %H:%M:%S") self.timespent = f"{duration.total_seconds():.0f}sec; {float(duration.total_seconds() / 60):.2f}min" ip_address = models.StringField() browser = models.StringField()
class Player(BasePlayer): random_number = models.IntegerField( doc= "Turns either 1 or 2 (see subsession) and is used to randomly assign roles in the experiment (see def role)." ) compensation = models.CharField( doc="Compensation scheme put in place for agents (see Settings).") participation_fee = models.CurrencyField( doc="Participation fee for all agents (can be modified in Settings).") def role(self): return "Principal" if self.id_in_group == self.random_number else "Agent" # Everyone takes the investment decision for their principal: decision_for_p1 = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset.") investment = models.CurrencyField( doc= "Indicates for everyone the investment decision as taken by their agents." ) def get_investment(self): agent = self.get_others_in_group()[0] self.investment = agent.decision_for_p1 # Payoffs: def calculate_payoffs_principals(self): if self.role() == "Principal": if self.group.investment_success: self.payoff = self.investment * 3.5 + ( Constants.endowment_principals - self.investment) self.profit = self.investment * 2.5 else: self.payoff = Constants.endowment_principals - self.investment self.profit = 0 profit = models.CurrencyField(doc="Gives the profit of the principal.") payoff_of_principal = models.CurrencyField( doc="Gives for each agent the payoff of his principal.") profit_of_principal = models.CurrencyField( doc="Gives for each agent the payoff of his principal.") def get_payoff_profit(self): principal = self.get_others_in_group()[0] self.profit_of_principal = principal.profit self.payoff_of_principal = principal.payoff def calculate_payoffs_agents(self): if self.role() == "Agent": if self.compensation == "fixed": self.payoff = Constants.fixed_payment if self.compensation == "variable_result": self.payoff = Constants.fixed_payment + Constants.share_result / 100 * self.payoff_of_principal if self.compensation == "variable_profit": self.payoff = Constants.fixed_payment + Constants.share_profit / 100 * self.profit_of_principal # Comprehension Questions (Instructions 1) question_1 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) question_2 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) # Comprehension questions instructions 2 question_3 = models.CurrencyField() question_4 = models.CurrencyField() # comprehension question instructions 3 question_6 = models.CharField(widget=widgets.RadioSelectHorizontal(), choices=["Richtig", "Falsch"]) # Questionnaire: age = models.PositiveIntegerField( max=100, verbose_name="Wie alt sind Sie?", doc="We ask participants for their age between 0 and 100 years") gender = models.CharField(choices=["männlich", "weiblich", "anderes"], widget=widgets.RadioSelectHorizontal(), verbose_name="Was ist Ihr Geschlecht?", doc="gender indication") studies = models.CharField(blank=True, verbose_name="Was studieren Sie im Hauptfach?", doc="field of studies indication.") nonstudent = models.BooleanField( widget=widgets.CheckboxInput(), verbose_name="Kein Student", doc="Ticking the checkbox means that the participant is a non-student." ) financial_advice = models.BooleanField( choices=[(True, "Ja"), (False, "Nein")], widget=widgets.RadioSelectHorizontal(), verbose_name= "Haben Sie bereits eine Bankberatung in Anspruch genommen?", doc="We ask participants if they ever made use of financial advice.") income = models.CurrencyField( verbose_name="Wie viel Geld im Monat steht Ihnen frei zur Verfügung?", doc= "We ask participants how much money they have freely available each month." ) # empathy questions em1 = make_empathy_question( "Ich erkenne leicht, ob jemand ein Gespräch anfangen möchte.") em2 = make_empathy_question( "Ich bemerke leicht, wenn jemand etwas anderes sagt, als er meint.") em3 = make_empathy_question( "Es fällt mir leicht mich in einen anderen Menschen hineinzuversetzen." ) em4 = make_empathy_question( "Ich kann gut vorhersagen, wie jemand sich fühlen wird.") em5 = make_empathy_question( "Ich bemerke schnell, wenn jemand sich unbehaglich oder unwohl in einer Gruppe fühlt." ) em6 = make_empathy_question( "Andere Leute bestätigen, dass ich gut nachempfinden kann, was andere denken oder fühlen." ) em7 = make_empathy_question( "Ich erkenne leicht, ob jemand das, was ich erzähle, interessant oder langweilig findet." ) em8 = make_empathy_question( "Freunde erzählen mir normalerweise von ihren Problemen, weil sie mich für besonders verständnisvoll halten." ) em9 = make_empathy_question( "Ich bemerke, wenn ich störe, auch wenn die andere Person es nicht sagt." ) em10 = make_empathy_question( "Ich kann mich schnell und intuitiv darauf einstellen, wie eine andere Person sich fühlt." ) em11 = make_empathy_question( "Es fällt mir leicht herauszufinden, worüber mein Gesprächspartner sich gerne unterhalten möchte." ) em12 = make_empathy_question( "Ich erkenne, ob jemand seine wahren Gefühle verbirgt.") em13 = make_empathy_question( "Ich kann gut vorhersagen, was jemand tun wird.") em_score = models.IntegerField() def score_empathy(self): # transformation is as follows: # 1 and 2 become 0, # 3 becomes 1, # 4 becomes 2 # that is: substract 2, then check if value is negative. if so, set to 0 instead. # these are then summed up raw_scores = [ self.em1, self.em2, self.em3, self.em4, self.em5, self.em6, self.em7, self.em8, self.em9, self.em10, self.em11, self.em12, self.em13 ] transformed_scores = [] for score in raw_scores: transformed = score - 2 transformed = 0 if transformed < 0 else transformed transformed_scores.append(transformed) self.em_score = sum(transformed_scores) # Dummies für Stata: female = models.BooleanField( doc="Turns True if the participant is a woman.") male = models.BooleanField(doc="Turns True if the participant is a man.") other_gender = models.BooleanField( doc="Turns True if the participant indicates other.") econ_student = models.BooleanField( doc="Turns True if the participant is an economics student.") def create_gender_dummies(self): if self.gender == "weiblich": self.female = True self.male = False self.other_gender = False elif self.gender == "männlich": self.female = False self.male = True self.other_gender = False elif self.gender == "anderes": self.female = False self.male = False self.other_gender = True def create_econ_dummy(self): if self.studies: subject = self.studies.lower() if "econ" in subject: self.econ_student = True elif "vwl" in subject: self.econ_student = True elif "ökono" in subject: self.econ_student = True else: self.econ_student = False else: self.econ_student = False
class Player(BasePlayer): ### Public Good Variables germanplayerlabel = models.StringField(doc="See player label.") playerlabel = models.CharField( doc='The player name. Player A - Player E', choices=['Player A', 'Player B', 'Player C', 'Player D', 'Player E']) contribution = models.IntegerField( doc='The players contribution in the public good game in Taler', verbose_name='Ihr Betrag', min=0, max=Constants.endowment) plays = models.BooleanField( doc= 'Determines if the player is allowed to play the guessing game in a particular round.', default=True) #TODO: this app is entirely 'only' treatment. But keep this s. t. there is an indicator in the database treatment = models.CharField( doc= 'Defines the treatment of the session. The treatment is the same for all players in one session' ) round_payoff = models.IntegerField( initial=0, doc="The amount of Taler of the player in a particular round.") #### Breakpoint in Transission round breakpoint = models.IntegerField(blank=False, doc='Breakpoint', verbose_name="") ###################################################################################################################### ### Control Variables ##how often did the participant try to submit the control questions when some answers were still wrong # if the participant was correct on the first try, than this will be 1 control_tries = models.IntegerField( initial=0, doc= "How often did the player try to submit the control questions page when answers were still wrong. \ 1 if the player had everything correct on the first try." ) # only + nosanction + exlude + dislike + punish control1 = models.IntegerField( verbose_name= "Wie viele Taler haben Sie auf Ihrem privaten Konto, wenn Sie 3 Taler auf das Gruppenkonto einzahlen?", min=0) # only + nosanction + exlude + dislike + punish control2 = models.IntegerField( verbose_name= "20 Taler wurden insgesamt in das Gruppenkonto eingezahlt. Wie viele Taler erhalten Sie am Ende aus dem Gruppenkonto?", min=0) # only + nosanction + exlude + dislike + punish control3a = models.StringField( widget=widgets.RadioSelect(), verbose_name= "Es kann sein, dass verschiedene Gruppenmitglieder unterschiedlich viele Taler aus dem Gruppenkonto erhalten.", choices=["wahr", "falsch"]) # only + nosanction + exlude + dislike + punish control3b = models.StringField( widget=widgets.RadioSelect(), verbose_name= "Am Ende der ersten Stufe einer jeweiligen Runde wissen Sie, wie viel jedes Gruppenmitglied ins Gruppenkonto eingezahlt hat.", choices=["wahr", "falsch"]) # only + nosanction + exlude + dislike + punish control3c = models.StringField( widget=widgets.RadioSelect(), verbose_name= "Sie spielen in jeder Runde in einer neuen Gruppe mit anderen Personen", choices=["wahr", "falsch"]) #################################################################################################################### ### Questionnaire1 q1 = models.IntegerField( verbose_name= "Was denken Sie, wie viele Taler sollte man zum Gruppenkonto beitragen?", min=0, max=10) q2 = models.StringField( widget=widgets.RadioSelect(), verbose_name="Denken Sie, die meisten anderen sehen das auch wie Sie?", choices=[ "Ja", "Ich bin mir unsicher", "Nein, die meisten anderen denken man sollte mehr beitragen", "Nein, die meisten anderen denken man sollte weniger beitragen", ]) #################################################################################################################### ### Questionnaire2 q5 = models.IntegerField(verbose_name="Bitte geben Sie Ihr Alter an", min=0, max=99) q7 = models.StringField(verbose_name="Bitte geben Sie Ihr Studienfach an") q8 = models.IntegerField( min=0, verbose_name= "Wie oft haben Sie bereits an einer ökonomischen Laborstudie teilgenommen (auch außerhalb dieses Labors)?" ) q9 = models.StringField( verbose_name= "Wie viele Teilnehmerinnen oder Teilnehmer in diesem Raum haben Sie schon vor dem Experiment gekannt?" ) q10 = models.StringField( verbose_name= "Möchten Sie uns noch etwas mitteilen? Hier ist die Gelegenheit dazu!", blank=True) #################################################################################################################### payround = models.IntegerField( doc= "The round number that will be payed out for the player. Note: this is an oTree round e. g. experiment_round+1." ) #################################################################################################################### ### FamilyFeud # does the player play the bonus FF round after all rounds of the experiment according to the evaluation mechanism # depends on the valuationFF results plays_bonusFF = models.BooleanField( initial=True, doc= "This determines if the player plays the bonus guessing game round at the end of the experiment. \ This is true if the players willingness to pay (ff_valuation) is higher than the computer (number random_ff_valuation)" ) plays = models.BooleanField( doc= 'Determines if the player is allowed to play the guessing game in a particular round.', default=True) # the willingness to pay for the bonus family feud round ff_valuation = models.DecimalField( verbose_name= "Bitte klicken Sie auf die Skala, um Ihre Zahlungsbereitschaft auszuwählen.", widget=widgets.Slider(show_value=False), min=0, max=6, decimal_places=1, max_digits=2, doc= "The players' willingness to pay for the bonus round of the guessing game.", initial=0) random_ff_valuation = models.FloatField( doc= "The computer number which will be to compared with ff_valuation to determine if the player plays the bonus round.", initial=0.0) # Number of correctly answered questions ff_points = models.IntegerField( initial=0, doc= "The number of correct answers which the player found overall in the guessing game in one round." ) # Number of tries (guesses) of a player num_guesses = models.IntegerField(initial=0) def inc_num_guesses(self): self.num_guesses += 1 self.save() def inc_ff_points(self): self.ff_points += 1 self.save() def initial_decision(self): return 0.5
class Player(BasePlayer): quiz1 = models.IntegerField( widget=widgets.RadioSelect, choices=[ [1, 'True'], [2, 'False'] ], label='Question 1: If you accept a plea bargain you are not contesting your guilt (in other words you are not claiming ' 'innocence)' ) quiz2 = models.IntegerField( widget=widgets.RadioSelect, choices=[ [1, 'True'], [2, 'False'] ], label='Question 2: If you accept a plea bargain or are found guilty at the experimental trial, then the monetary penalty ' 'will reduce your experimental payment today.' ) quiz3 = models.IntegerField( widget=widgets.RadioSelect, choices=[ [1, 'The prosecutor has to present the evidence of guilt you see in the plea bargain trial threat'], [2, 'You have to present your evidence of innocence'], [3, 'There is no monetary penalty if you are found guilty'] ], label='Question 3: At trial, which of the following is true?' ) plea_decision2 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $0.40 and $0.60 ' '(a Small Crime) you will' ) plea_decision3 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $0.60 and $0.80 ' '(a Medium Crime) you will' ) plea_decision4 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $0.90 and $1.10 ' '(a Medium Crime) you will' ) plea_decision5 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $1.10 and $1.30 ' '(a Large Crime) you will' ) plea_decision6 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $1.40 and $1.60 ' '(a Large Crime) you will' ) trial_decision1 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $0.10 and $0.30 ' '(a Small Crime) you will' ) trial_decision2 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $0.40 and $0.60 ' '(a Small Crime) you will' ) trial_decision3 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $0.60 and $0.80 ' '(a Medium Crime) you will' ) trial_decision4 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $0.90 and $1.10 ' '(a Medium Crime) you will' ) trial_decision5 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $1.10 and $1.30 ' '(a Large Crime) you will' ) trial_decision6 = models.IntegerField( widget=widgets.RadioSelect, label='If the monetary penalty for being found guilty at trial is between $1.40 and $1.60 ' '(a Large Crime) you will' ) belief = models.IntegerField( min=0, max=100, widget=widgets.Slider(attrs={'size': 100}), label='' ) alt_innocence_level = models.IntegerField() alt_guilt_level = models.IntegerField() alt_pun_level_1 = models.FloatField() alt_pun_level_2 = models.FloatField() alt_pun_level_3 = models.FloatField() ending_guilt = models.BooleanField() ending_guilt_level = models.IntegerField() ending_punishment = models.CurrencyField() ending_trial_status = models.BooleanField() relevant_decision = models.IntegerField() innocence_level = models.IntegerField() guilt_level = models.IntegerField() plea_punishment = models.FloatField() no_plea_punishment = models.FloatField() crime_level = models.IntegerField() pros_choice = models.IntegerField() plea_threat = models.IntegerField() innocence_level_this_round = models.IntegerField() guilt_level_this_round = models.IntegerField() plea_punishment_this_round = models.FloatField() what_round = models.IntegerField() payoffmodule3 = models.CurrencyField() trialcrime = models.IntegerField() defenseevid = models.IntegerField() prosevid = models.IntegerField() # Trial status: # True - went to trial # False - took plea def set_payoff(self): # WE RECORD DECISIONS ONLY WHEN THE INNOCENCE LEVEL, GUILT LEVEL, AND PLEA MATCH THOSE SEEN BY A JURY OR PLEA # OFFERED BY A PROSECUTOR self.innocence_level = self.participant.vars['innocencelevel'].item() self.guilt_level = self.participant.vars['guiltlevel'].item() self.crime_level = self.participant.vars['crimelevel'] self.pros_choice = self.participant.vars['proschoice'] self.plea_punishment = self.participant.vars['pleapunishment'] self.no_plea_punishment = self.participant.vars['nopleapun'] self.plea_threat = self.participant.vars['pleathreat'] self.innocence_level_this_round = self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][0] self.guilt_level_this_round = self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][1] self.plea_punishment_this_round = self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][2] self.what_round = self.participant.vars['whatround'] if self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][0] == self.participant.vars['innocencelevel'].item() and \ self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][1] == self.participant.vars['guiltlevel'].item() and \ self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][2] == self.participant.vars['pleapunishment']: # FIRST WE LOOK AT WHEN THE PROSECUTOR DECIDES TO MAKE A PLEA OFFER if self.participant.vars['proschoice'] == 3: # NOW WE RESTRICT OUR ATTENTION TO WHICH PLEA THREAT WAS MADE if self.participant.vars['pleathreat'] == 1: # WE RECORD THE DEFENDANT'S DECISION self.participant.vars['relevantdecision'] = self.plea_decision2 if self.participant.vars['pleathreat'] == 2: self.participant.vars['relevantdecision'] = self.plea_decision3 if self.participant.vars['pleathreat'] == 3: self.participant.vars['relevantdecision'] = self.plea_decision4 if self.participant.vars['pleathreat'] == 4: self.participant.vars['relevantdecision'] = self.plea_decision5 if self.participant.vars['pleathreat'] == 5: self.participant.vars['relevantdecision'] = self.plea_decision6 # IF THE DEFENDANT TAKES THE PLEA DEAL, INDICATED BY A 1, THEN WE SET THEIR PAYOFF FOR THIS MODULE # TO THE PROPOSED PUNISHMENT AMOUNT if self.participant.vars['relevantdecision'] == 1: self.ending_guilt = True self.ending_guilt_level = self.participant.vars['pleacrimelevel'] self.ending_punishment = self.participant.vars['pleapunishment'] self.ending_trial_status = False self.payoff = -self.participant.vars['pleapunishment'] self.relevant_decision = self.participant.vars['relevantdecision'] # IF THE DEFENDANT GOES TO TRIAL WITH THEIR INNOCENCE LEVEL PROVIDED, INDICATED BY A 2, THEN WE # GATHER THE THE THREATENED CRIME LEVEL (FROM PROSECUTOR), THREATENED EVIDENCE LEVEL (FROM # PROSECUTOR), AND THE INNOCENCE LEVEL (FROM DEFENDANT) AND FIND THE APPROPRIATE ROW IN THE JURY # DECISION TABLE, AND SIMULATE A TRIAL. if self.participant.vars['relevantdecision'] == 2: self.ending_trial_status = True if self.participant.vars['pleathreat'] == 1: trialcrime = 1 trialdefevid = self.participant.vars['innocencelevel'].item() trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 2: trialcrime = 2 trialdefevid = self.participant.vars['innocencelevel'].item() trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 3: trialcrime = 2 trialdefevid = self.participant.vars['innocencelevel'].item() trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 4: trialcrime = 3 trialdefevid = self.participant.vars['innocencelevel'].item() trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 5: trialcrime = 3 trialdefevid = self.participant.vars['innocencelevel'].item() trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] # HERE WE ACTUALLY SIMULATE THE GUILTY/NOT GUILTY FINDING FROM THE JURY TABLE self.trialcrime = trialcrime self.defenseevid = trialdefevid if trialdefevid == 1: trialdefevid = 0 else: if trialdefevid == 2: trialdefevid = 1 else: if trialdefevid == 3: trialdefevid = 2 else: if trialdefevid == 4: trialdefevid = 3 self.prosevid = trialprosevid self.participant.vars['jurydecision'] = np.random.binomial(1, (self.session.vars['juryprobs'].loc[(self.session.vars['juryprobs']['Crime'] == trialcrime) & (self.session.vars['juryprobs']['Defense evidence'] == trialdefevid) & (self.session.vars['juryprobs']['Prosecutor evidence'] == trialprosevid), 'Probability of a guilty findng at trial'].item())) # IF JURY DECIDES NOT GUILTY, INDICATED BY A 0, THEN NO PUNISHMENT if self.participant.vars['jurydecision'] == 0: self.payoff = 0 self.ending_guilt = False self.ending_guilt_level = 0 self.ending_punishment = 0 self.relevant_decision = self.participant.vars['relevantdecision'] # IF JURY DECIDES GUILTY, THEN WE LOOK AT THE RELEVANT THREAT LEVEL AND GENERATE A PUNISHMENT else: self.ending_guilt = True if self.participant.vars['pleathreat'] == 1: self.ending_punishment = np.random.choice([.1, .2, .3]) self.ending_guilt_level = 1 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 2: self.ending_punishment = np.random.choice([.4, .5, .6]) self.ending_guilt_level = 1 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 3: self.ending_punishment = np.random.choice([.6, .7, .8]) self.ending_guilt_level = 2 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 4: self.ending_punishment = np.random.choice([.9, 1, 1.1]) self.ending_guilt_level = 2 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 5: self.ending_punishment = np.random.choice([1.1, 1.2, 1.3]) self.ending_guilt_level = 3 self.relevant_decision = self.participant.vars['relevantdecision'] # WE DO SOMETHING VERY SIMILAR FOR WHEN THE DEFENDANT DECIDES TO PLEA THE FIFTH, INDICATED BY A 3 if self.participant.vars['relevantdecision'] == 3: self.ending_trial_status = True if self.participant.vars['pleathreat'] == 1: trialcrime = 1 trialdefevid = 0 trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 2: trialcrime = 2 trialdefevid = 0 trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 3: trialcrime = 2 trialdefevid = 0 trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 4: trialcrime = 3 trialdefevid = 0 trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 5: trialcrime = 3 trialdefevid = 0 trialprosevid = self.participant.vars['pleaevidence'] self.relevant_decision = self.participant.vars['relevantdecision'] self.trialcrime = trialcrime self.defenseevid = trialdefevid if trialdefevid == 1: trialdefevid = 0 else: if trialdefevid == 2: trialdefevid = 1 else: if trialdefevid == 3: trialdefevid = 2 else: if trialdefevid == 4: trialdefevid = 3 self.prosevid = trialprosevid self.participant.vars['jurydecision'] = np.random.binomial(1, (self.session.vars['juryprobs'].loc[(self.session.vars['juryprobs']['Crime'] == trialcrime) & (self.session.vars['juryprobs']['Defense evidence'] == trialdefevid) & (self.session.vars['juryprobs']['Prosecutor evidence'] == trialprosevid), 'Probability of a guilty findng at trial'].item())) if self.participant.vars['jurydecision'] == 0: self.payoff = 0 self.ending_guilt = False self.ending_guilt_level = 0 self.ending_punishment = 0 self.relevant_decision = self.participant.vars['relevantdecision'] else: self.ending_guilt = True if self.participant.vars['pleathreat'] == 1: self.ending_punishment = np.random.choice([.1, .2, .3]) self.ending_guilt_level = 1 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 2: self.ending_punishment = np.random.choice([.4, .5, .6]) self.ending_guilt_level = 1 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 3: self.ending_punishment = np.random.choice([.6, .7, .8]) self.ending_guilt_level = 2 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 4: self.ending_punishment = np.random.choice([.9, 1, 1.1]) self.ending_guilt_level = 2 self.relevant_decision = self.participant.vars['relevantdecision'] if self.participant.vars['pleathreat'] == 5: self.ending_punishment = np.random.choice([1.1, 1.2, 1.3]) self.ending_guilt_level = 3 self.relevant_decision = self.participant.vars['relevantdecision'] # NEXT WE CONSIDER WHEN THEIR IS NO PLEA OFFER AND THE PROSECUTOR GOES STRAIGHT TO TRIAL. THIS IS ALL VERY # SIMILAR TO WHAT IS DONE ABOVE WHEN THE DEFENDANT WANTS TO GO TO TRIAL AGAINST A THREAT if self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][0] == self.participant.vars['innocencelevel'].item() and \ self.participant.vars['allpossibleinfo'][self.subsession.round_number - 1][1] == self.participant.vars['guiltlevel'].item() and \ self.subsession.round_number % 3 == 0: if self.participant.vars['proschoice'] == 2: self.ending_trial_status = True if self.participant.vars['nopleapun'] == 0: self.participant.vars['relevantdecision'] = self.trial_decision1 self.relevant_decision = self.participant.vars['relevantdecision'] trialcrime = 1 if self.participant.vars['relevantdecision'] == 1: trialdefevid = self.participant.vars['innocencelevel'].item() else: trialdefevid = 0 trialprosevid = self.participant.vars['nopleaevidence'] if self.participant.vars['nopleapun'] == 1: self.participant.vars['relevantdecision'] = self.trial_decision2 self.relevant_decision = self.participant.vars['relevantdecision'] trialcrime = 1 if self.participant.vars['relevantdecision'] == 1: trialdefevid = self.participant.vars['innocencelevel'].item() else: trialdefevid = 0 trialprosevid = self.participant.vars['nopleaevidence'] if self.participant.vars['nopleapun'] == 2: self.participant.vars['relevantdecision'] = self.trial_decision3 self.relevant_decision = self.participant.vars['relevantdecision'] trialcrime = 2 if self.participant.vars['relevantdecision'] == 1: trialdefevid = self.participant.vars['innocencelevel'].item() else: trialdefevid = 0 trialprosevid = self.participant.vars['nopleaevidence'] if self.participant.vars['nopleapun'] == 3: self.participant.vars['relevantdecision'] = self.trial_decision4 self.relevant_decision = self.participant.vars['relevantdecision'] trialcrime = 2 if self.participant.vars['relevantdecision'] == 1: trialdefevid = self.participant.vars['innocencelevel'].item() else: trialdefevid = 0 trialprosevid = self.participant.vars['nopleaevidence'] if self.participant.vars['nopleapun'] == 4: self.participant.vars['relevantdecision'] = self.trial_decision5 self.relevant_decision = self.participant.vars['relevantdecision'] trialcrime = 3 if self.participant.vars['relevantdecision'] == 1: trialdefevid = self.participant.vars['innocencelevel'].item() else: trialdefevid = 0 trialprosevid = self.participant.vars['nopleaevidence'] if self.participant.vars['nopleapun'] == 5: self.participant.vars['relevantdecision'] = self.trial_decision6 self.relevant_decision = self.participant.vars['relevantdecision'] trialcrime = 3 if self.participant.vars['relevantdecision'] == 1: trialdefevid = self.participant.vars['innocencelevel'].item() else: trialdefevid = 0 trialprosevid = self.participant.vars['nopleaevidence'] self.trialcrime = trialcrime self.defenseevid = trialdefevid if trialdefevid == 1: trialdefevid = 0 else: if trialdefevid == 2: trialdefevid = 1 else: if trialdefevid == 3: trialdefevid = 2 else: if trialdefevid == 4: trialdefevid = 3 self.prosevid = trialprosevid self.participant.vars['jurydecision'] = np.random.binomial(1, (self.session.vars['juryprobs'].loc[(self.session.vars['juryprobs']['Crime'] == trialcrime) & (self.session.vars['juryprobs']['Defense evidence'] == trialdefevid) & (self.session.vars['juryprobs']['Prosecutor evidence'] == trialprosevid), 'Probability of a guilty findng at trial'].item())) if self.participant.vars['jurydecision'] == 0: self.payoff = 0 self.ending_guilt = False self.ending_guilt_level = 0 self.ending_punishment = 0 self.relevant_decision = self.participant.vars['relevantdecision'] else: self.ending_guilt = True if self.participant.vars['nopleapun'] == 0: self.ending_punishment = np.random.choice([.1, .2, .3]) self.ending_guilt_level = 1 if self.participant.vars['nopleapun'] == 1: self.ending_punishment = np.random.choice([.4, .5, .6]) self.ending_guilt_level = 1 if self.participant.vars['nopleapun'] == 2: self.ending_punishment = np.random.choice([.6, .7, .8]) self.ending_guilt_level = 2 if self.participant.vars['nopleapun'] == 3: self.ending_punishment = np.random.choice([.9, 1, 1.1]) self.ending_guilt_level = 2 if self.participant.vars['nopleapun'] == 4: self.ending_punishment = np.random.choice([1.1, 1.2, 1.3]) self.ending_guilt_level = 3 if self.participant.vars['nopleapun'] == 5: self.ending_punishment = np.random.choice([1.4, 1.5, 1.6]) self.ending_guilt_level = 3 if self.participant.vars['proschoice'] == 1: self.ending_trial_status = False self.ending_guilt = False self.payoff = 0 self.ending_guilt_level = 0 self.ending_punishment = 0 self.relevant_decision = 0 # WE MUST ALSO CONSIDER THE CASE WHERE THE PROSECUTOR HAS NO EVIDENCE if self.participant.vars['guiltlevel'].item() == 1: self.ending_trial_status = False self.participant.vars['ending_trial_status'] = self.ending_trial_status self.ending_guilt = False self.participant.vars['ending_guilt'] = self.ending_guilt self.payoff = 0 self.ending_guilt_level = 0 self.participant.vars['ending_guilt_level'] = self.ending_guilt_level self.ending_punishment = 0 self.participant.vars['ending_punishment'] = self.ending_punishment self.participant.vars['relevantdecision'] = None self.relevant_decision = self.participant.vars['relevantdecision'] self.participant.vars['payoffmodule3'] = c(self.ending_punishment) # Record this decision so it can be displayed on final page # self.participant.vars['payoffmodule3'] = c(self.ending_punishment) # For excel checking purposes... if self.subsession.round_number == self.participant.vars['whatround']: self.participant.vars['ending_trial_status'] = self.ending_trial_status self.ending_trial_status = self.ending_trial_status self.participant.vars['ending_guilt'] = self.ending_guilt self.ending_guilt = self.ending_guilt self.payoff = self.payoff self.participant.vars['ending_guilt_level'] = self.ending_guilt_level self.ending_guilt_level = self.ending_guilt_level self.participant.vars['ending_punishment'] = self.ending_punishment self.participant.vars['payoffmodule3'] = c(-self.ending_punishment) self.ending_punishment = self.ending_punishment self.payoffmodule3 = self.participant.vars['ending_punishment'] # THINGS RECORDED: # payoff - the resulting punishment, if anything # ending_guilt_level - what level of crime they were determined to have committed, if any # ending_punishment - same thing as payoff in this module def record_number(self): self.participant.vars['thethirdone'] = [self.session.config['app_sequence'].index('criminal_plea')]
class Player(BasePlayer): # Roles: # gerade Nummern sind Kunden def role(self): if self.id_in_group % 2 == 0: return "Customer" else: return "Agent" def get_agent_decision(self): agent = self.group.get_player_by_id(self.corresponding_agent) self.invested_amount = agent.investment_single def get_principal_category(self): principal = self.group.get_player_by_id(self.corresponding_principal) self.category_received = principal.category def get_principal_outcome(self): principal = self.group.get_player_by_id(self.corresponding_principal) self.outcome_received = principal.investment_outcome def get_principal_message(self): principal = self.group.get_player_by_id(self.corresponding_principal) self.message_received = principal.message def get_principal_payoff(self): principal = self.group.get_player_by_id(self.corresponding_principal) self.payoff_principal = principal.payoff corresponding_agent = models.CharField( doc="Returns the ID of the participants agent.") corresponding_principal = models.CharField( doc="Returns the ID of the participants customer.") # Part II Choosing Category: category = models.CharField( choices=Constants.category_names, widget=widgets.RadioSelect(), verbose_name="Bitte wählen Sie nun einen der fünf Begriffe:", doc= "Principals choose the category which is communicated to their agent") category_received = models.CharField( doc="Category that agents see (from their customers).") # Part II Investment: investment_single = models.CurrencyField( min=0, max=Constants.endowment_principals, widget=widgets.Slider(), # Neuer Slider von Christian verbose_name="Ihre Investitionsentscheidung für Ihren Kunden:", doc="Agents investment for the principal in the risky asset.") invested_amount = models.CurrencyField( doc="What was invested by the corresponding agent.") # Legt fest, ob die Investition erfolgreich war (p=1/3) oder nicht (1-p=2/3): def risky_asset(self): self.random_number = random.randint(1, 3) if self.random_number == 1: self.investment_outcome = "Die Investition war erfolgreich." else: self.investment_outcome = "Die Investition war nicht erfolgreich." investment_outcome = models.CharField( doc= "Tells the customer if the investment was successfull or not successfull." ) outcome_received = models.CharField( doc= "Tells the agent if his investment for his customer was successfull.") def payments_principals(self): if self.id_in_group % 2 == 0: # Für Kunden if self.investment_outcome == "Die Investition war erfolgreich.": self.payoff = self.invested_amount * 3.5 + ( Constants.endowment_principals - self.invested_amount) elif self.investment_outcome == "Die Investition war nicht erfolgreich.": self.payoff = Constants.endowment_principals - self.invested_amount def payments_agents(self): if self.id_in_group % 2 != 0: # Für Berater if self.session.config["compensation"] == "fixed": self.payoff = Constants.fixed_payment if self.session.config["compensation"] == "variable": self.payoff = Constants.variable_payment + Constants.share / 100 * self.payoff_principal payoff = models.CurrencyField() payoff_principal = models.CurrencyField( doc="Payoff of the agent's principal.") # Results: Messages message = models.CharField( choices=[ "Ich bin sehr zufrieden mit Ihrer Entscheidung", "Ich bin zufrieden mit Ihrer Entscheidung", "Ich bin unzufrieden mit Ihrer Entscheidung", "Ich bin sehr unzufrieden mit Ihrer Entscheidung" ], widget=widgets.RadioSelect(), verbose_name= "Wählen Sie dazu eine der vorgefertigten Mitteilungen aus:", doc="Principals choose the message to send to the agents.") message_received = models.CharField( doc="Message that agents receive from their principals.") # compensation = models.CharField( doc="Compensation scheme put in place for agents (see settings).") participation_fee = models.CharField( doc="Participation Fee for all agents.") # Questionnaire: age = models.PositiveIntegerField( max=100, verbose_name="Wie alt sind Sie?", doc="We ask participants for their age between 0 and 100 years") gender = models.CharField(choices=["männlich", "weiblich", "anderes"], widget=widgets.RadioSelect(), verbose_name="Was ist Ihr Geschlecht?", doc="gender indication") studies = models.CharField(blank=True, verbose_name="Was studieren Sie im Hauptfach?", doc="field of studies indication.") studies2 = models.BooleanField( widget=widgets.CheckboxInput(), verbose_name="Kein Student", doc="Ticking the checkbox means that the participant is a non-student." ) financial_advice = models.CharField( choices=["Ja", "Nein"], widget=widgets.RadioSelect(), verbose_name= "Haben Sie bereits eine Bankberatung in Anspruch genommen?", doc="We ask participants if they ever made use of financial advice.") income = models.CurrencyField( verbose_name="Wie viel Geld im Monat steht Ihnen frei zur Verfügung?", doc= "We ask participants how much money they have freely available each month." )
class Player(BasePlayer): transfer_will = models.IntegerField( min=2500, max=5000, initial=0, label=questions.transfer_message, widget=widgets.Slider(), blank=True, ) transfer_will_yn = models.BooleanField( label="이직의사 없음", widget=widgets.CheckboxInput, choices=Constants.BINARY_CHOICES, blank=True, ) transfer_will_alt = models.IntegerField( min=5000, max=10000, initial=0, label=questions.transfer_message_alt, widget=widgets.Slider(), ) transfer_will_alt_yn = models.BooleanField( label="이직의사 없음", widget=widgets.CheckboxInput, choices=Constants.BINARY_CHOICES, blank=True, ) workplace_restriction_1 = models.IntegerField( label="", widget=widgets.RadioSelectHorizontal, choices=Constants.YNU_CHOICES, ) workplace_restriction_2 = models.IntegerField( label="", widget=widgets.RadioSelectHorizontal, choices=Constants.YNU_CHOICES, ) sm1_1 = make_field_sm(1) sm1_2 = make_field_sm(2) sm1_3 = make_field_sm(3) sm1_4 = make_field_sm(4) sm1_5 = make_field_sm(5) sm1_6 = make_field_sm(6) sm1_7 = make_field_sm(7) sm1_8 = make_field_sm(8) sm1_9 = make_field_sm(9) sm_3 = models.IntegerField( label="", widget=widgets.RadioSelect, choices=Constants.sm3_choices, ) cessation_education = models.BooleanField( label= "현재 재직중인 귀하의 사업장에서 작년(2019년) 한해 동안 흡연과 관련된 교육(예: 금연 및 흡연예방 교육, 간접흡연 피해 교육, 금연 프로그램 안내 교육 등)을 받은 적 있으십니까?", widget=widgets.RadioSelectHorizontal, choices=Constants.BINARY_CHOICES, ) cessation_program_1 = models.IntegerField( label="", widget=widgets.RadioSelectHorizontal, choices=Constants.YNU_CHOICES, ) cessation_program_2 = models.IntegerField( label="", widget=widgets.RadioSelectHorizontal, choices=Constants.YNU_CHOICES, ) cessation_program_2_op = models.StringField( label= "귀하의 사업장에서운영중인 금연프로그램에 대해 구체적으로 설명해주십시오. (예: 참가자 기준, 프로그램 내용, 보상 체계, 패널티 체계, 금연성공률 등)", blank=True, ) paid_leave4program = models.IntegerField( label= "귀하는 보건소에서 무료로 제공하고 있는 금연캠프(4박5일) 참가 대상인 흡연 근로자(흡연력 20년 이상)가 금연캠프에 참가하도록 사업주가 유급휴가를 주어야 한다는 의견에 찬성하십니까? 반대하십니까?", widget=widgets.RadioSelectHorizontal, choices=Constants.pros_cons_choices, )