Esempio n. 1
0
class Player(BasePlayer):

    # Within each group, assign all players their colors
    def role(self):
        if self.id_in_group == 1:
            return "red"
        if self.id_in_group == 2:
            return "blue"
        if self.id_in_group == 3:
            return "green"

    my_group_id = models.IntegerField(doc="Assigns each player a group ID")

    # Returns the group_id of each player in round 1
    def return_group_id(self):
        return self.in_round(1).my_group_id

    treatment = models.CharField(doc="Treatment (either public or private)")

    advice = models.CharField(
        choices=["A", "B", "C", "D", "E", "F"],
        doc="Advice which is given to the players (see settings).")

    # below are the fields of the questionnaire
    age = models.PositiveIntegerField(
        max=100,
        verbose_name="How old are you?",
        doc="We ask participants for their age between 0 and 100 years")

    gender = models.CharField(choices=["female", "male", "other"],
                              widget=widgets.RadioSelect(),
                              verbose_name="Please indicate your gender.",
                              doc="gender indication")

    studies = models.CharField(
        blank=True,
        verbose_name="Please indicate your field of studies.",
        doc="field of studies indication.")

    studies2 = models.BooleanField(
        widget=widgets.CheckboxInput(),
        verbose_name="Non-student",
        doc="Ticking the checkbox means that the participant is a non-student."
    )

    risk = models.CharField(
        choices=[
            "highly risk averse", "risk averse", "somewhat risk averse",
            "neutral", "somewhat risk loving", "risk loving",
            "highly risk loving"
        ],
        widget=widgets.RadioSelectHorizontal(),
        verbose_name="Please indicate your risk preference.",
        doc="7 point likert scale to measure risk preference.")

    country = CountryField(
        blank=True, verbose_name="Please indicate your country of birth."
    )  # We ask participants for their country of birth.
Esempio n. 2
0
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."
    )
Esempio n. 3
0
class Player(BasePlayer):

    label = models.CharField(
        doc='The player name. Player A - Player E',
        choices=['Player A', 'Player B', 'Player C', 'Player D', 'Player E'])

    treatment = models.CharField(
        doc=
        'Defines the treatment of the session. The treatment is the same for all players in one session.',
        choices=['inclusion', 'exclusion'])

    city = models.CharField(
        doc='Defines the city where the experiment took place ',
        choices=['heidelberg', 'karlsruhe'])

    cont_first = models.CurrencyField(
        doc=
        'The players contribution in the first public good game of the round.',
        verbose_name='What do you want to contribute to the project?',
        min=0,
        max=Constants.endowment)

    plays_secondpg = models.BooleanField(
        doc=
        'A bool that displays if the player plays in the second public good game.',
        default=True)

    cont_second = models.CurrencyField(
        doc=
        'The players contribution in the second public good game of the round.',
        verbose_name='What do you want to contribute to the project?',
        min=0,
        max=Constants.endowment)

    myvotes_inclusion = models.IntegerField(
        doc=
        'The number of invitations the player got for the second public good game'
    )

    myvotes_exclusion = models.IntegerField(
        doc=
        'The number of negative votes the player got for the second public good game'
    )

    #inclusion treatment
    # these vars have a one if the processing player did invite the player by clicking the invite checkbox in inclusive treatment
    invite_A = models.BooleanField(widget=widgets.CheckboxInput(),
                                   verbose_name='Player A')
    invite_B = models.BooleanField(widget=widgets.CheckboxInput(),
                                   verbose_name='Player B')
    invite_C = models.BooleanField(widget=widgets.CheckboxInput(),
                                   verbose_name='Player C')
    invite_D = models.BooleanField(widget=widgets.CheckboxInput(),
                                   verbose_name='Player D')
    invite_E = models.BooleanField(widget=widgets.CheckboxInput(),
                                   verbose_name='Player E')

    #these vars have a one if the processing player did exclude the player by deselecting the checkbox in exclusive treatments
    #note this variable definition is obtained by invterting the raw variable after the voting occured
    exclude_A = models.BooleanField(
        widget=widgets.CheckboxInput(),
        verbose_name='Player A',
        initial=True,
    )
    exclude_B = models.BooleanField(widget=widgets.CheckboxInput(),
                                    verbose_name='Player B',
                                    initial=True)
    exclude_C = models.BooleanField(widget=widgets.CheckboxInput(),
                                    verbose_name='Player C',
                                    initial=True)
    exclude_D = models.BooleanField(widget=widgets.CheckboxInput(),
                                    verbose_name='Player D',
                                    initial=True)
    exclude_E = models.BooleanField(widget=widgets.CheckboxInput(),
                                    verbose_name='Player E',
                                    initial=True)
