예제 #1
0
class Group(BaseGroup):
    inflation_mean = models.DecimalField(max_digits=9, decimal_places=2)
    actual_inflation = models.DecimalField(max_digits=9, decimal_places=2)
    deficit = models.DecimalField(max_digits=9, decimal_places=2)
    alpha = models.DecimalField(max_digits=9, decimal_places=2)
    def_fin = models.DecimalField(max_digits=9, decimal_places=2)
    treatment = models.StringField()
예제 #2
0
class Player(BasePlayer):
    # type of the player: 0 == seller; 1 == buyer
    def role(self):
        if self.id_in_group == 1:
            return 'buyer'
        if self.id_in_group == 2:
            return 'seller'

    # variables for the values
    value = models.DecimalField(max_digits=5, decimal_places=1, default=0)

    #buyer_value  = models.DecimalField(max_digits=5, decimal_places=1, default=0)
    # setting the values
    def set_value(self):
        self.value = random.uniform(Constants.min_support,
                                    Constants.max_support)
        #print('value set')

    # variables for the prices:
    personal_price = models.DecimalField(max_digits=5,
                                         decimal_places=1,
                                         default=0)
    #buyer_price  = models.DecimalField(max_digits=5, decimal_places=1, default=0)

    # profit variable
    profit = models.DecimalField(max_digits=5, decimal_places=1, default=0)
예제 #3
0
class Player(BasePlayer):
    def before_next_page(self):
        self.fake_svo_angle = self.participant.vars['fangle'][0]
        self.fake_svo_classification = slider.svo_classification(self.fake_svo_angle)
        self.individual_share_a = self.participant.vars['fshare']
        self.shared_point = Constants.endowment - self.participant.vars['fshare']

    def set_payoff(self):
        """Calculate payoff, to be implemented later """
        self.payoff = 0

    slider1 = models.FloatField()
    slider2 = models.FloatField()
    slider3 = models.FloatField()
    slider4 = models.FloatField()
    slider5 = models.FloatField()
    slider6 = models.FloatField()
    offer_accept = models.BooleanField(choices=[[True, u'接受'], [False, u'不接受']],
                                       widget=widgets.RadioSelectHorizontal, label=u'你是否接受这个方案?')
    slider_angle = models.DecimalField(decimal_places=2, max_digits=5)
    slider_classification = models.CharField()
    fake_svo_angle = models.DecimalField(decimal_places=2, max_digits=5)
    fake_svo_classification = models.CharField()
    individual_share_a = models.IntegerField()
    shared_point = models.IntegerField()
    feeling_rating = models.IntegerField()
    name = models.StringField(label = u'请输入您的姓名')
    age = models.IntegerField(label=u'请输入您的年龄')
    gender = models.IntegerField(label=u'请输入您的性别',choices=[[1,u'男'],[2,u'女']])
    education = models.StringField(label=u'请输入您的受教育程度',blank=True,choices=[u'小学',u'中学',u'高中',u'大学',]
                                   + [u'大学后进阶教育 %d 年' %y for y in range(1,10)] +[u'持续进阶教育达到 10年及以上',])
    career = models.StringField(label = u'请输入您的职业')
    contact = models.StringField(label = u'请输入您的联系方式(支付宝绑定的手机号)')
    subjectid = models.StringField(label=u'请输入您的身份证号(用于报销凭证)')
    otherinfo = models.StringField(label = u'如有被试费用相关信息请在此处,请在此处说明')
    def vars_for_template(self):
        if self.round_number ==1:
            print (self.participant.vars['fangle'][0], self.participant.vars['fshare'])
            return {'svo_slider_angle': self.slider_angle,
                    'slider_classification': slider.svo_classification(self.slider_angle),
                    'fake_svo_angle': self.participant.vars['fangle'][0],
                    'fake_svo_classification': slider.svo_classification(self.fake_svo_angle),
                    'individual_share_a':self.participant.vars['fshare'],
                    'shared_point': Constants.endowment - self.participant.vars['fshare'],
                    }
        else:
            round_1_player = self.in_round(1)
            return {'svo_slider_angle': round_1_player.slider_angle,
                    'slider_classification': round_1_player.slider_classification,
                    'fake_svo_angle': self.participant.vars['fangle'][0],
                    'fake_svo_classification': slider.svo_classification(self.fake_svo_angle),
                    'individual_share_a':self.participant.vars['fshare'],
                    'shared_point': Constants.endowment - self.participant.vars['fshare']
                    }
예제 #4
0
class Group(BaseGroup):
    # in DS Bilateral Trade the price is determined as random:
    final_price = models.DecimalField(max_digits=5,
                                      decimal_places=1,
                                      default=0)
    paying_round = models.IntegerField()

    # setting payoffs function:
    def set_payoffs(self):
        p_buyer = self.get_player_by_role('buyer')
        p_seller = self.get_player_by_role('seller')
        self.final_price = p_seller.personal_price
        if p_buyer.personal_price >= p_seller.personal_price:
            p_buyer.profit = p_buyer.value - p_seller.personal_price
            p_seller.profit = p_seller.personal_price - p_seller.value
        else:
            p_buyer.profit = 0
            p_seller.profit = 0
        p_buyer.set_belief_payoff()
        p_seller.set_belief_payoff()

    # setting final payoffs:
    def set_final_payoff(self):
        self.subsession.paying_round = random.randint(1, Constants.num_rounds)
        for p in self.get_players():
            # also converting to GBPs:
            p.final_treatment_profit = p.in_round(
                self.subsession.paying_round).profit * decimal.Decimal(
                    Constants.trade_exchange_rate)
            p.final_beliefs_profit = p.in_round(
                self.subsession.paying_round).beliefs_profit * decimal.Decimal(
                    Constants.trade_exchange_rate)
예제 #5
0
class Group(BaseGroup):
	# VARIABLES:
	# in DS Bilateral Trade the price is determined as random:
	final_price = models.DecimalField(max_digits=5, decimal_places=0, default=0)
	paying_round = models.IntegerField()


	# FUNCTIONS:
	# method to support the random price:
	def set_random_price(self):
		# instead of using random.randrange that is for integers only, we use rand.uniform to have the float
		self.final_price = round(random.uniform(Constants.min_support,Constants.max_support),0)

	# setting payoffs function:
	def set_payoffs(self):
		# trade profit:
		p_buyer  = self.get_player_by_role('buyer')
		p_seller = self.get_player_by_role('seller')
		if p_buyer.personal_price >= self.final_price and p_seller.personal_price <= self.final_price:
			p_buyer.profit = p_buyer.value - self.final_price
			p_seller.profit = self.final_price - p_seller.value
		else:
			p_buyer.profit = 0
			p_seller.profit = 0
		# belief profit:
		p_buyer.set_belief_payoff()
		p_seller.set_belief_payoff()

	# setting final payoffs:
	def set_final_payoff(self):
		self.subsession.paying_round=random.randint(1,Constants.num_rounds)
		for p in self.get_players():
			# also converting to GBPs:
			p.final_treatment_profit = p.in_round(self.subsession.paying_round).profit*decimal.Decimal(Constants.trade_exchange_rate)
			p.final_beliefs_profit = p.in_round(self.subsession.paying_round).beliefs_profit*decimal.Decimal(Constants.trade_exchange_rate)
예제 #6
0
class Player(BasePlayer):
    name = models.StringField(label="The nickname you chose for the class:")
    age = models.IntegerField(label="Your Age:")
    country = models.StringField(label="Where are you from?")
    gender = models.IntegerField(
        label="Gender:",
        choices=[
            [1, 'Male'],
            [2, 'Female'],
        ]
    )
    experience = models.IntegerField(
        label="Have you ever experienced annual inflation greater than 10%?",
        choices=[
            [1, 'Yes'],
            [0, 'No'],
            ]
        )
    economics = models.IntegerField(
        label="Do you have previous training in Economics?",
        choices=[
            [1, 'Yes'],
            [0, 'No'],
        ]
    )

    inflation = models.DecimalField(max_digits=9, decimal_places=2)

    comments = models.LongStringField(label="What was your general strategy? Do you want to add some comments?")
예제 #7
0
class Group(BaseGroup):
    # define vars
    treatment = models.TextField()
    value_type = models.TextField()
    elicitation_method = models.TextField()
    BDM_type = models.TextField()
    BDM_lolimit = models.TextField()
    BDM_uplimit = models.TextField()
    BDM_list_step = models.DecimalField(max_digits=5, decimal_places=2)
예제 #8
0
class Subsession(BaseSubsession):
    players_per_group = models.IntegerField()
    language = models.CharField(choices=['ja'])  # English, Deutsch, Italian
    #    language = models.CharField(choices=['EN', 'DE', 'IT'])   # English, Deutsch, Italian
    select_items = models.CharField(choices=['PRIMARY', 'FULL'])
    items_in_random_order = models.BooleanField()
    scale = models.DecimalField(max_digits=5, decimal_places=2)
    precision = models.CharField(
        choices=['INTEGERS', 'TWO_DIGITS_AFTER_POINT'])
    matching = models.CharField(choices=['RING', 'RANDOM_DICTATOR'])
    random_payoff = models.CharField(choices=['RAND', 'SUM'])
    slider_init_type = models.CharField(
        choices=['LEFT', 'RIGHT', 'RAND', 'AVG'])

    # Runs at initialization time and saves the configs in the database
    def before_session_starts(self):
        self.players_per_group = Constants.players_per_group
        self.language = Constants.language
        self.select_items = Constants.select_items
        self.items_in_random_order = Constants.items_in_random_order
        self.scale = Constants.scale
        self.precision = Constants.precision
        self.matching = Constants.matching
        self.slider_init_type = Constants.slider_init_type

        if Constants.select_items == 'FULL':
            item_order = list(range(1, 16))
        else:
            item_order = list(range(1, 7))

        self.set_item_orders(item_order)

# Sets the order of items that is going to be shown to each player
# it can be random for each player or the fixed order according to the paper

    def set_item_orders(self, item_order):
        players = self.get_players()
        if Constants.items_in_random_order:
            random.shuffle(item_order)
        for player in players:
            player.random_order1 = item_order[0]
            player.random_order2 = item_order[1]
            player.random_order3 = item_order[2]
            player.random_order4 = item_order[3]
            player.random_order5 = item_order[4]
            player.random_order6 = item_order[5]
            if Constants.select_items == 'FULL':
                player.random_order7 = item_order[6]
                player.random_order8 = item_order[7]
                player.random_order9 = item_order[8]
                player.random_order10 = item_order[9]
                player.random_order11 = item_order[10]
                player.random_order12 = item_order[11]
                player.random_order13 = item_order[12]
                player.random_order14 = item_order[13]
                player.random_order15 = item_order[14]
