from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import numpy as np import pandas as pd import itertools import random import django #from captcha.fields import ReCaptchaField #from captcha.widgets import ReCaptchaV2Checkbox author = 'Elisa Macchi' doc = """ Experiment Receiver """ class Constants(BaseConstants): name_in_url = 'exp_receiver_short' players_per_group = None n_players = 1 num_rounds = 1 min_time = 15 max_time = 20 maxbonus = c(5000) consent_template = 'exp_receiver_short/instructions.html' instructions_template = 'exp_receiver_short/instructions_r.html' n_questions = 9 # Payoffs: participation_fee = c(3000) bonus = c(2000) tot_bonus = c(5000) bonus_guessed = c(500) # Sender info: df = pd.read_csv('exp_receiver/exp_sender_2019-07-29.csv') id_sender = list(df['participant.id_in_session']) print("id_sender") print(id_sender) income_sender = list(df['player.income']) gender_sender = list(df['player.gender']) age_sender_c = list(df['player.update_credit_age']) print("age_sender_c") print(age_sender_c) weight_sender_c = list(df['player.update_credit_weight']) height_sender_c = list(df['player.update_credit_height']) info_sender = list(df['player.information']) age_sender_d = list(df['player.update_dating_age']) weight_sender_d = list(df['player.update_dating_weight']) height_sender_d = list(df['player.update_dating_height']) # Image info: img_t = ['1_thin.jpg', '2_thin.jpg', '4_thin.jpg', '5_thin.jpg', '6_thin.jpg', '7_thin.jpg', '8_thin.jpg', '9_thin.jpg', '10_thin.jpg'] img_f = ['1_fat.jpg', '2_fat.jpg', '4_fat.jpg', '5_fat.jpg', '6_fat.jpg', '7_fat.jpg', '8_fat.jpg', '9_fat.jpg', '10_fat.jpg'] images = img_f + img_t name = ['Dan', 'Patrick', 'Isaac', 'Jane', 'Rezia', 'Deborah', 'Annet', 'Abdul', 'Saline'] age = [31, 58, 32, 40, 52, 56, 38, 33, 37] gender = [1, 1, 1, 0, 0, 0, 0, 1, 0] # 1 = male # Endowment (trust and dictator game): endowment = c(4) # Multiplier trust game: multiplier = 2 # Correct answers to understanding questions: correct_answers = {'uq2': 2, 'uq3': 2, 'uq4': 1} class Subsession(BaseSubsession): def creating_session(self): # randomize to treatments treatments = itertools.cycle(['thin', 'fat']) imgs_fat = itertools.cycle(Constants.img_f) imgs_thin = itertools.cycle(Constants.img_t) imgs_age = itertools.cycle(Constants.age) imgs_gen = itertools.cycle(Constants.gender) id_sender = itertools.cycle(Constants.id_sender) print("id_sender") print(id_sender) for p in self.get_players(): # Randomize whether car/no car info. p.treatment = next(treatments) p.car = random.choice([1, 2]) p.participant.vars['car'] = p.car p.image_age = next(imgs_age) p.image_gender = next(imgs_gen) if p.treatment == "fat": p.participant.vars['images'] = next(imgs_fat) p.image_url = next(imgs_fat) elif p.treatment == "thin": p.participant.vars['images'] = next(imgs_thin) p.image_url = next(imgs_thin) # Match with the senders: p.sender1 = next(id_sender) p.sender2 = next(id_sender) p.sender3 = next(id_sender) p.sender4 = next(id_sender) class Group(BaseGroup): def set_payoffs(self): all_players = self.get_players() for p in all_players: p.round_that_counts = random.choice([1, 2]) p.random_bonus = random.choice([5000, 7000, 10000]) p.payoff = Constants.participation_fee + p.random_bonus # player_per_image = {} # # i = 0 # # for image in Constants.images: # n = 0 # # group of players with the same image # # for p in all_players: # if p.participant.vars['images'] == image: # n += 1 # player_per_image[image] = n # # for p in all_players: # # if player_per_image[p.participant.vars['images']] > 0: # # # Robust Bayesian Truth Serum for one picture: # # low = [1, 2, 3, 4, 5, 6, 7] # high = [8, 9, 10] # # # Build X_bar_j: the proportion of the n responders endorsing option j as their belief # # i = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]] # # if p.b1 <= 7: # i[0][0] += 1 # else: # i[1][0] += 1 # if p.b2 <= 7: # i[0][1] += 1 # else: # i[1][1] += 1 # if p.b3 <= 7: # i[0][2] += 1 # else: # i[1][2] += 1 # # if p.b4 <= 7: # i[0][3] += 1 # else: # i[1][3] += 1 # # if p.b5 <= 7: # i[0][4] += 1 # else: # i[1][4] += 1 # # if p.b6 <= 7: # i[0][5] += 1 # else: # i[1][5] += 1 # # if p.b7 <= 7: # i[0][6] += 1 # else: # i[1][6] += 1 # # if p.b8 <= 7: # i[0][7] += 1 # else: # i[1][7] += 1 # # if p.b9 <= 7: # i[0][8] += 1 # else: # i[1][8] += 1 # # x_bar = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]] # # x_bar[0] = [item / Constants.n_players for item in i[0]] # x_bar[1] = [item / Constants.n_players for item in i[1]] # # # Build Y_bar_j: the geometric mean of the endorsement predictions for option j # # # p = array of LOG prediction of the proportion of participants endorsing option j # # (each row is one player, each column is one question) # # p_h = [] # for i in range(Constants.n_players): # p_h.append([0] * Constants.n_questions) # # # j = 0 # for player in all_players: # p_h[j][0] = player.b1 / 10 # p_h[j][1] = player.b2 / 10 # p_h[j][2] = player.b3 / 10 # p_h[j][3] = player.b4 / 10 # p_h[j][4] = player.b5 / 10 # p_h[j][5] = player.b6 / 10 # p_h[j][6] = player.b7 / 10 # p_h[j][7] = player.b8 / 10 # p_h[j][8] = player.b9 / 10 # print("j") # print(j) # j += 1 # # p_l = [] # for i in range(Constants.n_players): # p_l.append([0] * Constants.n_questions) # # j = 0 # for player in all_players: # p_l[j][0] = 1 - player.b1 / 10 # p_l[j][1] = 1 - player.b2 / 10 # p_l[j][2] = 1 - player.b3 / 10 # p_l[j][3] = 1 - player.b4 / 10 # p_l[j][4] = 1 - player.b5 / 10 # p_l[j][5] = 1 - player.b6 / 10 # p_l[j][6] = 1 - player.b7 / 10 # p_l[j][7] = 1 - player.b8 / 10 # p_l[j][8] = 1 - player.b9 / 10 # print("j") # print(j) # j += 1 # # p_h = np.log(p_h) # p_l = np.log(p_l) # # sum_p_h = [sum(column) for column in zip(*p_h)] # sum_p_l = [sum(column) for column in zip(*p_l)] # # y_bar_l = [np.exp(i) for i in np.divide(sum_p_l, Constants.n_players)] # y_bar_h = [np.exp(i) for i in np.divide(sum_p_h, Constants.n_players)] # # y_bar = [y_bar_l, y_bar_h] # # score_j: score for each question # # score_q = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]] # # for i in range(Constants.n_questions): # score_q[0][i] = np.log(x_bar[0][i] / y_bar[0][i]) # score_q[1][i] = np.log(x_bar[1][i] / y_bar[1][i]) # # # Final iscore for each player, by question!!! # # iscore_h = [] # iscore_l = [] # tiscore_l = [] # # for i in range(Constants.n_questions): # iscore_l.append([0] * Constants.n_players) # iscore_h.append([0] * Constants.n_players) # tiscore_l.append([0] * Constants.n_players) # # # THIS SHOULD BE PART OF THE ISCORE (SECOND COMPONENT) BUT IT'S ALWAYS NAN - CHECK FOR REAL # # EXPERIMENT. # # for player in range(Constants.n_players): # tiscore_l[0][player] = x_bar[0][0] * np.log(p_l[player][0] / x_bar[0][0]) + x_bar[1][ # 0] * np.log(p_h[player][0] / x_bar[1][0]) # tiscore_l[1][player] = x_bar[0][1] * np.log(p_l[player][1] / x_bar[0][1]) + x_bar[1][ # 1] * np.log(p_h[player][1] / x_bar[1][1]) # tiscore_l[2][player] = x_bar[0][2] * np.log(p_l[player][2] / x_bar[0][2]) + x_bar[1][ # 2] * np.log(p_h[player][2] / x_bar[1][2]) # tiscore_l[3][player] = x_bar[0][3] * np.log(p_l[player][3] / x_bar[0][3]) + x_bar[1][ # 3] * np.log(p_h[player][3] / x_bar[1][3]) # tiscore_l[4][player] = x_bar[0][4] * np.log(p_l[player][4] / x_bar[0][4]) + x_bar[1][ # 4] * np.log(p_h[player][4] / x_bar[1][4]) # tiscore_l[5][player] = x_bar[0][5] * np.log(p_l[player][5] / x_bar[0][5]) + x_bar[1][ # 5] * np.log(p_h[player][5] / x_bar[1][5]) # tiscore_l[6][player] = x_bar[0][6] * np.log(p_l[player][6] / x_bar[0][6]) + x_bar[1][ # 6] * np.log(p_h[player][6] / x_bar[1][6]) # tiscore_l[7][player] = x_bar[0][7] * np.log(p_l[player][6] / x_bar[0][7]) + x_bar[1][ # 7] * np.log(p_h[player][7] / x_bar[1][7]) # tiscore_l[8][player] = x_bar[0][7] * np.log(p_l[player][6] / x_bar[0][8]) + x_bar[1][ # 8] * np.log(p_h[player][7] / x_bar[1][8]) # # ## TILL HERE # # for player in range(Constants.n_players): # iscore_l[0][player] = score_q[0][0] # iscore_l[1][player] = score_q[0][1] # iscore_l[2][player] = score_q[0][2] # iscore_l[3][player] = score_q[0][3] # iscore_l[4][player] = score_q[0][4] # iscore_l[5][player] = score_q[0][5] # iscore_l[6][player] = score_q[0][6] # iscore_l[7][player] = score_q[0][7] # iscore_l[8][player] = score_q[0][8] # # iscore_h[0][player] = score_q[1][0] # iscore_h[1][player] = score_q[1][1] # iscore_h[2][player] = score_q[1][2] # iscore_h[3][player] = score_q[1][3] # iscore_h[4][player] = score_q[1][4] # iscore_h[5][player] = score_q[1][5] # iscore_h[6][player] = score_q[1][6] # iscore_h[7][player] = score_q[1][7] # iscore_h[8][player] = score_q[1][8] # # # iscore = [] # # for i in range(Constants.n_questions): # iscore.append([0] * Constants.n_players) # # j = 0 # for player in all_players: # if player.b1 <= 7: # player.iscore1 = iscore_l[0][j] # else: # player.iscore1 = iscore_h[0][j] # # iscore[0][j] = player.iscore1 # # if player.b2 <= 7: # player.iscore2 = iscore_l[1][j] # else: # player.iscore2 = iscore_h[1][j] # iscore[1][j] = player.iscore2 # # if player.b3 <= 7: # player.iscore3 = iscore_l[2][j] # else: # player.iscore3 = iscore_h[2][j] # # iscore[2][j] = player.iscore3 # # if player.b4 <= 7: # player.iscore4 = iscore_l[3][j] # else: # player.iscore4 = iscore_h[3][j] # iscore[3][j] = player.iscore4 # # if player.b5 <= 7: # player.iscore5 = iscore_l[4][j] # else: # player.iscore5 = iscore_h[4][j] # iscore[4][j] = player.iscore5 # # if player.b6 <= 7: # player.iscore6 = iscore_l[5][j] # else: # player.iscore6 = iscore_h[5][j] # iscore[5][j] = player.iscore6 # # if player.b7 <= 7: # player.iscore7 = iscore_l[6][j] # else: # player.iscore7 = iscore_h[6][j] # iscore[6][j] = player.iscore7 # # if player.b8 <= 7: # player.iscore8 = iscore_l[7][j] # else: # player.iscore8 = iscore_h[7][j] # iscore[7][j] = player.iscore8 # # if player.b8 <= 7: # player.iscore9 = iscore_l[8][j] # else: # player.iscore9 = iscore_h[8][j] # iscore[7][j] = player.iscore9 # # j += 1 # # for player in all_players: # if player.iscore1 is np.nan or np.isinf(player.iscore1): # player.iscore1 = 0 # if player.iscore2 is np.nan or np.isinf(player.iscore2): # player.iscore2 = 0 # if player.iscore3 is np.nan or np.isinf(player.iscore3): # player.iscore3 = 0 # if player.iscore4 is np.nan or np.isinf(player.iscore4): # player.iscore4 = 0 # if player.iscore5 is np.nan or np.isinf(player.iscore5): # player.iscore5 = 0 # if player.iscore6 is np.nan or np.isinf(player.iscore6): # player.iscore6 = 0 # if player.iscore7 is np.nan or np.isinf(player.iscore7): # player.iscore7 = 0 # if player.iscore8 is np.nan or np.isinf(player.iscore8): # player.iscore8 = 0 # if player.iscore9 is np.nan or np.isinf(player.iscore9): # player.iscore9 = 0 # # for player in all_players: # player.participant.vars['iscore1'] = round(player.iscore1, 2) # player.participant.vars['iscore2'] = round(player.iscore2, 2) # player.participant.vars['iscore3'] = round(player.iscore3, 2) # player.participant.vars['iscore4'] = round(player.iscore4, 2) # player.participant.vars['iscore5'] = round(player.iscore5, 2) # player.participant.vars['iscore6'] = round(player.iscore6, 2) # player.participant.vars['iscore7'] = round(player.iscore7, 2) # player.participant.vars['iscore8'] = round(player.iscore8, 2) # player.participant.vars['iscore9'] = round(player.iscore9, 2) # # print('iscore') # print(iscore) # # for player in all_players: # player.participant.vars['max_iscore'] = max(player.iscore1, # player.iscore2, # player.iscore3, # player.iscore4, # player.iscore5, # player.iscore6, # player.iscore7, # player.iscore8, # player.iscore9) # for player in all_players: # print('max_iscore') # print(player.participant.vars['max_iscore']) # # # Define bonus winners (best in group!) # # top_one_third_q1 = np.argsort(iscore[0])[-2:] # top_one_third_q2 = np.argsort(iscore[1])[-2:] # top_one_third_q3 = np.argsort(iscore[2])[-2:] # top_one_third_q4 = np.argsort(iscore[3])[-2:] # top_one_third_q5 = np.argsort(iscore[4])[-2:] # top_one_third_q6 = np.argsort(iscore[5])[-2:] # top_one_third_q7 = np.argsort(iscore[6])[-2:] # top_one_third_q8 = np.argsort(iscore[7])[-2:] # top_one_third_q9 = np.argsort(iscore[8])[-2:] # # top_one_third = [[top_one_third_q1], [top_one_third_q2], [top_one_third_q3], [top_one_third_q4], # [top_one_third_q5], [top_one_third_q6], [top_one_third_q7], [top_one_third_q8]] # # print("top_one_third") # # print(top_one_third) # # for p in all_players: # p.total_bonus_section1 = 0 # p.n_times_in_top3 = 0 # if np.any(top_one_third_q1 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q2 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q3 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q4 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q5 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q6 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q7 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q8 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # if np.any(top_one_third_q9 == p.id_in_group): # p.total_bonus_section1 += Constants.bonus # p.n_times_in_top3 += 1 # # p.participant.vars['bonus_section1'] = p.total_bonus_section1 # p.participant.vars['n_times_in_top3'] = p.n_times_in_top3 # # winners = np.unique(top_one_third) # # for p in all_players: # p.participant.vars['payoff_section1'] = p.total_bonus_section1 # if p.id_in_group in winners: # p.is_top_one_third = True # else: # p.is_top_one_third = False # # p.participant.vars['top_one_third'] = p.is_top_one_third # # p.total_bonus_section2 = 0 # # if p.guessed_income1 == Constants.income_sender[p.sender1 - 1]: # p.total_bonus_section2 = Constants.bonus_guessed + p.total_bonus_section2 # if p.guessed_income2 == Constants.income_sender[p.sender2 - 1]: # p.total_bonus_section2 = Constants.bonus_guessed + p.total_bonus_section2 # if p.guessed_income3 == Constants.income_sender[p.sender3 - 1]: # p.total_bonus_section2 = Constants.bonus_guessed + p.total_bonus_section2 # if p.guessed_income4 == Constants.income_sender[p.sender4 - 1]: # p.total_bonus_section2 = Constants.bonus_guessed + p.total_bonus_section2 # # p.participant.vars['payoff_section2'] = p.total_bonus_section2 class Player(BasePlayer): # Captcha # captcha = ReCaptchaField(widget=ReCaptchaV2Checkbox) # Treatment Perception: treatment = models.StringField() image_url = models.StringField() # Car/No Car variation: car = models.IntegerField() # Images Characteristics image_age = models.IntegerField() image_gender = models.BooleanField() # Understanding Questions: cp_error = models.BooleanField() # set to True when a person answers erroneously at a comprehension page error1 = models.BooleanField() # first error error2 = models.BooleanField() error3 = models.BooleanField() # second error flagged = models.BooleanField() # if you make 3 mistakes #uq1 = models.IntegerField( # choices=[[1, 'It matters, because it is possible to distinguish originals and not.'], # [2, 'It is relevant to understand how to play the games.'], # [3, 'Does not determine in any way your payment and is completely irrelevant.'], # ], # widget=widgets.RadioSelect, # label="The fact that some pictures are original and some are not:") uq2 = models.IntegerField( choices=[[1, 'Is determined as random.'], [2, 'Is larger the more accurate and truthful your answers are.'], [3, 'Does not depend on your answers.'], ], widget=widgets.RadioSelect, label="Your bonus payment:") uq3 = models.IntegerField( choices=[[1, 'You will see a portrait and answer to 9 questions about the portrayed individual only ONCE.'], [2, 'You will see a portrait and answer to 9 questions about the portrayed individual TWICE.'], [3, 'You will have to answer to 9 questions about a person, but you will not see his/her portrait.'], ], widget=widgets.RadioSelect, label="In Part 1:") uq4 = models.IntegerField( choices=[[1, "You will have to rate other participants' " ' based on information on their appearance.'], [2, "You will have to rate other participants' " ' with no information on their appearance.'], [3, 'You will have to answer 9 questions about yourself.'], ], widget=widgets.RadioSelect, label="In Part 2:") # Beliefs: b1 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How would you rate this person's income? ; Low income ; High income ''') # income b2 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How would you rate this person's health? ; Poor health; Very good health ''') # income b3 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How likely would you be to accept a date with this person?*; Unlikely; Very likely ''') # income b4 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How would you rate this person attractiveness? ; Not attractive; Very Attractive ''') # income b5 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How likely is this person to live a long life?; Unlikely; Very likely ''') # longevity b6 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How likely is this person to yield to temptation? ; Unlikely; Very likely ''') # longevity b7 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How likely is this person to be hard-working? ; Unlikely; Very likely ''') # longevity b8 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How would you rate this person's intelligence? ; Low intelligence; Very high intelligence ''') # intelligence b9 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How likely would you be to follow this person's advice? ; Unlikely; Very likely ''') # status # Perception: q1 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people would think this person is rich? ''') # income q2 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people would think this person is healthy? ''') # health q3 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people of the opposite sex would go on a date with this person? ''') # dating q4 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people would consider this person attractive? ''') # attractiveness q5 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people would think this person will live a long life? ''') # longevity q6 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people would think this person easily yields to temptation? ''') # self-control q7 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people would consider this person hard-working? ''') # work ethos q8 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, verbose_name=''' How many people would consider this person intelligent? ''') # intelligence q9 = models.IntegerField(choices=[[0, ""], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, ""]], widget=widgets.RadioSelectHorizontal, default=None, label=''' How many people would follow this person's advice? ''') # status # Perception: # Section 2: rating_c_p1 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10, label=''' Low; High; ''') rating_c_p2 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10) rating_c_p3 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10) rating_c_p4 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10) rating_d_p1 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10) rating_d_p2 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10) rating_d_p3 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10) rating_d_p4 = models.IntegerField(widget=widgets.Slider(attrs={'step': '1'}, show_value=True), default=5, min=0, max=10, label=''' Low; High; ''') # Check variables for forcing slider movements (one slider for each sender rated) checkslider1 = models.IntegerField(blank=True) checkslider2 = models.IntegerField(blank=True) checkslider3 = models.IntegerField(blank=True) checkslider4 = models.IntegerField(blank=True) checkslider5 = models.IntegerField(blank=True) checkslider6 = models.IntegerField(blank=True) checkslider7 = models.IntegerField(blank=True) checkslider8 = models.IntegerField(blank=True) sender1 = models.IntegerField() sender2 = models.IntegerField() sender3 = models.IntegerField() sender4 = models.IntegerField() # credit guessed_income1 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) guessed_income2 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) guessed_income3 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) guessed_income4 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) # dating guessed_income5 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) guessed_income6 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) guessed_income7 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) guessed_income8 = models.CurrencyField( choices=currency_range(c(0), c(10000), c(50)), blank=True ) # Demographics year_of_birth = models.IntegerField(choices=range(1930, 2018, 1), label='''In which year were you born?''') age = models.IntegerField() gender = models.IntegerField(choices=[[1, 'Male'], [0, 'Female'], [2, 'Other']], label='''Are you:''' ) income = models.CurrencyField( label='''What is your monthly personal income in USh? Please, provide your best approximation.''', choices=currency_range(c(0), c(50000000), c(20000)) ) hhincome = models.CurrencyField( label=''' What is your monthly household income in USh? Please, provide your best guess.''', choices=currency_range(c(0), c(100000000), c(50000)) ) marital_status = models.IntegerField(choices=[[1, 'Single'], [2, 'Married'], [3, 'Living as married'], [4, 'Separated'], [5, 'Divorced'], [6, 'Widowed']], widget=widgets.RadioSelectHorizontal, label=''' Are you:''' ) children = models.IntegerField(choices=range(0, 16, 1), label=''' How many children do you have? Please, only count those you support financially.''' ) education = models.IntegerField(choices=[[1, 'Primary school'], [2, 'Secondary school'], [3, 'Technical/Vocational training'], [4, 'Some College'], [5, 'Bachelor Degree'], [6, 'Masters Degree'], [7, 'PhD, MD, or other Doctorate'], [8, 'None of the above'] ], widget=widgets.RadioSelect, label=''' What is the highest level of education you have completed?''' ) height = models.IntegerField(choices=range(130, 216, 1), label=''' What is your height in cm? Please, provide your best guess.''') weight = models.IntegerField(choices=range(30, 300, 1), label=''' What is your weight in kg? Please, provide your best guess.''') race = models.IntegerField(choices=[[1, 'African'], [2, 'Indian'], [3, 'Asian'], [4, 'White'], [5, 'Mixed']], label='''What is your race?''') health = models.IntegerField(choices=[[1, 'Poor '], [2, 'Fair'], [3, 'Good'], [4, 'Very good'] ], widget=widgets.RadioSelectHorizontal, label='''In general, you would say that your health is''') country = models.StringField(label='''In which country do you reside?''') zip = models.StringField(label='''In which district do you live?''') westernized = models.BooleanField(label='''Do you ever watch western TV or read western magazines? ''') loan = models.IntegerField(choices=[[0, 'No, never.'], [1, 'Yes, only from banks.'], [2, 'Yes, only from informal money lenders.'], [3, 'Yes, both from banks and from informal money lenders.'] ], widget=widgets.RadioSelect, label='''Did you ever borrowed money or received a loan from a non-family member?''') loan_hypothetical = models.IntegerField(choices=[ [0, 'A bank.'], [1, 'An informal money lender.'], ], widget=widgets.RadioSelect, label='''If you needed to borrow 5 million Ush and could not ask to family/friends, would you rather go to:''') loan_hypothetical_why = models.LongStringField( label='''Why would you prefer that?''') # end experiment issues = models.LongStringField(label="", blank=True) comments = models.LongStringField(label="", blank=True) # payments iscore1 = models.FloatField() iscore2 = models.FloatField() iscore3 = models.FloatField() iscore4 = models.FloatField() iscore5 = models.FloatField() iscore6 = models.FloatField() iscore7 = models.FloatField() iscore8 = models.FloatField() iscore9 = models.FloatField() is_top_one_third = models.BooleanField() n_times_in_top3 = models.IntegerField() total_bonus_section1 = models.CurrencyField() total_bonus_section2 = models.CurrencyField() count = models.IntegerField(min=0) random_bonus = models.CurrencyField() round_that_counts = models.IntegerField() phone_number = models.StringField() phone_error = models.BooleanField() payment_method = models.IntegerField(choices=[[0, "Mobile Money"], [1, "Air time"]], widget=widgets.RadioSelect)