Esempio n. 4
0
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
Esempio n. 5
0
class Player(BasePlayer):

    def role(self):
        if self.id_in_group == 1:
            return "A"
        if self.id_in_group == 2:
            return "B"
        if self.id_in_group == 3:
            return "C"
        else:
            return "D"

#punishment choice for C and D
    punishment=models.BooleanField(
        choices=[(True, "Yes"), (False, "No")],
        verbose_name="Do you want to pay 10 points to get 70 punishment points?",
        doc="Boolean Field for decision of C and D whether to buy punishment points."
        ) 

#punishment  

    punishment_A=models.PositiveIntegerField(
        min= 0,
        max= Constants.punishment_max,#
        blank=True,
        verbose_name="How much do you want to punish A?",
        doc= "Punishment A",
        initial=0)
    punishment_B=models.PositiveIntegerField(
        min= 0,
        max= Constants.punishment_max,
        blank=True,
        verbose_name="How much do you want to punish B?",
        doc= "Punishment B",
        initial=0)
    punishment_C=models.PositiveIntegerField(
        min=0,
        max= Constants.punishment_max,
        blank=True,
        verbose_name="How much do you want to punish C?",
        doc= "Punishment C",
        initial=0)
    punishment_D=models.PositiveIntegerField(
        min=0,
        max=Constants.punishment_max,
        blank=True,
        verbose_name="How much do you want to punish D?",
        doc= "Punishment D",
        initial=0)


    #demographics
    age = models.PositiveIntegerField(
        max=120,
        blank=True,
        verbose_name="How old are you?",
        doc="collect age data between 0 and 120"
        )
    gender = models.CharField(
        choices=["Female", "Male"],
        widget=widgets.RadioSelect(),
        blank=True,
        verbose_name="What is your gender?",
        doc="Ask for the gender"
        )
    field_of_studies = models.CharField(
        blank=True,
        verbose_name="What do you study if at all?",
        doc="free text input of field of studies"       
        )
    no_student = models.BooleanField(
        verbose_name="I'm not a student",
        widget=widgets.CheckboxInput(),
        doc="Boolean Field, if player is no student: 1")
    willingness_risk= models.CharField(
        choices=["Strongly disagree", "Disagree", "Moderately Disagree", "Undecided", "Moderately Agree", "Agree", "Strongly Agree"],
        blank=True,
        widget=widgets.RadioSelectHorizontal(),
        verbose_name="My willigness to take risk is high:",
        doc="willigness to take risk input CharField- Likert Scale"
        )
    nationality=models.CharField(
        choices=["Germany", "Italy","France","Spain","Belgium","The Netherlands","UK", "China", "Japan","USA", "other"],
        blank=True,
        verbose_name="What is your country of birth?",
        doc= "input nationality dropdown"
        )