예제 #9
0
파일: models.py 프로젝트: DDuell/ATT2
class Player(BasePlayer):
    def role(self):
        if self.subsession.round_number == 1:
            if self.id_in_group == 1:
                return 'Player 1'
            else:
                return 'Player 2'
        else:
            if self.in_round(1).id_in_group == 1:
                return 'Player 1'
            elif self.in_round(1).id_in_group == 2:
                return 'Player 2'

    age = models.PositiveIntegerField(verbose_name='How old are you?')

    gender = models.PositiveIntegerField(
        initial=None,
        choices=[(0, 'male'), (1, 'female')],
        # (7, 'other')],
        verbose_name='What is your gender?',
        widget=widgets.RadioSelect())
    state = USStateField(verbose_name='Which is your state of residence?',
                         blank=True)

    race = models.PositiveIntegerField(
        initial=None,
        choices=[
            (1, 'White Non-Hispanic'),
            (2, 'Black Non-Hispanic'),
            (3, 'Hispanic'),
            (4, 'Other or multiple races, Non-Hispanic'),
        ],
        verbose_name='What is your race or ethnicity?',
        widget=widgets.RadioSelect)

    round_chosen_payoff = models.IntegerField(initial=1, )

    chosen_payoff = models.DecimalField(max_digits=5, decimal_places=2)

    total_payoff = models.DecimalField(max_digits=5, decimal_places=2)

    other_gender = models.CharField()
예제 #10
0
class Player(BasePlayer):

    time_emo_quest_pg1 = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_emo_quest_pg2 = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_DoneQuestionnaire = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

    for i in range(len(Constants.emo_list)):
        temp = Constants.emo_list[i]
        locals()['{}'.format(temp)] = models.DecimalField(widget=widgets.HiddenInput(),
                                                          max_digits=3,
                                                          decimal_places=1,
                                                          min=1,
                                                          max=7)
예제 #11
0
class Group(BaseGroup):
    # in DS Bilateral Trade the price is determined as random:
    final_price = models.DecimalField(max_digits=5,
                                      decimal_places=1,
                                      default=0)

    # setting payoffs function:
    def set_payoffs(self):
        p_buyer = self.get_player_by_role('buyer')
        p_seller = self.get_player_by_role('seller')
        self.final_price = p_seller.personal_price
        if p_buyer.personal_price >= p_seller.personal_price:
            p_buyer.profit = p_buyer.value - p_seller.personal_price
            p_seller.profit = p_seller.personal_price - p_seller.value
        else:
            p_buyer.profit = 0
            p_seller.profit = 0
예제 #12
0
class Player(BasePlayer):
    maxScreens = models.DecimalField(max_digits=5, decimal_places=2)
    screenTime = models.DecimalField(max_digits=5, decimal_places=2)
    pointDistMin = models.DecimalField(max_digits=5, decimal_places=2)
    pointDistMax = models.DecimalField(max_digits=5, decimal_places=2)

    task_reward = models.DecimalField(max_digits=5, decimal_places=2)
    target_income = models.DecimalField(max_digits=5, decimal_places=2)
    # add timestamps
    time_GameInstructions = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_PracticeTask = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_SearchTask = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
class Group(BaseGroup):
    # in DS Bilateral Trade the price is determined as random:
    final_price = models.DecimalField(max_digits=5,
                                      decimal_places=1,
                                      default=0)

    # method to support the random price:
    def set_random_price(self):
        # instead of using random.randrange that is for integers only, we use rand.uniform to have the float
        self.final_price = random.uniform(Constants.min_support,
                                          Constants.max_support)

    # setting payoffs function:
    def set_payoffs(self):
        p_buyer = self.get_player_by_role('buyer')
        p_seller = self.get_player_by_role('seller')
        if p_buyer.personal_price >= self.final_price and p_seller.personal_price <= self.final_price:
            p_buyer.profit = p_buyer.value - self.final_price
            p_seller.profit = self.final_price - p_seller.value
        else:
            p_buyer.profit = 0
            p_seller.profit = 0
예제 #14
0
파일: models.py 프로젝트: akrgt/gotree
class Player(BasePlayer):
    def set_payoff(self):
        """Calculate payoff, to be implemented later """
        self.payoff = 0

    slider1 = models.FloatField()
    slider2 = models.FloatField()
    slider3 = models.FloatField()
    slider4 = models.FloatField()
    slider5 = models.FloatField()
    slider6 = models.FloatField()
    slider_angle = models.DecimalField(decimal_places=2, max_digits=5)
    slider_classification = models.CharField()
    slider7 = models.FloatField()
    slider8 = models.FloatField()
    slider9 = models.FloatField()
    slider10 = models.FloatField()
    slider11 = models.FloatField()
    slider12 = models.FloatField()
    slider13 = models.FloatField()
    slider14 = models.FloatField()
    slider15 = models.FloatField()

    nine_item_tdm_1 = models.CharField()
    nine_item_tdm_2 = models.CharField()
    nine_item_tdm_3 = models.CharField()
    nine_item_tdm_4 = models.CharField()
    nine_item_tdm_5 = models.CharField()
    nine_item_tdm_6 = models.CharField()
    nine_item_tdm_7 = models.CharField()
    nine_item_tdm_8 = models.CharField()
    nine_item_tdm_9 = models.CharField()
    nine_item_tdm_prosocial = models.IntegerField()
    nine_item_tdm_individualistic = models.IntegerField()
    nine_item_tdm_competitive = models.IntegerField()
    nine_item_tdm_classification = models.CharField()
예제 #15
0
class Group(BaseGroup):
    b_willing = models.DecimalField(min=0, max_digits=6, decimal_places=3)
예제 #16
0
class Player(BasePlayer):
    group = models.IntegerField()
    UserAgent = models.StringField()
    device = models.StringField()

    consent = models.IntegerField(
        label='Consent declaration:',
        initial=None,
        choices=[[
            1,
            'I read and understood the stated terms. I had enough time to make a decision. Herewith, I consent to participate in this study.'
        ], [0, 'I choose not to participate in this study.']],
        widget=widgets.RadioSelect)

    success_number = models.IntegerField(initial=random.randint(1, 6))
    success_number2 = models.IntegerField(initial=0)
    fail_number = models.IntegerField(initial=0)

    investment = models.IntegerField(label='',
                                     initial=None,
                                     min=0,
                                     max=Constants.endowment)

    lottery = models.BooleanField()
    # initial=None,
    # label='Möchten Sie CHF 0.25 in die Lotterie investieren?',
    # choices=[
    #     [25, 'Ja, ich will in die Lotterie investieren.'],
    #     [0, 'Nein, ich steige aus den Lotterien aus.']
    # ]

    success = models.BooleanField()
    random_draw = models.IntegerField()
    exit = models.IntegerField(initial=0)

    # results / payoffs
    investment_1 = models.IntegerField(initial=None)
    investment_2 = models.IntegerField(initial=None)
    investment_3 = models.IntegerField(initial=None)
    investment_4 = models.IntegerField(initial=None)

    lot_1_p = models.CurrencyField(initial=None)
    lot_2_p = models.CurrencyField(initial=None)
    lot_3_p = models.CurrencyField(initial=None)
    lot_4_p = models.CurrencyField(initial=None)

    lot_1_s = models.BooleanField(initial=None)
    lot_2_s = models.BooleanField(initial=None)
    lot_3_s = models.BooleanField(initial=None)
    lot_4_s = models.BooleanField(initial=None)

    sum_lot_p = models.CurrencyField(initial=None)
    sum_lot = models.DecimalField(max_digits=5, decimal_places=0)
    sum_lot_chf = models.DecimalField(max_digits=5, decimal_places=2)
    part_id = models.StringField(initial=None)

    #Aspect Listing
    reason_1 = models.LongStringField(initial=None, label='Reason # 1')
    reason_2 = models.LongStringField(initial=None, label='Reason # 2')
    reason_3 = models.LongStringField(initial=None, label='Reason # 3')
    reason_4 = models.LongStringField(initial=None, label='Reason # 4')
    reason_5 = models.LongStringField(initial=None, label='Reason # 5')