Esempio n. 6
0
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
Esempio n. 7
0
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
Esempio n. 8
0
class Player(BasePlayer):
    order_id = models.IntegerField()
    comment = models.StringField()
    img_id = models.IntegerField()
    comment_subject_id = models.IntegerField()

    q1 = models.StringField(
        initial=None,
        choices=[('1', 'sehr freundlich'), ('2', '2'), ('3', '3'), ('4', '4'),
                 ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'),
                 ('9', 'sehr feindselig'),
                 ('Nicht zu bewerten', 'Nicht zu bewerten')],
        verbose_name=
        'Ist der Kommentar freundlich oder feindselig gegenüber der im Foto dargestellten Gruppe? ',
        widget=widgets.RadioSelectHorizontal())

    against_other = models.StringField(
        initial=None,
        choices=[
            'Nein', 'Ja, er ist zustimmend', 'Ja, er ist ablehnend',
            'Nicht zu bewerten'
        ],
        verbose_name='Richtet sich der Kommentar an einen anderen Nutzer?',
        widget=widgets.RadioSelectHorizontal())
    should_allow = models.StringField(
        initial=None,
        choices=['Nein', 'Ja', 'Ich weiß nicht'],
        verbose_name=
        'Sollte dieser Kommentar in einem Internetforum erlaubt sein?',
        widget=widgets.RadioSelectHorizontal())

    c_1 = models.CharField(widget=widgets.CheckboxInput(),
                           blank=True,
                           verbose_name='Beinhaltet negative Vorurteile')
    c_2 = models.CharField(widget=widgets.CheckboxInput(),
                           blank=True,
                           verbose_name='Nutzt rassistische Beleidigungen')
    c_3 = models.CharField(
        widget=widgets.CheckboxInput(),
        blank=True,
        verbose_name=
        'Beinhaltet  beleidigende, erniedrigende oder abwertende Worte')
    c_4 = models.CharField(
        widget=widgets.CheckboxInput(),
        blank=True,
        verbose_name='Ruft zu Gewalt, Drohungen oder Diskriminierung auf')
    c_5 = models.CharField(widget=widgets.CheckboxInput(),
                           blank=True,
                           verbose_name='Nutzt sexistische Beleidigungen')
    c_6 = models.CharField(
        widget=widgets.CheckboxInput(),
        blank=True,
        verbose_name=
        'Die sexuelle Orientierung oder das Geschlecht/Gender wird  herabgesetzt oder stigmatisiert'
    )

    # For the layout
    ceiling_rounds = models.IntegerField()
    displayed_rounds = models.IntegerField()

    # Control variable
    current_time = models.DateTimeField()

    # treatments
    pop_uncertain = models.BooleanField()
    group_size = models.StringField()

    # If we the person was admitted to the treatments or blocked because we
    # are full
    admit = models.BooleanField()

    # Outcome variable
    volunteer_decision = models.BooleanField()

    def current_question(self):
        return self.participant.vars['comments'][self.round_number - 1]

    def get_time_diff(self):
        time_end = self.in_round(Constants.vod_round).current_time
        start_time = self.participant.vars['time_start']

        time_task = time_end - start_time
        return time_task

    def is_playing(self):
        pass

    def get_additional_constants(self):
        """ A function which returns constants stored in the config for the template"""

        group_key = self.participant.vars['group_size']
        pop_unc = self.participant.vars['pop_uncertain']

        spread = Constants.group_dict[group_key]['spread']
        mean_group_size = Constants.group_dict[group_key]['mean']
        lb_group_size = mean_group_size - spread
        ub_group_size = mean_group_size + spread

        baseline_fee = self.session.config['participation_fee']
        vod_bonus = self.session.config['vod_bonus']
        return {
            'mean_group_size': mean_group_size,
            'ub_group_size': ub_group_size,
            'lb_group_size': lb_group_size,
            'baseline_fee': baseline_fee,
            'vod_bonus': vod_bonus,
            'pop_uncertain': pop_unc
        }

    def assign_treatment(self):
        prob_list, total_missing = self.calc_probs()

        # If there are no spots to fill, set the *admit* variable to false to
        # block the participants
        if total_missing > 0:
            treatments, probs = zip(*prob_list)
            treatments_list = list(treatments)

            # because numpy is weird when drawing from a list of tuples we do
            # it like this:
            random_index = int(np.random.choice(len(treatments), 1, p=probs))
            treatment = treatments[random_index]

            # assign treatment according to random draw
            self.group_size, self.pop_uncertain = treatment

            # Also save in the participant dict
            self.participant.vars['pop_uncertain'] = self.pop_uncertain
            self.participant.vars['group_size'] = self.group_size
            self.admit = True

        else:
            self.session.vars['admit'] = False
            self.admit = False

    def calc_probs(self):
        prob_list = []
        missing_treatments = {}
        total_missing = 0
        for key in Constants.group_dict.keys():
            missing_treatments[key] = {}

            diff_cert = Constants.group_dict[key]['threshold_cert'] - \
                self.session.vars[key]['finished_cert']
            diff_unc = Constants.group_dict[key]['threshold_unc'] - \
                self.session.vars[key]['finished_unc']

            # If players join at the same time a lot it can happen that
            # threshold_cert< finished_cert
            if diff_cert < 0:
                missing_treatments[key]['cert'] = 0
            else:
                missing_treatments[key]['cert'] = diff_cert

            if diff_unc < 0:
                missing_treatments[key]['unc'] = 0
            else:
                missing_treatments[key]['unc'] = diff_unc
            total_missing = missing_treatments[key]['cert'] + \
                missing_treatments[key]['unc'] + total_missing

        for key in Constants.group_dict.keys():
            if total_missing > 0:
                current_prob_cert = missing_treatments[key]['cert'] / \
                    total_missing
                current_prob_unc = missing_treatments[key]['unc'] / \
                    total_missing
                # If players join at the same time a lot it can happen that
                # threshold_cert< finished_cert
                if current_prob_cert < 0:
                    current_prob_cert = 0
                if current_prob_unc < 0:
                    current_prob_cert = 0
            else:
                current_prob_cert = 0
                current_prob_unc = 0

            # Append the probability for population uncertainty for the given
            # group size
            prob_list.append(((key, True), current_prob_unc))

            # The same for non population uncertainty
            prob_list.append(((key, False), current_prob_cert))

        return prob_list, total_missing

    def increase_counter(self):
        key = self.participant.vars['group_size']
        if self.participant.vars['pop_uncertain'] is True:
            self.session.vars[key][
                'finished_unc'] = self.session.vars[key]['finished_unc'] + 1
        if self.participant.vars['pop_uncertain'] is False:
            self.session.vars[key][
                'finished_cert'] = self.session.vars[key]['finished_cert'] + 1