예제 #17
0
class Player(BasePlayer):

    # == OBJECTS == #
    # == Base Objects == #
    prolific_id = models.StringField()
    start_time = models.FloatField()
    end_time = models.FloatField()
    round_earnings = models.FloatField()
    round_earnings_str = models.StringField()
    # round_earnings_init = models.FloatField() <- DO I NEED THIS???
    condition = models.StringField()
    cause = models.StringField()

    # Allow for small mistakes in inputting consent/confirmation
    consent = models.StringField(label='',
                                 choices=['I consent', 'I consent '],
                                 widget=widgets.TextInput)
    confirm_cause_nra = models.StringField(
        label='',
        choices=[
            'Any donations I make in this experiment will '
            'go to the National Rifle Association (NRA).',
            'Any donations I make in this experiment will '
            'go to the National Rifle Association (NRA)',
            'Any donations I make in this experiment will '
            'go to the National Rifle Association.',
            'Any donations I make in this experiment will '
            'go to the National Rifle Association',
        ],
        widget=widgets.TextInput)
    confirm_cause_etfgs = models.StringField(
        label='',
        choices=[
            'Any donations I make in this experiment will go to '
            'Everytown for Gun Safety.',
            'Any donations I make in this experiment will go to '
            'Everytown for Gun Safety'
        ],
        widget=widgets.TextInput)
    confirm_cause_rc = models.StringField(
        label='',
        choices=[
            'Any donations I make in this experiment '
            'will go to The American Red Cross.',
            'Any donations I make in this experiment '
            'will go to The American Red Cross'
        ],
        widget=widgets.TextInput)
    confirm_money = models.StringField(
        label='',
        choices=[
            'My personal earnings in this experiment will be paid '
            'to me in real money.',
            'My personal earnings in this experiment will be paid '
            'to me in real money'
        ],
        widget=widgets.TextInput)
    donation = models.FloatField()
    donation_sum = models.FloatField()
    round_donation_str = models.StringField()
    donation_str = models.StringField()
    payoff_a = models.FloatField()
    payoff_a_str = models.StringField()
    payoff_b = models.FloatField()
    payoff_b_str = models.StringField()
    paying_round_a = models.IntegerField()
    paying_round_b = models.IntegerField()
    rand_num = models.IntegerField()
    social_action_count = models.IntegerField()

    # == Create Strategy Bundle Input Objects == #
    type = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['Sweater Vest', 'Cardigan', 'Turtleneck'],
        blank=False)
    cotton = models.PositiveIntegerField(
        label='',
        blank=False,
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)])
    price = models.PositiveIntegerField(
        label='',
        blank=False,
        validators=[MinValueValidator(9),
                    MaxValueValidator(109)])
    social_action = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['No Action', 'Donate 10% of Period Earnings'],
        blank=False)
    # Default strategy bundle choices for first round (first reference strategy from previous CEO letter)
    type1 = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['Sweater Vest', 'Cardigan', 'Turtleneck'],
        blank=False,
        initial='Sweater Vest')
    cotton1 = models.PositiveIntegerField(
        label='',
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)],
        blank=False,
        initial=80)
    price1 = models.PositiveIntegerField(
        label='',
        validators=[MinValueValidator(9),
                    MaxValueValidator(109)],
        blank=False,
        initial=49)
    social_action1 = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['No Action', 'Donate 10% of Period Earnings'],
        blank=False,
        initial='No Action')
    # Boolean match objects for assigning relevant market niche from strategy
    t_match1 = models.BooleanField()
    t_match2 = models.BooleanField()
    t_match3 = models.BooleanField()
    d_match1 = models.BooleanField()
    d_match2 = models.BooleanField()
    d_match3 = models.BooleanField()
    match1 = models.BooleanField()
    match2 = models.BooleanField()
    match3 = models.BooleanField()

    # == Objects to Store Notes Taken on Results Page == #
    round_earnings_n = models.DecimalField(label='',
                                           decimal_places=2,
                                           max_digits=4,
                                           blank=True)
    type_n = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['Sweater Vest', 'Cardigan', 'Turtleneck'],
        blank=True)
    cotton_n = models.IntegerField(label='', blank=True)
    price_n = models.IntegerField(label='', blank=True)
    social_action_n = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['No Action', 'Donate 10% of Period Earnings'],
        blank=True)
    board_block_n = models.StringField(label='',
                                       widget=widgets.RadioSelect,
                                       choices=['Blocked', 'Did Not Block'],
                                       blank=True)

    # == Board Condition Variables == #
    type_b = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['Sweater Vest', 'Cardigan', 'Turtleneck'],
        blank=False)
    cotton_b = models.IntegerField(
        label='',
        blank=False,
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)])
    price_b = models.IntegerField(
        label='',
        blank=False,
        validators=[MinValueValidator(9),
                    MaxValueValidator(109)])
    social_action_b = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['No Action', 'Donate 10% of Period Earnings'],
        blank=False)
    board_block = models.StringField()
    board_penalty = models.StringField()
    pre_decision_earnings = models.FloatField()

    # == Attention and Free Response Answer Objects == #
    attention_check = models.StringField(label='', blank=True)

    free_response_1 = models.StringField(label='', widget=widgets.Textarea)
    free_response_2 = models.StringField(label='', widget=widgets.Textarea)
    free_response_3 = models.StringField(label='', widget=widgets.Textarea)
    free_response_4 = models.StringField(label='', widget=widgets.Textarea)

    free_response_b1 = models.StringField(label='', widget=widgets.Textarea)
    free_response_b2 = models.StringField(label='', widget=widgets.Textarea)

    free_response_r1 = models.StringField(label='', widget=widgets.Textarea)
    free_response_r2 = models.StringField(label='', widget=widgets.Textarea)

    # == Questionnaire and Risk / Ambiguity Aversion Objects == #
    age = models.IntegerField(label='', min=0, max=100, blank=True)
    gender = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=['Male', 'Female', 'Non-Binary', 'Prefer not to Disclose'],
        blank=True)
    race = models.StringField(label='',
                              widget=widgets.RadioSelect,
                              choices=[
                                  'White', 'Black', 'East Asian',
                                  'South Asian', 'Middle Eastern', 'Hispanic',
                                  'Multi-racial', 'Other'
                              ],
                              blank=True)
    volunteer = models.StringField(label='',
                                   widget=widgets.RadioSelect,
                                   choices=['Yes', 'No'],
                                   blank=True)
    donated = models.StringField(label='',
                                 widget=widgets.RadioSelect,
                                 choices=['Yes', 'No'],
                                 blank=True)
    politics = models.StringField(label='',
                                  widget=widgets.RadioSelect,
                                  choices=[
                                      'Very Conservative',
                                      'Moderately Conservative',
                                      'Lean Conservative', 'Lean Liberal',
                                      'Moderately Liberal', 'Very Liberal'
                                  ],
                                  blank=True)
    stance_opinion = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=[
            'Very Inappropriate', 'Moderately Inappropriate',
            'Slightly Inappropriate', 'Slightly Appropriate',
            'Moderately Appropriate', 'Very Appropriate'
        ],
        blank=True)
    csr_opinion = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=[
            'Very Inappropriate', 'Moderately Inappropriate',
            'Slightly Inappropriate', 'Slightly Appropriate',
            'Moderately Appropriate', 'Very Appropriate'
        ],
        blank=True)
    trolley = models.StringField(
        label='',
        widget=widgets.RadioSelect,
        choices=[
            'Leave the ventilator in the original patient; the five new patients die',
            'Rotate the ventilator among the five new patients; the original patient dies'
        ],
        blank=True)

    def make_risk_amb_fields(choices):
        return models.StringField(
            label='',
            widget=widgets.RadioSelect,
            choices=choices,
            blank=True,
        )

    risk1 = make_risk_amb_fields([
        '$7 for certain', '$10 with probability 50%, $2 with probability 50%'
    ])
    risk2 = make_risk_amb_fields([
        '$6 for certain', '$10 with probability 50%, $2 with probability 50%'
    ])
    risk3 = make_risk_amb_fields([
        '$5 for certain', '$10 with probability 50%, $2 with probability 50%'
    ])
    risk4 = make_risk_amb_fields([
        '$4 for certain', '$10 with probability 50%, $2 with probability 50%'
    ])
    risk5 = make_risk_amb_fields([
        '$3 for certain', '$10 with probability 50%, $2 with probability 50%'
    ])
    amb1 = make_risk_amb_fields([
        'Bag 1 (containing 16 red balls and 4 black balls)',
        'Bag 2 (containing 20 balls)'
    ])
    amb2 = make_risk_amb_fields([
        'Bag 1 (containing 14 red balls and 6 black balls)',
        'Bag 2 (containing 20 balls)'
    ])
    amb3 = make_risk_amb_fields([
        'Bag 1 (containing 12 red balls and 8 black balls)',
        'Bag 2 (containing 20 balls)'
    ])
    amb4 = make_risk_amb_fields([
        'Bag 1 (containing 10 red balls and 10 black balls)',
        'Bag 2 (containing 20 balls)'
    ])
    amb5 = make_risk_amb_fields([
        'Bag 1 (containing 8 red balls and 12 black balls)',
        'Bag 2 (containing 20 balls)'
    ])
    amb6 = make_risk_amb_fields([
        'Bag 1 (containing 6 red balls and 14 black balls)',
        'Bag 2 (containing 20 balls)'
    ])
    amb7 = make_risk_amb_fields([
        'Bag 1 (containing 4 red balls and 16 black balls)',
        'Bag 2 (containing 20 balls)'
    ])

    def make_fair_mkt_fields(label):
        return models.StringField(label=label,
                                  widget=widgets.RadioSelect,
                                  choices=[
                                      "5: Completely Agree", "4", "3", "2",
                                      "1", "0: Neither Agree nor Disagree",
                                      "-1", "-2", "-3", "-4",
                                      "-5: Completely Disagree"
                                  ],
                                  blank=True)

    fair1 = make_fair_mkt_fields('The free market system is a fair system')
    fair2 = make_fair_mkt_fields(
        'Common or “normal” business practices must be fair, or they would not survive'
    )
    fair3_r = make_fair_mkt_fields(
        'In many markets, there is no such thing as a true “fair” market price'
    )
    fair4_r = make_fair_mkt_fields(
        'Ethical businesses are not as profitable as unethical businesses')
    fair5 = make_fair_mkt_fields(
        'The most fair economic system is a market system in which everyone is allowed to '
        'independently pursue their own economic interests')
    fair6_r = make_fair_mkt_fields(
        'Acting in response to market forces is not always a fair way to conduct business'
    )
    fair7 = make_fair_mkt_fields(
        'The free market system is an efficient system')
    fair8_r = make_fair_mkt_fields(
        'The free market system has nothing to do with fairness')
    fair9 = make_fair_mkt_fields(
        'Acting in response to market forces is an ethical way to conduct business'
    )
    fair10 = make_fair_mkt_fields(
        'In free market systems, people tend to get the outcomes that they deserve'
    )

    risk_payoff = models.FloatField()
    risk_payoff_str = models.StringField()
    amb_payoff = models.FloatField()
    amb_payoff_str = models.StringField()
    open_comments = models.StringField(label='',
                                       widget=widgets.Textarea,
                                       blank=True)

    # == FUNCTIONS == #
    # == Assign first period default choices from CEO letter to production input variables == #
    def first_period_to_vars(self):
        self.type = self.type1
        self.cotton = self.cotton1
        self.price = self.price1
        self.social_action = self.social_action1

    def first_period_to_vars_board(self):
        self.type_b = self.type1
        self.cotton_b = self.cotton1
        self.price_b = self.price1
        self.social_action_b = self.social_action1

    # == Set random numbers for board blocking functions, map board condition choices to round earning choices== #
    def initialize_board_calcs(self):
        self.rand_num = random.randint(0, 100)
        self.type = self.type_b
        self.cotton = self.cotton_b
        self.price = self.price_b
        self.social_action = self.social_action_b

    # == After gathering pre_decision_earnings, assign new choices if board blocks. == #
    def board_decision(self):
        if self.social_action_b == 'No Action' or self.rand_num > Constants.board_deny_threshold:
            self.board_block = "Did Not Block"
            self.board_penalty = "No penalty"
        else:
            self.board_block = "Blocked"
            self.board_penalty = "A $1.00 penalty"
            self.type = 'Sweater Vest'
            self.cotton = 80
            self.price = 49
            self.social_action = 'No Action'

    # == Determine if participant chose optimal input given donation action == #
    def determine_type_match(self):
        self.t_match1 = (self.type == "Sweater Vest")
        self.t_match2 = (self.type == "Turtleneck")
        self.t_match3 = (self.type == "Cardigan")
        self.d_match1 = (self.social_action == 'No Action')
        self.d_match2 = (self.social_action == 'Donate 10% of Period Earnings')
        self.match1 = (self.t_match1 == self.d_match1)
        self.match2 = (self.t_match2 == self.d_match2)
        self.match3 = (self.t_match3 == self.d_match3)

    # == Determine payoffs by input bundle (Creates profit landscape) == #
    def determine_round_earnings(self):
        if self.social_action == 'No Action' and self.type == 'Sweater Vest':
            self.round_earnings = round(max(Constants.max_pi[0] - \
                          abs(Constants.opt_values[0, 0] - self.cotton) / 10.0 * Constants.penalty[1, 0] - \
                          abs(Constants.opt_values[1, 0] - self.price) / 10.0 * Constants.penalty[2, 0],
                                            Constants.min_value), 2)

        elif self.social_action == 'No Action' and self.type != 'Sweater Vest':
            self.round_earnings = round(max(Constants.max_pi[0] - Constants.penalty[0, 0] - \
                          abs(Constants.opt_values[0, 0] - self.cotton) / 10.0 * Constants.penalty[1, 0] - \
                          abs(Constants.opt_values[1, 0] - self.price) / 10.0 * Constants.penalty[2, 0],
                                            Constants.min_value), 2)

        elif self.social_action == 'Donate 10% of Period Earnings' and self.type == 'Sweater Vest':
            self.round_earnings = round(max(Constants.max_pi[0] - Constants.penalty[0, 2] - \
                          abs(Constants.opt_values[0, 0] - self.cotton) / 10.0 * Constants.penalty[1, 0] - \
                          abs(Constants.opt_values[1, 0] - self.price) / 10.0 * Constants.penalty[2, 0],
                                            Constants.min_value), 2)

        elif self.social_action == 'Donate 10% of Period Earnings' and self.type == 'Turtleneck':
            self.round_earnings = round(max(Constants.max_pi[1] - \
                          abs(Constants.opt_values[0, 1] - self.cotton) / 10.0 * Constants.penalty[1, 1] - \
                          abs(Constants.opt_values[1, 1] - self.price) / 10.0 * Constants.penalty[2, 1],
                                            Constants.min_value), 2)

        elif self.social_action == "Donate 10% of Period Earnings" and self.type == 'Cardigan':
            self.round_earnings = round(max(Constants.max_pi[2] - \
                          abs(Constants.opt_values[0, 2] - self.cotton) / 10.0 * Constants.penalty[1, 2] - \
                          abs(Constants.opt_values[1, 2] - self.price) / 10.0 * Constants.penalty[2, 2],
                                            Constants.min_value), 2)

        # self.round_earnings_init = round(self.round_earnings, 2) <-- DO I NEED THIS??

    # == Set pre-board decision earnings == #
    def set_pre_decision_earnings(self):
        self.pre_decision_earnings = self.round_earnings - (
            self.round_earnings * Constants.donation_pct)

    # == Adjust payoff for board decision or reputation, depending on condition == #
    def board_adjust(self):
        if self.board_block == 'Blocked':
            self.round_earnings = Constants.orig_value - Constants.min_value
        else:
            self.round_earnings = self.round_earnings

    def reputation_adjust(self):
        if self.participant.vars['condition'] == 'Reputation':
            if self.social_action != 'No Action':
                self.participant.vars['social_action_count'] += 1
            else:
                self.participant.vars[
                    'social_action_count'] = self.participant.vars[
                        'social_action_count']
        else:
            self.round_earnings = self.round_earnings

        if self.social_action == 'No Action':
            self.round_earnings = max(
                (self.round_earnings -
                 (Constants.reputation_penalty *
                  self.participant.vars['social_action_count']), 0.00))
        else:
            self.round_earnings = self.round_earnings

    # == Calculate donation if stance taken == #
    def donation_calculate(self):
        if self.social_action == 'Donate 10% of Period Earnings':
            self.donation = round(
                (self.round_earnings * Constants.donation_pct), 2)
            self.round_earnings = self.round_earnings - self.donation
        else:
            self.donation = 0.00

    # == Create string variables so currencies will display on results pages == #
    def string_convert(self):
        self.round_earnings_str = '{:,.2f}'.format(self.round_earnings)
        self.round_donation_str = '{:,.2f}'.format(self.donation)

    # == Calculate payoffs and create strings for final display == #
    def set_payoffs(self):
        if self.subsession.round_number == self.participant.vars[
                'paying_round_a']:
            self.payoff_a = round(self.round_earnings / 2, 2)
            self.payoff = self.payoff_a
            self.payoff_a_str = '{:,.2f}'.format(self.payoff_a)
            self.participant.vars['payoff_a'] = self.payoff_a_str
            self.donation = round(self.donation / 2, 2)
        else:
            pass

        if self.subsession.round_number == self.participant.vars[
                'paying_round_b']:
            self.payoff_b = round(self.round_earnings / 2, 2)
            self.payoff = self.payoff + self.payoff_b
            self.payoff_b_str = '{:,.2f}'.format(self.payoff_b)
            self.participant.vars['payoff_b'] = self.payoff_b_str
            self.donation = round(self.donation / 2, 2)
        else:
            pass

        if self.subsession.round_number == self.participant.vars['paying_round_a'] \
                or self.subsession.round_number == self.participant.vars['paying_round_b']:
            self.donation = self.donation
        else:
            self.donation = 0

    def extra_payments(self):
        risk = random.choice(
            [self.risk1, self.risk2, self.risk3, self.risk4, self.risk5])
        risk_dict = {
            self.risk1: 0.35,
            self.risk2: 0.30,
            self.risk3: 0.25,
            self.risk4: 0.20,
            self.risk5: 0.15
        }
        amb = random.choice([
            self.amb1, self.amb2, self.amb3, self.amb4, self.amb5, self.amb6,
            self.amb7
        ])
        amb_dict = {
            self.amb1: 80,
            self.amb2: 70,
            self.amb3: 60,
            self.amb4: 50,
            self.amb5: 40,
            self.amb6: 30,
            self.amb7: 20
        }
        rand1 = random.randint(0, 100)
        rand2 = random.randint(0, 100)

        # == Risk Aversion Payoffs == #
        if risk == '$10 with probability 50%, $2 with probability 50%':
            if rand1 > 50:
                self.payoff = self.payoff + 0.50
                self.risk_payoff = 0.50
            else:
                self.risk_payoff = 0.10
                self.payoff = self.payoff + 0.10
        else:
            self.risk_payoff = risk_dict[risk]
            self.payoff = self.payoff + self.risk_payoff

        # == Ambiguity Aversion Payoffs == #
        if amb == 'Bag 2 (containing 20 balls)':
            if rand1 > rand2:
                self.payoff = self.payoff + 0.50
                self.amb_payoff = 0.50
            else:
                self.payoff = self.payoff + 0.10
                self.amb_payoff = 0.10
        else:
            amb_val = amb_dict[amb]
            if amb_val > rand2:
                self.payoff = self.payoff + 0.50
                self.amb_payoff = 0.50
            else:
                self.payoff = self.payoff + 0.10
                self.amb_payoff = 0.10

        self.risk_payoff_str = '{:,.2f}'.format(self.risk_payoff)
        self.participant.vars['risk_payoff'] = self.risk_payoff_str
        self.amb_payoff_str = '{:,.2f}'.format(self.amb_payoff)
        self.participant.vars['amb_payoff'] = self.amb_payoff_str
예제 #18
0
class Player(BasePlayer):
    # Results / Payoffs
    investment_1 = models.CurrencyField(initial=None)
    investment_2 = models.CurrencyField(initial=None)
    investment_3 = models.CurrencyField(initial=None)
    investment_4 = models.CurrencyField(initial=None)

    lot_1_p = models.CurrencyField(initial=None)
    lot_2_p = models.CurrencyField(initial=None)
    lot_3_p = models.CurrencyField(initial=None)
    lot_4_p = models.CurrencyField(initial=None)

    lot_1_s = models.BooleanField(initial=None)
    lot_2_s = models.BooleanField(initial=None)
    lot_3_s = models.BooleanField(initial=None)
    lot_4_s = models.BooleanField(initial=None)

    sum_lot_p = models.CurrencyField(initial=None)
    sum_lot = models.CurrencyField(initial=None)
    sum_lot_chf = models.DecimalField(max_digits=5, decimal_places=2)

    # participant id
    code = models.StringField(
        label='personal identity code:',
        blank=False,
        max_length=6,
    )

    # demographic questionnaire
    education = models.IntegerField(
        label=
        'What is the highest level of school you have completed or the highest degree you have received?',
        choices=[[1, 'less than high school degree'],
                 [2, 'high school degree or equivalent (e.g., GED)'],
                 [3, 'Some college but no degree'], [4, 'Associate degree'],
                 [5, 'Bachelor degree'], [6, 'Graduate degree'],
                 [0, 'Prefer not to say']],
    )

    subject = models.IntegerField(label='What subject did you study?')

    def subject_choices(self):
        import random
        choices_end = [[99, 'other'], [0, 'Prefer not to say']]
        choices_shuffle = [[1, 'Business'], [2, 'Medicine'], [3, 'Law'],
                           [4, 'Arts'], [5, 'Social Science'], [6, 'Science']]
        random.shuffle(choices_shuffle)
        choices = choices_shuffle + choices_end
        return choices

    statistics = models.IntegerField(
        label='Did you ever take a statistic course?',
        choices=[[1, 'Yes'], [0, 'No']],
        widget=widgets.RadioSelect,
    )

    stocks = models.IntegerField(
        label='Have you ever traded stocks?',
        choices=[[1, 'Yes'], [0, 'No']],
        widget=widgets.RadioSelect,
    )

    gamble = models.IntegerField(
        label=
        'Have you played any games of chance in the last 12 months (e.g. online, at the casino)?',
        choices=[[1, 'Yes'], [0, 'No']],
        widget=widgets.RadioSelect
        #alternativ: How often do you gamble (e.g. online, at the casino)?'
    )

    # feedback questionnaire
    check_instructions = models.IntegerField(
        label='Wie verständlich waren für Sie die Instruktionen?',
        choices=[[4, 'sehr verständlich'], [3, 'eher verständlich'],
                 [2, 'eher unverständlich'], [1, 'unverständlich']],
        widget=widgets.RadioSelectHorizontal)

    # open comments:
    check_goal = models.StringField(
        label='What do you think is the purpose of this study?', blank=True)

    comment = models.LongStringField(label='Do you have any further comments?',
                                     blank=True)

    pass