Esempio n. 9
0
class Player(BasePlayer):

	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"
		)


# Part II: Investment for Group members
	
	c_principal_1 = models.CharField()
	c_principal_2 = models.CharField()
	c_principal_3 = models.CharField()
	c_principal_4 = models.CharField()

	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
		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
		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
		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
		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


	investment_for_p_1 = 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_for_p_2 = 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_for_p_3 = 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_for_p_4 = 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."
		)


# 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."
		)





	randomizer = models.IntegerField()


	def assign_role(self):
		if self.id_in_group == self.randomizer:
			self.roles="Agent"
		else:
			self.roles="Principal"


	roles = models.CharField()


	# 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.")


	def payments_principals(self):

		if self.roles == "Principal":
			if self.randomizer == 1:
				if self.id_in_group == 2:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p1 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p1)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p1
				elif self.id_in_group == 3:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p2 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p2)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p2
				elif self.id_in_group == 4:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p3 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p3)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p3
				elif self.id_in_group == 5:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p4 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p4)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p4

			elif self.randomizer == 2:
				if self.id_in_group == 1:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p1 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p1)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p1
				elif self.id_in_group == 3:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p2 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p2)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p2
				elif self.id_in_group == 4:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p3 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p3)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p3
				elif self.id_in_group == 5:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p4 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p4)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p4

			elif self.randomizer == 3:
				if self.id_in_group == 1:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p1 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p1)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p1
				elif self.id_in_group == 2:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p2 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p2)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p2
				elif self.id_in_group == 4:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p3 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p3)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p3
				elif self.id_in_group == 5:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p4 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p4)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p4

			elif self.randomizer == 4:
				if self.id_in_group == 1:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p1 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p1)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p1
				elif self.id_in_group == 2:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p2 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p2)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p2
				elif self.id_in_group == 3:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p3 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p3)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p3
				elif self.id_in_group == 5:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p4 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p4)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p4

			elif self.randomizer == 5:
				if self.id_in_group == 1:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p1 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p1)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p1
				elif self.id_in_group == 2:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p2 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p2)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p2
				elif self.id_in_group == 3:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p3 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p3)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p3
				elif self.id_in_group == 4:
					if self.investment_outcome == "Die Investition war erfolgreich.":
						self.payoff=self.group.invested_amount_p4 * 3.5 + (Constants.endowment_principals - self.group.invested_amount_p4)
					elif self.investment_outcome == "Die Investition war nicht erfolgreich.":
						self.payoff=Constants.endowment_principals - self.group.invested_amount_p4




	def payments_agents(self):

		if self.roles == "Agent":
			if self.compensation == "fixed":
				self.payoff=Constants.fixed_payment
			if self.compensation == "variable":
				self.payoff=Constants.variable_payment + Constants.share/100 * self.group.principals_payoff



	def find_relevant_principal(self):

		if self.group.randomizer_principal == self.id_in_group:
			self.relevant_principal = 1
		elif self.group.randomizer_principal != self.id_in_group:
			self.relevant_principal = 0

	relevant_principal = models.IntegerField()





	payoff = models.CurrencyField()






	my_group_id = models.IntegerField()

	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.")