class Player(BasePlayer):
    answer_q01 = models.IntegerField()
    answer_q02 = models.IntegerField()
    start_time0 = models.FloatField()
    elapsed_time0 = models.FloatField()
    count0 = models.IntegerField()
    is_correct0 = models.BooleanField()
    score = models.DecimalField(max_digits=5, decimal_places=2)

    test_matrix1 = models.IntegerField(widget=widgets.RadioSelectHorizontal,
                                       choices=[[0, 'yes'], [1, 'no']])

    test_matrix2 = models.IntegerField(widget=widgets.RadioSelectHorizontal,
                                       choices=[[0, 'yes'], [1, 'no']])
    answer_q11 = models.IntegerField()
    answer_q12 = models.IntegerField()
    start_time1 = models.FloatField()
    elapsed_time1 = models.FloatField()
    is_correct1 = models.BooleanField()
    count1 = models.IntegerField()
    score1 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q21 = models.IntegerField()
    answer_q22 = models.IntegerField()
    start_time2 = models.FloatField()
    elapsed_time2 = models.FloatField()
    is_correct2 = models.BooleanField()
    count2 = models.IntegerField()
    score2 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q31 = models.IntegerField()
    answer_q32 = models.IntegerField()
    start_time3 = models.FloatField()
    elapsed_time3 = models.FloatField()
    is_correct3 = models.BooleanField()
    count3 = models.IntegerField()
    score3 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q41 = models.IntegerField()
    answer_q42 = models.IntegerField()
    start_time4 = models.FloatField()
    elapsed_time4 = models.FloatField()
    is_correct4 = models.BooleanField()
    count4 = models.IntegerField()
    score4 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q51 = models.IntegerField()
    answer_q52 = models.IntegerField()
    start_time5 = models.FloatField()
    elapsed_time5 = models.FloatField()
    is_correct5 = models.BooleanField()
    count5 = models.IntegerField()
    score5 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q61 = models.IntegerField()
    answer_q62 = models.IntegerField()
    start_time6 = models.FloatField()
    elapsed_time6 = models.FloatField()
    is_correct6 = models.BooleanField()
    count6 = models.IntegerField()
    score6 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q71 = models.IntegerField()
    answer_q72 = models.IntegerField()
    start_time7 = models.FloatField()
    elapsed_time7 = models.FloatField()
    is_correct7 = models.BooleanField()
    count7 = models.IntegerField()
    score7 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q81 = models.IntegerField()
    answer_q82 = models.IntegerField()
    start_time8 = models.FloatField()
    elapsed_time8 = models.FloatField()
    is_correct8 = models.BooleanField()
    count8 = models.IntegerField()
    score8 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q91 = models.IntegerField()
    answer_q92 = models.IntegerField()
    start_time9 = models.FloatField()
    elapsed_time9 = models.FloatField()
    is_correct9 = models.BooleanField()
    count9 = models.IntegerField()
    score9 = models.DecimalField(max_digits=5, decimal_places=2)

    answer_q101 = models.IntegerField()
    answer_q102 = models.IntegerField()
    start_time10 = models.FloatField()
    elapsed_time10 = models.FloatField()
    is_correct10 = models.BooleanField()
    count10 = models.IntegerField()
    score10 = models.DecimalField(max_digits=5, decimal_places=2)

    matrix_payoff0 = models.CurrencyField()
    matrix_payoff = models.CurrencyField()
    avg_score = models.DecimalField(max_digits=5, decimal_places=1)

    def set_payoff0(self):
        self.matrix_payoff0 = max(round(90 - self.elapsed_time0, 2), 0) / 60
        self.participant.vars['matrix_payoff0'] = self.matrix_payoff0

    def set_payoff(self):
        self.payoff = (max(round(90 - self.elapsed_time9, 2), 0)) / 60
        self.participant.vars['matrix_payoff'] = self.payoff

    def set_time9(self):
        self.participant.vars['t9'] = self.elapsed_time9

    def set_avg_score(self):
        self.avg_score = str(
            round((Decimal(self.participant.vars['score1']) +
                   Decimal(self.participant.vars['score2']) +
                   Decimal(self.participant.vars['score3']) +
                   Decimal(self.participant.vars['score4']) +
                   Decimal(self.participant.vars['score5']) +
                   Decimal(self.participant.vars['score6']) +
                   Decimal(self.participant.vars['score7']) +
                   Decimal(self.participant.vars['score8']) +
                   Decimal(self.participant.vars['score9']) +
                   Decimal(self.participant.vars['score10'])) *
                  Decimal(repr(0.1)), 2))
        self.participant.vars['avg_score'] = self.avg_score

    def check_correct0(self):
        newlist0 = (self.answer_q01, self.answer_q02)
        self.is_correct0 = any(
            x not in newlist0
            for x in [Constants.solution_q01, Constants.solution_q02])

    def check_correct1(self):
        newlist1 = (self.answer_q11, self.answer_q12)
        self.is_correct1 = any(
            x not in newlist1
            for x in [Constants.solution_q11, Constants.solution_q12])

    def check_correct2(self):
        newlist2 = (self.answer_q21, self.answer_q22)
        self.is_correct2 = any(
            x not in newlist2
            for x in [Constants.solution_q21, Constants.solution_q22])

    def check_correct3(self):
        newlist3 = (self.answer_q31, self.answer_q32)
        self.is_correct3 = any(
            x not in newlist3
            for x in [Constants.solution_q31, Constants.solution_q32])

    def check_correct4(self):
        newlist4 = (self.answer_q41, self.answer_q42)
        self.is_correct4 = any(
            x not in newlist4
            for x in [Constants.solution_q41, Constants.solution_q42])

    def check_correct5(self):
        newlist5 = (self.answer_q51, self.answer_q52)
        self.is_correct5 = any(
            x not in newlist5
            for x in [Constants.solution_q51, Constants.solution_q52])

    def check_correct6(self):
        newlist6 = (self.answer_q61, self.answer_q62)
        self.is_correct6 = any(
            x not in newlist6
            for x in [Constants.solution_q61, Constants.solution_q62])

    def check_correct7(self):
        newlist7 = (self.answer_q71, self.answer_q72)
        self.is_correct7 = any(
            x not in newlist7
            for x in [Constants.solution_q71, Constants.solution_q72])

    def check_correct8(self):
        newlist8 = (self.answer_q81, self.answer_q82)
        self.is_correct8 = any(
            x not in newlist8
            for x in [Constants.solution_q81, Constants.solution_q82])

    def check_correct9(self):
        newlist9 = (self.answer_q91, self.answer_q92)
        self.is_correct9 = any(
            x not in newlist9
            for x in [Constants.solution_q91, Constants.solution_q92])

    def check_correct10(self):
        newlist10 = (self.answer_q101, self.answer_q102)
        self.is_correct10 = any(
            x not in newlist10
            for x in [Constants.solution_q101, Constants.solution_q102])
예제 #20
0
class Player(BasePlayer):
    cost = models.FloatField(doc='personal cost for entry')
    participant_vars_dump = models.StringField(doc='to store participant vars')
    payoff_forecasting = models.DecimalField(initial=0,
                                             doc='payoff for forecasting',
                                             decimal_places=2,
                                             max_digits=10)
    payoff_entry = models.DecimalField(
        initial=0,
        doc='payoff for entry in the previous round',
        decimal_places=2,
        max_digits=10)
    paying_round_f = models.IntegerField(doc='round to pay for forecasting')
    paying_round_e = models.IntegerField(doc='round to pay for entry')
    temp_payoff = models.DecimalField(initial=0,
                                      doc='temporary payoff in round',
                                      decimal_places=2,
                                      max_digits=10)
    e_price_next = models.DecimalField(
        min=0,
        max=Constants.max_price,
        doc='expected price for next round',
        verbose_name='Predict the price in the next round',
        decimal_places=2,
        max_digits=10,
    )
    e_price_now = models.DecimalField(
        min=0,
        max=Constants.max_price,
        doc='expected price for current round',
        verbose_name='Predict the price in this round',
        decimal_places=2,
        max_digits=10)
    participation = models.BooleanField(choices=[(False, 'No'), (True, 'Yes')],
                                        widget=widgets.RadioSelect)

    def previous_expected(self):
        if self.round_number == 1:
            expected_price = round(self.e_price_now, 2)
        else:
            expected_price = round(
                self.in_round(self.round_number - 1).e_price_next, 2)
        return expected_price

    def get_prec(self):
        if self.group.total_participation is not None:
            participation_rate = "{0:.0f}%".format(
                self.group.total_participation * 100)
        else:
            participation_rate = None
        record = PRec(
            round_number=self.round_number,
            expected_price=self.previous_expected(),
            price=self.group.price,
            participation_rate=participation_rate,
            ego_participation=self.participation,
            payoff=self.temp_payoff,
        )
        return record

    # calculation of payoff for the participation in the previous round:
    def set_entry_payoff(self):
        if self.round_number == 1:
            return 0
        p = self.in_round(self.round_number - 1)
        price_t_2 = self.group.price
        price_t = p.group.price
        r = Constants.R
        mu = Constants.mu
        e = p.participation
        d = Constants.d
        k = self.cost
        if e is None:
            return 0
        if e == 0:
            ep = e * (price_t_2 + mu - r * price_t + d - k)
        else:
            ep = d
        self.payoff_entry = ep

    def set_forecasting_payoff(self):
        c = Constants.c
        p_t = self.group.price
        if self.round_number > 1:
            p = self.in_round(self.round_number - 1)
            e_pt1 = float(p.e_price_next)
        else:
            e_pt1 = float(p_t)
        e_pt2 = float(self.e_price_now)
        fp = c / (1 + abs(p_t - e_pt1) + abs(p_t - e_pt2))
        self.payoff_forecasting = fp

    def set_payoff(self):
        # we set final payoff only in the last round! (It's a bit absurd that we check for this condition
        # the THIRD time in a row but it's better be safe)
        if self.round_number == Constants.num_rounds:
            same_ef_round = self.session.config.get(
                'simultaneous_ef_payment', Constants.simultaneous_ef_payment)
            participation_stage = self.subsession.participation_stage
            if same_ef_round:
                self.paying_round_e = self.paying_round_f = random.randint(
                    1, Constants.num_rounds)
                self.payoff = self.in_round(
                    self.paying_round_f).payoff_forecasting
                if participation_stage:
                    self.payoff += self.in_round(
                        self.paying_round_f).payoff_entry
            else:
                self.paying_round_e, self.paying_round_f = random.sample(
                    range(1, Constants.num_rounds + 1), 2)
                if participation_stage:
                    self.payoff = self.in_round(
                        self.paying_round_f
                    ).payoff_forecasting + self.in_round(
                        self.paying_round_e).payoff_entry
                else:
                    self.payoff = float(
                        self.in_round(
                            self.paying_round_f).payoff_forecasting) + float(
                                self.in_round(
                                    self.paying_round_e).payoff_forecasting)

        else:
            self.payoff = 0
예제 #21
0
파일: models.py 프로젝트: pv77uck3r/oTree
class Player(BasePlayer):

    Innovate = models.BooleanField(widget=widgets.CheckboxInput, blank=True)

    NoInnovate = models.BooleanField(widget=widgets.CheckboxInput, blank=True)

    InnovateorImitateButton = models.DecimalField(max_digits=3,
                                                  decimal_places=0,
                                                  min=0,
                                                  max=100,
                                                  blank=True)

    Draw = models.FloatField(initial=0)
    payout = models.FloatField(initial=0)

    def InnovateRoll(self):
        if self.Innovate == True:
            self.InnovateorImitateButton = 100
        if self.NoInnovate == True:
            self.InnovateorImitateButton = 0
        if (self.subsession.SuperRound == 1 and self.InnovateorImitateButton >= self.session.vars['randomroll'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 2 and self.InnovateorImitateButton >= self.session.vars['randomroll2'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 3 and self.InnovateorImitateButton >= self.session.vars['randomroll3'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 4 and self.InnovateorImitateButton >= self.session.vars['randomroll4'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 5 and self.InnovateorImitateButton >= self.session.vars['randomroll5'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 6 and self.InnovateorImitateButton >= self.session.vars['randomroll6'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 7 and self.InnovateorImitateButton >= self.session.vars['randomroll7'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 8 and self.InnovateorImitateButton >= self.session.vars['randomroll8'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 9 and self.InnovateorImitateButton >= self.session.vars['randomroll9'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 10 and self.InnovateorImitateButton >= self.session.vars['randomroll10'][(self.subsession.round_number - 1)%Constants.num_players]*100):
            self.Draw = round(
                np.random.triangular(self.subsession.trianglea,
                                     self.subsession.trianglemode,
                                     self.subsession.triangleb), 2)
        else:
            self.Draw = round(self.subsession.OldHighDraw, 2)

    def setpayoff(self):
        if self.Innovate == True:
            self.InnovateorImitateButton = 100
        if self.NoInnovate == True:
            self.InnovateorImitateButton = 0
        if (self.subsession.SuperRound == 1 and self.InnovateorImitateButton >= self.session.vars['randomroll'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 2 and self.InnovateorImitateButton >= self.session.vars['randomroll2'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 3 and self.InnovateorImitateButton >= self.session.vars['randomroll3'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 4 and self.InnovateorImitateButton >= self.session.vars['randomroll4'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 5 and self.InnovateorImitateButton >= self.session.vars['randomroll5'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 6 and self.InnovateorImitateButton >= self.session.vars['randomroll6'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 7 and self.InnovateorImitateButton >= self.session.vars['randomroll7'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 8 and self.InnovateorImitateButton >= self.session.vars['randomroll8'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 9 and self.InnovateorImitateButton >= self.session.vars['randomroll9'][(self.subsession.round_number - 1)%Constants.num_players]*100)\
                or (self.subsession.SuperRound == 10 and self.InnovateorImitateButton >= self.session.vars['randomroll10'][(self.subsession.round_number - 1)%Constants.num_players]*100):
            self.payout = round(self.Draw, 2)
        if (self.subsession.SuperRound == 1 and self.InnovateorImitateButton < self.session.vars['randomroll'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 2 and self.InnovateorImitateButton < self.session.vars['randomroll2'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 3 and self.InnovateorImitateButton < self.session.vars['randomroll3'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 4 and self.InnovateorImitateButton < self.session.vars['randomroll4'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 5 and self.InnovateorImitateButton < self.session.vars['randomroll5'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 6 and self.InnovateorImitateButton < self.session.vars['randomroll6'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 7 and self.InnovateorImitateButton < self.session.vars['randomroll7'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 8 and self.InnovateorImitateButton < self.session.vars['randomroll8'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 9 and self.InnovateorImitateButton < self.session.vars['randomroll9'][(self.subsession.round_number - 1) % Constants.num_players] * 100) \
                or (self.subsession.SuperRound == 10 and self.InnovateorImitateButton < self.session.vars['randomroll10'][(self.subsession.round_number - 1) % Constants.num_players] * 100):
            self.payout = round(self.Draw, 2) + Constants.endowment
        if self.subsession.SuperRound == self.session.vars['randompayround']:
            self.participant.vars['ExpEarnings'] = self.payout

    def retainDraws(self):
        if (self.subsession.round_number - 1) % Constants.num_players + 1 == 1:
            self.Draw = 0
        else:
            self.Draw = self.in_round((self.subsession.round_number - 1)).Draw

    def retainPayoffs(self):
        if (self.subsession.round_number - 1) % Constants.num_players + 1 == 1:
            self.payout = 0
        else:
            self.payout = self.in_round(
                (self.subsession.round_number - 1)).payout
예제 #22
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'])

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

    plays = models.BooleanField(
        doc=
        'Determines if the player is allowed to play the guessing game in a particular round.',
        default=True)
    #TODO: this app is entirely 'only' treatment. But keep this s. t. there is an indicator in the database
    treatment = models.CharField(
        doc=
        'Defines the treatment of the session. The treatment is the same for all players in one session'
    )

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

    #### Breakpoint in Transission round
    breakpoint = models.IntegerField(blank=False,
                                     doc='Breakpoint',
                                     verbose_name="")

    ######################################################################################################################
    ### Control Variables

    ##how often did the participant try to submit the control questions when some answers were still wrong
    # if the participant was correct on the first try, than this will be 1
    control_tries = models.IntegerField(
        initial=0,
        doc=
        "How often did the player try to submit the control questions page when answers were still wrong. \
                                                          1 if the player had everything correct on the first try."
    )

    # only + nosanction + exlude + dislike + punish
    control1 = models.IntegerField(
        verbose_name=
        "Wie viele Taler haben Sie auf Ihrem privaten Konto, wenn Sie 3 Taler auf das Gruppenkonto einzahlen?",
        min=0)

    # only + nosanction + exlude + dislike + punish
    control2 = models.IntegerField(
        verbose_name=
        "20 Taler wurden insgesamt in das Gruppenkonto eingezahlt. Wie viele Taler erhalten Sie am Ende aus dem Gruppenkonto?",
        min=0)

    # only + nosanction + exlude + dislike + punish
    control3a = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Es kann sein, dass verschiedene Gruppenmitglieder unterschiedlich viele Taler aus dem Gruppenkonto erhalten.",
        choices=["wahr", "falsch"])

    # only + nosanction + exlude + dislike + punish
    control3b = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Am Ende der ersten Stufe einer jeweiligen Runde wissen Sie, wie viel jedes Gruppenmitglied ins Gruppenkonto eingezahlt hat.",
        choices=["wahr", "falsch"])

    # only + nosanction + exlude + dislike + punish
    control3c = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name=
        "Sie spielen in jeder Runde in einer neuen Gruppe mit anderen Personen",
        choices=["wahr", "falsch"])

    ####################################################################################################################
    ###  Questionnaire1
    q1 = models.IntegerField(
        verbose_name=
        "Was denken Sie, wie viele Taler sollte man zum Gruppenkonto beitragen?",
        min=0,
        max=10)
    q2 = models.StringField(
        widget=widgets.RadioSelect(),
        verbose_name="Denken Sie, die meisten anderen sehen das auch wie Sie?",
        choices=[
            "Ja",
            "Ich bin mir unsicher",
            "Nein, die meisten anderen denken man sollte mehr beitragen",
            "Nein, die meisten anderen denken man sollte weniger beitragen",
        ])
    ####################################################################################################################
    ###  Questionnaire2
    q5 = models.IntegerField(verbose_name="Bitte geben Sie Ihr Alter an",
                             min=0,
                             max=99)
    q7 = models.StringField(verbose_name="Bitte geben Sie Ihr Studienfach an")
    q8 = models.IntegerField(
        min=0,
        verbose_name=
        "Wie oft haben Sie bereits an einer ökonomischen Laborstudie teilgenommen (auch außerhalb dieses Labors)?"
    )
    q9 = models.StringField(
        verbose_name=
        "Wie viele Teilnehmerinnen oder Teilnehmer in diesem Raum haben Sie schon vor dem Experiment gekannt?"
    )
    q10 = models.StringField(
        verbose_name=
        "Möchten Sie uns noch etwas mitteilen? Hier ist die Gelegenheit dazu!",
        blank=True)

    ####################################################################################################################

    payround = models.IntegerField(
        doc=
        "The round number that will be payed out for the player. Note: this is an oTree round e. g. experiment_round+1."
    )

    ####################################################################################################################
    ### FamilyFeud
    # does the player play the bonus FF round after all rounds of the experiment according to the evaluation mechanism
    # depends on the valuationFF results
    plays_bonusFF = models.BooleanField(
        initial=True,
        doc=
        "This determines if the player plays the bonus guessing game round at the end of the experiment. \
                                                This is true if the players willingness to pay (ff_valuation) is higher than the computer (number random_ff_valuation)"
    )

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

    # the willingness to pay for the bonus family feud round
    ff_valuation = models.DecimalField(
        verbose_name=
        "Bitte klicken Sie auf die Skala, um Ihre Zahlungsbereitschaft auszuwählen.",
        widget=widgets.Slider(show_value=False),
        min=0,
        max=6,
        decimal_places=1,
        max_digits=2,
        doc=
        "The players' willingness to pay for the bonus round of the guessing game.",
        initial=0)

    random_ff_valuation = models.FloatField(
        doc=
        "The computer number which will be to compared with ff_valuation to determine if the player plays the bonus round.",
        initial=0.0)

    # Number of correctly answered questions
    ff_points = models.IntegerField(
        initial=0,
        doc=
        "The number of correct answers which the player found overall in the guessing game in one round."
    )

    # Number of tries (guesses) of a player
    num_guesses = models.IntegerField(initial=0)

    def inc_num_guesses(self):
        self.num_guesses += 1
        self.save()

    def inc_ff_points(self):
        self.ff_points += 1
        self.save()

    def initial_decision(self):
        return 0.5
예제 #23
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
예제 #24
0
파일: models.py 프로젝트: emadRad/svo
class Player(BasePlayer):

    # input_self_1 represents the amount of money that the user has chosen for himself for the first item
    # input_other_1 represents the amount of money that the user has chosen for others for the first item.
    input_self_1 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_1 = models.DecimalField(max_digits=5, decimal_places=2)

    # Same as above but for item 2 in the paper
    input_self_2 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_2 = models.DecimalField(max_digits=5, decimal_places=2)

    # Same as above but for item 3 in the paper
    input_self_3 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_3 = models.DecimalField(max_digits=5, decimal_places=2)

    # Same as above but for item 2 in the paper and so on.
    input_self_4 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_4 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_5 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_5 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_6 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_6 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_7 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_7 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_8 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_8 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_9 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_9 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_10 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_10 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_11 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_11 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_12 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_12 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_13 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_13 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_14 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_14 = models.DecimalField(max_digits=5, decimal_places=2)

    input_self_15 = models.DecimalField(max_digits=5, decimal_places=2)
    input_other_15 = models.DecimalField(max_digits=5, decimal_places=2)

    # order of item 1 in RANDOM order
    random_order1 = models.IntegerField(initial=-1)
    random_order2 = models.IntegerField(initial=-1)
    random_order3 = models.IntegerField(initial=-1)
    random_order4 = models.IntegerField(initial=-1)
    random_order5 = models.IntegerField(initial=-1)
    random_order6 = models.IntegerField(initial=-1)
    random_order7 = models.IntegerField(initial=-1)
    random_order8 = models.IntegerField(initial=-1)
    random_order9 = models.IntegerField(initial=-1)
    random_order10 = models.IntegerField(initial=-1)
    random_order11 = models.IntegerField(initial=-1)
    random_order12 = models.IntegerField(initial=-1)
    random_order13 = models.IntegerField(initial=-1)
    random_order14 = models.IntegerField(initial=-1)
    random_order15 = models.IntegerField(initial=-1)

    svo_angle = models.DecimalField(max_digits=7, decimal_places=2)
    svo_type = models.CharField(
        choices=['Altruist', 'Prosocial', 'Individualist', 'Competitive'])
    inequality_aversion_score = models.DecimalField(max_digits=7,
                                                    decimal_places=2)

    # slider selected for payment as sender
    paid_slider = models.IntegerField(initial=-1)

    # slider selected for payment as receiver for matching=RING
    slider_as_receiver = models.IntegerField(initial=-1)

    # amount kept by the sender
    kept_of_sender = models.DecimalField(max_digits=5, decimal_places=2)

    # amount received from the sender
    received_from_sender = models.DecimalField(max_digits=5, decimal_places=2)
    '''
    random dictator matching
          is_sender=True : the player was a sender
          is_receiver=True : the player was a receiver
    ring matching 
        both values will be True      
    '''
    is_sender = models.BooleanField(initial=False)
    is_receiver = models.BooleanField(initial=False)
예제 #25
0
class Group(BaseGroup):
    # define vars

    a_task_income = models.DecimalField(max_digits=5, decimal_places=2)
    b_task_income = models.CurrencyField()
    discard = models.BooleanField()

    treatment = models.TextField()
    value_type = models.TextField()
    elicitation_method = models.TextField()
    BDM_type = models.TextField()
    BDM_lolimit = models.TextField()
    BDM_uplimit = models.TextField()
    BDM_list_step = models.DecimalField(max_digits=5, decimal_places=2)
    SOP_price = models.CurrencyField()

    take_rate = models.DecimalField(
        widget=widgets.HiddenInput(), max_digits=5, decimal_places=0, min=0, max=100)
    expected_take_rate = models.DecimalField(
        widget=widgets.HiddenInput(), max_digits=5, decimal_places=0, min=0, max=100)
    money_taken = models.CurrencyField()
    want_send_message = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)

    b_message = models.TextField(blank=True, initial="")
    b_value = models.CurrencyField(min=c(0), blank=True)

    message_price = models.CurrencyField()
    msg_sent = models.BooleanField(initial=0)
    SOP_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal())

    price_list_size = models.IntegerField()
    # below code moved to before session starts
    '''
    # create BDM List prices - It generates as many variables list_price_{0} as Constants.max_price_list_size
    for i in range(0, Constants.max_price_list_size):
        locals()['list_price_{0}_yes'.format(i)] = models.CharField(
            choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank = True)

    # create BDM compensation amount - It generates as many variables list_price_{0} as Constants.max_price_list_size
    for i in range(0, Constants.max_price_list_size):
        locals()['list_compensation_{0}'.format(i)] = models.CharField(choices=[
               'Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank = True)
    '''
    # low tech solutions because the for loops wouldn't work
    list_price_0_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_1_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_2_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_3_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_4_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_5_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_6_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_7_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_8_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_9_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_10_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_11_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_12_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_13_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_14_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_15_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_16_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_17_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_18_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_price_19_yes = models.CharField(
        choices=['Yes', 'No'], widget=widgets.RadioSelectHorizontal(), blank=True)

    list_compensation_0 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_1 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_2 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_3 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_4 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_5 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_6 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_7 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_8 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_9 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_10 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_11 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_12 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_13 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_14 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_15 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_16 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_17 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_18 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)
    list_compensation_19 = models.CharField(
        choices=['Send message', 'Receive'], widget=widgets.RadioSelectHorizontal(), blank=True)

    # create vars for timestamps
    time_ADecides = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_BPredicts = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_ATakeResults = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    # time_BTakeResults = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    # time_WriteMessage = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

    time_AllFmNm = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_AllBdmCont = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_AllBdmList = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_AllSOP = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

    # time_ElicitBdmCont = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    # time_ElicitBdmList = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    # time_ElicitSOP = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

    time_BdmResults = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_DisplayMessageToA = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_DisplayMessagesToR = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

    # this assigns payoff
    def set_payoffs(self):
        for p in self.get_players():
            if p.role() == 'A':
                p.payoff = p.available_income1
            elif p.role() == 'B':
                if p.group.treatment in ['FM', 'NM']:
                    p.payoff = p.available_income1
                elif p.group.treatment in ['DM', 'TP', 'DIS']:
                    p.payoff = p.available_income1 \
                        - (p.group.value_type == 'WTP') * p.group.msg_sent * p.group.message_price \
                        + (p.group.value_type == 'WTA') * \
                        (not p.group.msg_sent) * \
                        p.group.message_price
            elif p.role() == 'R':
                p.payoff = p.available_income0
예제 #26
0
class Player(BasePlayer):
    # you1 represents the amount of money that the user has chosen for himself for the first item
    # others1 represents the amount of money that the user has chosen for others for the first item.
    you1 = models.DecimalField(max_digits=5, decimal_places=2)
    others1 = models.DecimalField(max_digits=5, decimal_places=2)

    # Same as above but for item 2 in the paper
    you2 = models.DecimalField(max_digits=5, decimal_places=2)
    others2 = models.DecimalField(max_digits=5, decimal_places=2)

    # Same as above but for item 3 in the paper
    you3 = models.DecimalField(max_digits=5, decimal_places=2)
    others3 = models.DecimalField(max_digits=5, decimal_places=2)

    # Same as above but for item 2 in the paper and so on.
    you4 = models.DecimalField(max_digits=5, decimal_places=2)
    others4 = models.DecimalField(max_digits=5, decimal_places=2)

    you5 = models.DecimalField(max_digits=5, decimal_places=2)
    others5 = models.DecimalField(max_digits=5, decimal_places=2)

    you6 = models.DecimalField(max_digits=5, decimal_places=2)
    others6 = models.DecimalField(max_digits=5, decimal_places=2)

    you7 = models.DecimalField(max_digits=5, decimal_places=2)
    others7 = models.DecimalField(max_digits=5, decimal_places=2)

    you8 = models.DecimalField(max_digits=5, decimal_places=2)
    others8 = models.DecimalField(max_digits=5, decimal_places=2)

    you9 = models.DecimalField(max_digits=5, decimal_places=2)
    others9 = models.DecimalField(max_digits=5, decimal_places=2)

    you10 = models.DecimalField(max_digits=5, decimal_places=2)
    others10 = models.DecimalField(max_digits=5, decimal_places=2)

    you11 = models.DecimalField(max_digits=5, decimal_places=2)
    others11 = models.DecimalField(max_digits=5, decimal_places=2)

    you12 = models.DecimalField(max_digits=5, decimal_places=2)
    others12 = models.DecimalField(max_digits=5, decimal_places=2)

    you13 = models.DecimalField(max_digits=5, decimal_places=2)
    others13 = models.DecimalField(max_digits=5, decimal_places=2)

    you14 = models.DecimalField(max_digits=5, decimal_places=2)
    others14 = models.DecimalField(max_digits=5, decimal_places=2)

    you15 = models.DecimalField(max_digits=5, decimal_places=2)
    others15 = models.DecimalField(max_digits=5, decimal_places=2)

    # order of item 1 in RANDOM order
    random_order1 = models.IntegerField(initial=-1)
    random_order2 = models.IntegerField(initial=-1)
    random_order3 = models.IntegerField(initial=-1)
    random_order4 = models.IntegerField(initial=-1)
    random_order5 = models.IntegerField(initial=-1)
    random_order6 = models.IntegerField(initial=-1)
    random_order7 = models.IntegerField(initial=-1)
    random_order8 = models.IntegerField(initial=-1)
    random_order9 = models.IntegerField(initial=-1)
    random_order10 = models.IntegerField(initial=-1)
    random_order11 = models.IntegerField(initial=-1)
    random_order12 = models.IntegerField(initial=-1)
    random_order13 = models.IntegerField(initial=-1)
    random_order14 = models.IntegerField(initial=-1)
    random_order15 = models.IntegerField(initial=-1)

    svo_angle = models.DecimalField(max_digits=7, decimal_places=2)
    svo_type = models.CharField(
        choices=['Altruist', 'Prosocial', 'Individualist', 'Competitive'])
    inequality_aversion_score = models.DecimalField(max_digits=7,
                                                    decimal_places=2)

    # slider selected for payment as sender
    paid_slider = models.IntegerField(initial=-1)

    # slider selected for payment as receiver for matching=RING
    slider_as_receiver = models.IntegerField(initial=-1)

    # amount kept by the sender
    kept_of_sender = models.DecimalField(max_digits=5, decimal_places=2)

    # amount received from the sender
    received_from_sender = models.DecimalField(max_digits=5, decimal_places=2)
class Player(BasePlayer):

    Worry = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )

    Nervous = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Relax = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Talkative = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Sociable = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Reserved = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Original = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Artistic = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Active_imagination = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Rude = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Forgiving = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Considerate = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Thorough_job = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Lazy = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )
    Efficient = models.IntegerField(
        widget=widgets.RadioSelectHorizontal,
        choices=[[1, 'Strongly disagree'], [2, 'Disagree'],
                 [3, 'Neither agree nor disagree'], [4, 'Agree'],
                 [5, 'Strongly agree']],
    )

    Neuroticism = models.DecimalField(decimal_places=2, max_digits=5)
    Extraversion = models.DecimalField(decimal_places=2, max_digits=5)
    Openness = models.DecimalField(decimal_places=2, max_digits=5)
    Agreeableness = models.DecimalField(decimal_places=2, max_digits=5)
    Conscientiousness = models.DecimalField(decimal_places=2, max_digits=5)

    def player_info(self):
        self.player_Worry = self.Worry
        self.player_Nervous = self.Nervous
        self.player_Relax = self.Relax
        self.player_Talkative = self.Talkative
        self.player_Sociable = self.Sociable
        self.player_Reserved = self.Reserved
        self.player_Original = self.Original
        self.player_Artistic = self.Artistic
        self.player_Active_imagination = self.Active_imagination
        self.player_Rude = self.Rude
        self.player_Forgiving = self.Forgiving
        self.player_Considerate = self.Considerate
        self.player_Thorough_job = self.Thorough_job
        self.player_Lazy = self.Lazy
        self.player_Efficient = self.Efficient
예제 #28
0
class Player(BasePlayer):
    # Player level data
    vote_weight = models.PositiveIntegerField()
    id_in_round = models.PositiveIntegerField()
    payout = models.PositiveIntegerField()
    payoff_rounds = models.BooleanField()
    final_payout = models.PositiveIntegerField()
    final_us_payout = models.PositiveIntegerField()
    belief_payout = models.PositiveIntegerField()
    followed = models.BooleanField()
    individual_moral_cost = models.BooleanField(
     choices =[
                [0, 'No'],
                [1, 'Yes']
        ]
    )
    vote = models.BooleanField(
        choices = [
            [0, 'Project X will earn you more money than project Y'],
            [1, 'Project Y will earn you more money than project X']
        ]
    )

    belief = models.BooleanField(
        choices=[
            [0, 'No'],
            [1, 'Yes']
        ]
    )
    belief_average = models.DecimalField(min=0, max=30, max_digits=3, decimal_places=1)

    final_decision = models.BooleanField(
        choices=[
            [0, 'Project X'],
            [1, 'Project Y']
        ]
    )

    field = models.CharField()
    age = models.IntegerField(min=18, max=100)
    gender = models.CharField(
        choices=['Male', 'Female'],
        widget=widgets.RadioSelect(),
    )

    def moral_cost(self, project):
        """
        Determine if the player voted in their own interest or in the interest of the decision maker
        """

        if project == 0:
            if self.vote:
                self.individual_moral_cost = False
            else:
                self.individual_moral_cost = True
        elif project == 1:
            if self.vote:
                self.individual_moral_cost = True
            else:
                self.individual_moral_cost = False
        else:
            self.individual_moral_cost = False
예제 #29
0
class Player(BasePlayer):
    # define vars
    endowment = models.CurrencyField()
    participation_fee = models.CurrencyField()

    task_income = models.CurrencyField()
    # before money is taken : endowment plus task income
    available_income0 = models.CurrencyField()
    # after money is taken : endowment plus task income
    number_of_questions = models.IntegerField(initial=6)
    fields_checked = models.IntegerField(initial=-1)
    available_income1 = models.CurrencyField()
    time_Instructions = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_ControlQuestions = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_InitialStage2 = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_RolesIncome = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_Results = models.TextField(
        widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

        ## PTT EXPRESS INSTRUCTIONS FIELDS
    ctrlQ_anonymity = models.CharField(
        verbose_name='Once you are paired with another participant, '
                     'will you ever know the identity of this other participant?',
        choices=['Yes', 'No'],
        widget=widgets.RadioSelectHorizontal())

    ctrlQ_anonymity_err = models.CharField(
        choices=['Yes', 'No'])

    ctrlQ_who_transfers = models.CharField(
        verbose_name='Who decides how much to take from Role B’s account and deposit it into Role A’s account?',
        choices=['Role A', 'Role B', 'Role C', 'Role R', 'None of the above'],
        widget=widgets.RadioSelect())

    ctrlQ_who_transfers_err = models.CharField(
        choices=['Role A', 'Role B', 'Role C', 'Role R', 'None of the above'])

    ctrlQ_B_always_sends = models.CharField(
        verbose_name='Will the participant in Role B always send a message to the participant in Role A '
                     'that he/she is matched with?',
        choices=['Yes', 'No',
                 'It depends on his/her valuation for sending a message'],
        widget=widgets.RadioSelect())

    ctrlQ_B_always_sends_err = models.CharField(
        choices=['Yes', 'No', 'It depends on his/her valuation for sending a message'])

    ctrlQ_B_sends_message = models.CharField(
        verbose_name='Will the message written by Role B be sent in this case?',
        choices=['Yes', 'No'],
        widget=widgets.RadioSelectHorizontal())

    ctrlQ_B_sends_message_err = models.CharField(
        choices=['Yes', 'No'])

    # labels are going to be defying directly in ControlQuestions.html file instead of verbose
    ctrlQ_A_earnings = models.CharField(
        #        verbose_name='What are the final earnings for the participant in Role A? '
        #                     '(Hints: endowment plus task income equals $13.00. Do not include participation fee)',
        choices=['13.00 + X', '13.00 - X', '13.00 - X - Z', '13.00 - X + Z'],
        widget=widgets.RadioSelect())

    ctrlQ_A_earnings_err = models.CharField(
        choices=['13.00 + X', '13.00 - X', '13.00 - X - Z', '13.00 - X + Z'])

    ctrlQ_B_earnings = models.CharField(
        #        verbose_name='What are the final earnings for the participant in Role B? '
        #                    '(Hints: endowment plus task income equals $13.00. Do not include participation fee)',
        choices=['13.00 + X', '13.00 - X', '13.00 - X - Z', '13.00 - X + Z'],
        widget=widgets.RadioSelect())

    ctrlQ_B_earnings_err = models.CharField(
        choices=['13.00 + X', '13.00 - X', '13.00 - X - Z', '13.00 - X + Z'])


    #### SEARCH TASK FIELDS
    maxScreens = models.DecimalField(max_digits=5, decimal_places=2)
    screenTime = models.DecimalField(max_digits=5, decimal_places=2)
    pointDistMin = models.DecimalField(max_digits=5, decimal_places=2)
    pointDistMax = models.DecimalField(max_digits=5, decimal_places=2)

    task_reward = models.DecimalField(max_digits=5, decimal_places=2)
    target_income = models.DecimalField(max_digits=5, decimal_places=2)
    # add timestamps
    time_InitialStage1 = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_GameInstructions = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_PracticeTask = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))
    time_SearchTask = models.TextField(widget=widgets.HiddenInput(attrs={'id': 'arrive_time'}))

    # roles
    def role(self):
        if self.id_in_group == 1 and self.group.treatment != 'TP-R':
            return 'A'
        if self.id_in_group == 2 and self.group.treatment != 'TP-R':
            return 'B'
        if self.group.treatment == 'TP-R':
            return 'R'
    def searchRole(self):
        if self.id_in_group == 1:
            return 'A'
        if self.id_in_group == 2:
            return 'B'

    # gets the id of partner if you are matched, and of him/herself if the player is the reader
    def get_partner(self):
        if self.role() == 'A' or self.role() == 'B':
            return self.get_others_in_group()[0]
        elif self.role() == 'R':
            # OJO reader gets as partner him/herself!
            return self.group.get_player_by_role('R')
예제 #30
0
class Player(BasePlayer):
    # VARIABLES:
    # type of the player: 0 == seller; 1 == buyer
    def role(self):
        if self.id_in_group == 1:
            return 'buyer'
        if self.id_in_group == 2:
            return 'seller'

    # variables for the values
    value = models.DecimalField(max_digits=5, decimal_places=0, default=0)
    # variables for the prices:
    personal_price = models.DecimalField(max_digits=5,
                                         decimal_places=0,
                                         default=0)
    # profit variable
    profit = models.DecimalField(max_digits=5, decimal_places=0, default=0)

    # first order beliefs
    fob = models.IntegerField()
    hit_fob = models.BooleanField(default=False)
    # second order beliefs
    sob = models.IntegerField()
    hit_sob = models.BooleanField(default=False)
    # total profit form the beliefs treatment
    beliefs_profit = models.DecimalField(max_digits=5,
                                         decimal_places=0,
                                         default=0)

    # risk treatment variables
    risk_choice = models.DecimalField(max_digits=5,
                                      decimal_places=2,
                                      default=0,
                                      min=0,
                                      max=Constants.risk_endowment)
    risk_profit = models.DecimalField(max_digits=5,
                                      decimal_places=2,
                                      default=0)

    #payment info:
    #email input varaible:
    email = models.StringField()
    # show up fee
    show_up_fee = models.DecimalField(max_digits=5,
                                      decimal_places=2,
                                      default=Constants.show_up_fee)
    # profit from trade
    final_treatment_profit = models.DecimalField(max_digits=5,
                                                 decimal_places=2,
                                                 default=0)
    # profit form beliefs
    final_beliefs_profit = models.DecimalField(max_digits=5,
                                               decimal_places=2,
                                               default=0)
    # profit from the experiment 50/50 trade and beliefs
    final_profit = models.DecimalField(max_digits=5,
                                       decimal_places=2,
                                       default=0)
    # trade chosen for payment
    trade_chosen = models.BooleanField(default=False)

    # FUNCTIONS:
    # setting the values
    def set_value(self):
        self.value = round(
            random.uniform(Constants.min_support, Constants.max_support), 0)
        #print('value set')

    # functions defining the payoff
    def set_belief_payoff(self):
        self.beliefs_profit = 0
        self.hit_fob = False
        self.hit_sob = False
        for p in self.get_others_in_group():
            if (p.personal_price >= self.fob * 10) and (p.personal_price <=
                                                        (self.fob + 2) * 10):
                self.beliefs_profit = self.beliefs_profit + Constants.beliefs_revenue
                self.hit_fob = True
            if (p.fob == self.sob):
                self.beliefs_profit = self.beliefs_profit + Constants.beliefs_revenue
                self.hit_sob = True

    # setting payoffs for risk task:
    def risk_results(self):
        r = random.uniform(0, 1)
        risk_hold = Constants.risk_endowment - self.risk_choice
        if r > .5:
            self.risk_profit = Constants.risk_exchange_rate * (
                self.risk_choice * Constants.risk_return + risk_hold)
        else:
            self.risk_profit = risk_hold

    # setting final profit:
    def set_final_profit(self):
        # start with generating random number
        r = random.uniform(0, 1)
        if r <= .5:
            self.final_profit = self.final_treatment_profit + self.risk_profit
            self.trade_chosen = True
        else:
            self.final_profit = self.risk_profit + self.final_beliefs_profit
            self.trade_chosen = False