Esempio n. 10
0
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'])

    treatment = models.CharField(
        doc=
        'Defines the treatment of the session. The treatment is the same for all players in one session'
    )

    # Save cost for vote as a player variable s.t. it appears in the dataset because it is encoded only in session.config
    cost_for_vote = models.FloatField()

    contribution = models.IntegerField(
        doc='The players contribution in the public good game in Taler',
        verbose_name='Ihr Betrag',
        min=0,
        max=Constants.endowment)

    myvotes = models.IntegerField(
        doc='The number of votes the player got after the public good game.')

    ivoted = models.IntegerField(
        doc=
        'The number of votes the player distributed to other players. This could be in {0,4} depending on the implementation.',
        initial=0)

    #set in set_socialgame()
    sanctioned = models.BooleanField(
        doc=
        'Determines if the player was sanctioned after the vote. Sanctioning means Exclusion, Rüge or monitary punishment.',
        default=False)

    round_payoff = models.IntegerField(
        initial=0,
        doc="The amount of Taler of the player in a particular round.")

    # Variables where player can vote to exclude/invite one player from the social arena game
    vote_A = models.BooleanField(widget=widgets.CheckboxInput(),
                                 verbose_name='Teilnehmer A',
                                 doc="The player voted for Player A")
    vote_B = models.BooleanField(widget=widgets.CheckboxInput(),
                                 verbose_name='Teilnehmer B',
                                 doc="The player voted for Player B")
    vote_C = models.BooleanField(widget=widgets.CheckboxInput(),
                                 verbose_name='Teilnehmer C',
                                 doc="The player voted for Player C")
    vote_D = models.BooleanField(widget=widgets.CheckboxInput(),
                                 verbose_name='Teilnehmer D',
                                 doc="The player voted for Player D")
    vote_E = models.BooleanField(widget=widgets.CheckboxInput(),
                                 verbose_name='Teilnehmer E',
                                 doc="The player voted for Player E")

    exclude_none = models.BooleanField(
        widget=widgets.CheckboxInput(),
        verbose_name="Ich möchte für kein Gruppenmitglied stimmen.",
        doc="The player wanted not to vote for any other player.")

    # 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)

    ## the round number that will be payed out for the player
    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."
    )

    ######################################################################################################################
    ### Questionnaire variables

    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",
        ])

    # only in exclude
    q3 = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "In jeder Runde hatten Sie die Möglichkeit, Gruppenmitglieder vom Gruppenspiel auszuschließen. Welche Überlegungen haben Sie dabei angestellt? (Bitte wählen Sie die Option, die am besten passt.)",
        choices=[
            "Ich habe rein zufällig meine Stimme vergeben",
            "Ich wollte Gruppenmitglieder für ihr Verhalten in der vorherigen Stufe bestrafen",
            "Ich wollte andere von der Last des Gruppenspiels befreien",
            "Ich wollte ausprobieren was passiert",
            "Ich habe in keiner Runde eine Stimme abgegeben"
        ])

    # only in exclude
    q4 = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Was denken Sie, warum haben andere Teilnehmer dafür gestimmt, Gruppenmitglieder auszuschließen?",
        choices=[
            "Rein zufällig",
            "Sie wollten Gruppenmitglieder für ihr Verhalten in der vorherigen Stufe bestrafen",
            "Sie wollten andere von der Last des Gruppenspiels befreien",
            "Sie wollten ausprobieren was passiert"
        ])

    ### dislike

    # dislike
    q3dislike = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "In jeder Runde hatten Sie die Möglichkeit, Gruppenmitglieder zu rügen. Welche Überlegungen haben Sie dabei angestellt? (Bitte wählen Sie die Option, die am besten passt.)",
        choices=[
            "Ich habe rein zufällig meine Stimme vergeben",
            "Ich wollte Gruppenmitglieder für ihr Verhalten in der vorherigen Stufe bestrafen",
            "Ich wollte ausprobieren was passiert",
            "Ich habe in keiner Runde eine Stimme abgegeben"
        ])

    # dislike
    q4dislike = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Was denken Sie, warum haben andere Teilnehmer dafür gestimmt, Gruppenmitglieder zu rügen?",
        choices=[
            "Rein zufällig",
            "Sie wollten Gruppenmitglieder für ihr Verhalten in der vorherigen Stufe bestrafen",
            "Sie wollten ausprobieren was passiert"
        ])

    #### punish

    # punish
    q3punish = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "In jeder Runde hatten Sie die Möglichkeit für einen Punktabzug für andere Spieler zu stimmen. Welche Überlegungen haben Sie dabei angestellt? (Bitte wählen Sie die Option, die am besten passt.)",
        choices=[
            "Ich habe rein zufällig meine Stimme vergeben",
            "Ich wollte Gruppenmitglieder für ihr Verhalten in der vorherigen Stufe bestrafen",
            "Ich wollte ausprobieren was passiert",
            "Ich habe in keiner Runde eine Stimme abgegeben"
        ])

    # punish
    q4punish = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Was denken Sie, warum haben andere Teilnehmer dafür gestimmt?",
        choices=[
            "Rein zufällig",
            "Sie wollten Gruppenmitglieder für ihr Verhalten in der vorherigen Stufe bestrafen",
            "Sie wollten ausprobieren was passiert"
        ])

    ### alll treatments
    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)

    ######################################################################################################################
    ### 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"])

    # exclude
    control3d = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Sollten Sie in einer Runde vom Gruppenspiel ausgeschlossen werden, so können Sie in der nächsten Runde nicht an der Aufteilungsentscheidung teilnehmen.",
        choices=["wahr", "falsch"])

    # exclude
    control4 = models.IntegerField(
        widget=widgets.RadioSelectHorizontal(),
        verbose_name=
        "Für den Ausschluss von wie vielen Gruppenmitgliedern können Sie maximal stimmen?",
        choices=[0, 1, 2, 3, 4, 5])

    #exclude
    control5 = models.StringField(
        widget=widgets.RadioSelectHorizontal(),
        verbose_name=
        "Wie viele Taler kostet es Sie, wenn Sie ein Gruppenmitglied ausschließen?",
        choices=[
            "0 Taler  ", "0,2 Taler  ", "0,5 Taler  ", "1 Taler  ", "2 Taler  "
        ])

    #exclude
    control6 = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Sie erhalten zwei Stimmen. Dürfen Sie an dem Gruppenspiel teilnehmen?",
        choices=["ja", "nein"])

    ### dislike
    # you could also just change verbose names for many questions. But I do it like that in case single questions change
    # dislike. And for example for control6 it does not work because it is not the same answer

    # dislike
    control4dislike = models.IntegerField(
        widget=widgets.RadioSelectHorizontal(),
        verbose_name=
        "Für das Rügen von wie vielen Mitgliedern können Sie maximal stimmen?",
        choices=[0, 1, 2, 3, 4, 5])

    # dislike
    control5dislike = models.StringField(
        widget=widgets.RadioSelectHorizontal(),
        verbose_name=
        "Wie viele Taler kostet es Sie, wenn Sie ein Gruppenmitglied rügen?",
        choices=[
            "0 Taler  ", "0,2 Taler  ", "0,5 Taler  ", "1 Taler  ", "2 Taler  "
        ])

    # dislike
    control6dislike = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name="Sie erhalten zwei Stimmen. Werden Sie gerügt?",
        choices=["ja", "nein"])

    #### punish

    # punish
    control4punish = models.IntegerField(
        widget=widgets.RadioSelectHorizontal(),
        verbose_name=
        "Für den Abzug von Talern von wie vielen Mitgliedern können Sie maximal stimmen?",
        choices=[0, 1, 2, 3, 4, 5])

    # punish
    control5punish = models.StringField(
        widget=widgets.RadioSelectHorizontal(),
        verbose_name=
        "Wie viele Taler kostet es Sie, wenn Sie für den Talerabzug eines Mitglieds stimmen?",
        choices=[
            "0 Taler  ", "0,2 Taler  ", "0,5 Taler  ", "1 Taler  ", "2 Taler  "
        ])

    # punish
    control6punish = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Sie erhalten zwei Stimmen. Erhalten Sie einen Abzug von Talern?",
        choices=["ja", "nein"])

    # nosanction + dislike + punishment
    control7control = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name="Mit wem spielen Sie das Gruppenspiel?",
        choices=[
            "Alleine",
            "Mit 4 Teilnehmern, die in Stufe 1 dieser Runde nicht in meiner Gruppe waren",
            "Mit den 4 Teilnehmern, die in Stufe 1 dieser Runde in meiner Gruppe waren"
        ])

    #exclude
    control7exclude = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name="Mit wem spielen Sie das Gruppenspiel?",
        choices=[
            "Alleine",
            "Mit 4 Teilnehmern, die in Stufe 1 dieser Runde nicht in meiner Gruppe waren",
            "Mit den Teilnehmern meiner Gruppe, die nicht ausgeschlossen wurden",
            "Mit den ausgeschlossenen Gruppenmitgliedern aus dieser Runde"
        ])

    # nosanction + exclude + dislike + punishment
    control8 = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Was passiert, wenn Sie einen richtigen Begriff im Gruppenspiel eingeben?",
        choices=[
            "Nichts",
            "Er wird allen Gruppenmitgliedern gezeigt und ich verdiene einen Taler",
            "Er wird allen Gruppenmitgliedern gezeigt und die Gruppe bekommt einen Spielpunkt"
        ])

    ######################################################################################################################
    ###Family Feud

    plays = models.BooleanField(
        doc=
        'Determines if the player is allowed to play the guessing game in a particular round.',
        default=True)

    # 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)"
    )

    # 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
Esempio n. 11
0
File: models.py Progetto: chkgk/zteb
class Player(BasePlayer):

    treatment = models.CharField(
        doc='Defines the treatment of the player. The treatment is the same for all players in one session and can either be "Private" or "Distribution".',
        choices=['private', 'distribution'])

    #All dice inputs shall appear in the database
    dice1 = models.IntegerField(
        doc='The input for the 1st dice roll of the player', min=1, max=6)
    dice2 = models.IntegerField(
        doc='The input for the 2nd dice roll of the player', min=1, max=6)
    dice3 = models.IntegerField(
        doc='The input for the 3rd dice roll of the player', min=1, max=6)
    dice4 = models.IntegerField(
        doc='The input for the fourth dice roll of the player', min=1, max=6)
    dice5 = models.IntegerField(
        doc='The input for the fift dice roll of the player', min=1, max=6)
    dice6 = models.IntegerField(
        doc='The input for the sixt dice roll of the player', min=1, max=6)

    age = models.IntegerField(
        doc='The age of the participant',
        min=14,
        max=110,
        verbose_name='Please enter your age.')

    gender = models.CharField(
        doc='The gender of the participant',
        choices=['Male', 'Female'],
        widget=widgets.RadioSelect(),
        verbose_name='What is your gender?')

    nonstudent = models.BooleanField(
        doc='1 if the participant is not a student',
        widget=widgets.CheckboxInput(),
        verbose_name='Click if you are not a student.')

    studies = models.CharField(
        doc='Field of study, if the participant is a student',
        blank='True',
        verbose_name='Enter your field of study if you are a student. Leave blank if you are not a student')

    risk = models.CharField(
        doc='Risk attitude of the participant. (7 points Likert scale)',
        choices=['Entirely Agree',
                 'Mostly Agree',
                 'Somewhat Agree',
                 'Neither Agree nor Disagree',
                 'Somewhat Disagree',
                 'Mostly Disagree',
                 'Entirely Disagree'],
        widget=widgets.RadioSelectHorizontal(),
        verbose_name='How strong do you agree/disagree with the following statement: "I like taking risks."?')

    timeout = models.BooleanField(
        default=False,
        doc="Equals True if the participant did not enter any results. She then gets a payoff of zero.")

    #Note: if you implement a 'doc' parameter this will throw an exception
    country = CountryField(
        #I decided to not permit not entering a country
        blank=False,
        verbose_name='What is the country of your origin?')

    #Note: payoff is calculated in views by using this function
    def return_sum(self):
        return sum ([self.dice1, self.dice2, self.dice3, self.dice4, self.dice5, self.dice6])
Esempio n. 12
0
class Player(BasePlayer):
    consent = models.BooleanField(widget=widgets.CheckboxInput())
Esempio n. 13
0
    'Weibo',
    'WeChat',
]

rows = [
    ("prof_network", "Professional networking"),
    ("soc_network", "Social networking"),
    ("xchng_info", "Exchange of information with peers and family"),
    ("soc_events", "Organize and/or attend social events"),
    ("pol_events", "Organize and/or attend political events"),
    ("news_info", "News and information about people and places"),
    ("job", "Job seeking"),
    ("money", "To make money"),
    ("games", "To play games"),
    ("research", "Research"),
    #   ("other", "Other"),
    ("used_sites", "Select the sites that you use a couple of times a week"),
]

i = 0
for r in rows:
    for c in columns:
        i += 1
        field_name = 'q14_{}_{}X{}'.format(i, r[0], c)
        Player.add_to_class(
            field_name,
            models.BooleanField(
                verbose_name=r[1],
                widget=widgets.CheckboxInput(),
            ))