from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random import csv import numpy import pandas as pd import math doc = """ Your app description """ def import_strong_scores(): #f = open('game_lottery_std/test.csv',encoding='utf-8-sig') #reader = csv.DictReader(f) score_df = pd.read_csv('game_lottery_std/e_score.csv') score_df_tail = score_df.tail(19) return score_df_tail def import_si_scores(): score_si_df = pd.read_csv('game_lottery_std/si_score.csv') score_si_df_tail = score_si_df.tail(19) return score_si_df_tail class Constants(BaseConstants): name_in_url = 'game_dic' players_per_group = 2 #s1B = selection q1, BadLottery; s1G = selection q1, GL; s2B = selection q2, BL; s2G = selection q1, GL #be01aSB = sound bad; be02aSG = sound good #pub1SB = public 1 sound bad; pub1SG = public 1 sound good #pub2SB = public 2 sound bad; pub2SG = public 2 sound good tasks = ['s1B','s1G','s2B','s2G',"ego_d0_update","ego_d1_update","be01aSB","be02aSG","pub1_d0","pub2_d0","pub1_d1","pub2_d1"] num_rounds = len(tasks) num_schedule_rounds = 2 num_public_rounds = 4 num_npublic_rounds = num_rounds - num_public_rounds selection_rounds = 4 ego_update_rounds = 2 #strong-man score strong_man_scores = import_strong_scores() median_strong_man_score = strong_man_scores['score'].median() median_strong_man_education = strong_man_scores['education'].median() e_scores_list = strong_man_scores['score'].tolist() e_scores_string = ','.join(str(e) for e in e_scores_list) #print(median_strong_man_score) #print(median_strong_man_education) #si scores si_scores = import_si_scores() median_si_score = si_scores['score'].median() si_scores_list = si_scores['score'].tolist() si_scores_string = ','.join(str(e) for e in si_scores_list) #public strong man guess incentivization: #incentivized_pub = random.randint(0, 1) class Subsession(BaseSubsession): def creating_session(self): pass class Group(BaseGroup): ##ENUM PASS KEY TO PREVENT ACCIDENTAL NAVIGATION = 56631 ##Later check if no refresh on error is possible pass_key = models.IntegerField( label="" ) rounds = models.LongStringField() temp_income = models.IntegerField() c_score_guess = models.IntegerField( min =0, max=40 ) c_type_guess = models.IntegerField( min=0, max=20 ) is_transgression = models.BooleanField( choices=[ [True, "হা - সামাজিক রীতিনীতি ভাংছে"], [False, "না - সামাজিক রীতিনীতি ভাংছে না"] ] ) type = models.IntegerField( label = "", choices = [ [0,'EA'], [1, 'EPC'], [2, 'EPH'] ] ) treatment = models.IntegerField( label = "", choices = [ [0, 'Control'], [1, 'public-public'], [2, 'public-private'] ] ) subtreatment = models.IntegerField( label = "", choices = [ [0, 'NER'], [1, 'ER'], ] ) diagnostic = models.BooleanField( label = "Is it a diagnostic game", choices = [ [False,'NO'], [True,'YES'] ] ) #dictator transfer dic_t = models.IntegerField() check_dic_t = models.IntegerField(blank=True) # sound variables; check_X -> for enforcing selection # (be01a = sound for bad lottery) be01a = models.IntegerField() check_be01a = models.IntegerField(blank=True) # (be02a = sound for good lottery) be02a = models.IntegerField() check_be02a = models.IntegerField(blank=True) # (be_sound_eph_post = sound for EPH elicit regret ) be_sound_eph_regret = models.BooleanField( label = "Select sound again", choices=[ [True,'হ্যাঁ - শব্দ পুনরায় বাছাই করতে চাই'], [False,'না - শব্দ পুনরায় বাছাই করতে চাই না'] ] ) be_sound_eph_post = models.IntegerField() check_be_sound_eph_post = models.IntegerField(blank=True) # money variables # (be01b = money for bad plate) #be01b = models.IntegerField() #check_be01b = models.IntegerField(blank=True) # (be02b = money for good plate) #be02b = models.IntegerField() #check_be02b = models.IntegerField(blank=True) # plate variable -> plate kept by women; 1=Good plate=D=1;0=bad=d=0 be01 = models.IntegerField( label="", choices=[ [0, 'খারাপ বাটি'], [1, 'ভাল বাটি'] ] ) # E4 empatica announce time variables min_pre_announce = models.IntegerField( label="", max=300, min=0 ) sec_pre_announce = models.IntegerField( label="", max=60, min=0 ) # E4 empatica announce time variables min_post_announce = models.IntegerField( label="", max=300, min=0 ) sec_post_announce = models.IntegerField( label="", max=60, min=0 ) # E4 empatica post punishment time variables min_post_sch = models.IntegerField( label="", max=300, min=0 ) sec_post_sch = models.IntegerField( label="", max=60, min=0 ) #Temper Variable #Pre-announcement eph_temper_pre = models.IntegerField() eph_temper_pre_check = models.IntegerField(blank=True) #Post-announcement eph_temper_post_a = models.IntegerField() eph_temper_post_a_check = models.IntegerField(blank=True) #Post-schedule eph_temper_post_s = models.IntegerField() eph_temper_post_s_check = models.IntegerField(blank=True) # EA confidence variable ea_schedule_confidence = models.IntegerField() #likelihood of disobedience likelihood_d = models.IntegerField( min=0, max=10 ) #share of woman disobey by income randomizer h_income_d_first = models.IntegerField() #share of income woman disobeying, if h_income_d_first = 1, #then share w1_income_d =high income share disobeying, else share_w2_income = high income share d share_w1_income_d = models.IntegerField( min=0, max=20 ) share_w2_income_d = models.IntegerField( min=0, max=20 ) # Chooser outside option; take outside option = no food and reduce sound for giving away food #be03_c = models.IntegerField( # label="", # choices=[ # [0, 'No, Give Food - আমি পুরুষটিকে খাবার দিতে চাই'], # [1, 'Yes, Do not Give Food- আমি পুরুষটিকে খাবার দিতে চাই না '], # ] #) # Bead variable be03; good plate = 1 = blue, bad plate = 0 = red #be03 = models.IntegerField( # label="", # choices=[ # [0, 'Red Rice Dice'], # [1, 'Blue Chicken Dice'], # ] #) # Selection questions selection1G = models.IntegerField( label="", choices=[ [0, 'Never - কখনই না'], [1, 'Sometimes - কিছু সময়'], [2, 'More than half the time - বেশির ভাগ সময়'], [3, 'Almost always - প্রায় সব সময়'] ] ) selection1B = models.IntegerField( label="", choices=[ [0, 'Never - কখনই না'], [1, 'Sometimes - কিছু সময়'], [2, 'More than half the time - বেশির ভাগ সময়'], [3, 'Almost always - প্রায় সব সময়'] ] ) selection2G = models.IntegerField( label="", choices=[ [0, 'Never - কখনই না'], [1, 'Sometimes - কিছু সময়'], [2, 'More than half the time - বেশির ভাগ সময়'], [3, 'Almost always - প্রায় সব সময়'] ] ) selection2B = models.IntegerField( label="", choices=[ [0, 'Never - কখনই না'], [1, 'Sometimes - কিছু সময়'], [2, 'More than half the time - বেশির ভাগ সময়'], [3, 'Almost always - প্রায় সব সময়'] ] ) #Public vars #pub 1 public_name_1 = models.StringField() public_income_1 = models.IntegerField() #pub 1 sound expectation vars #be01a = sound for bad plate given; be02a = sound for good plate given pub_be01a_1 = models.IntegerField() check_pub_be01a_1 = models.IntegerField(blank=True) #pub2 d1 diff pub_be01a_diff = models.BooleanField( choices=[ [True, "হ্যাঁ - ভিন্ন হবে"], [False, "না - ভিন্ন হবে না"] ] ) pub_be02a_1 = models.IntegerField() check_pub_be02a_1 = models.IntegerField(blank=True) #pub2 d0 diff pub_be02a_diff = models.BooleanField( choices=[ [True, "হ্যাঁ - ভিন্ন হবে"], [False, "না - ভিন্ন হবে না"] ] ) #pub 2 public_name_2 = models.StringField() public_income_2 = models.IntegerField() #pub 2 sound expectation vars pub_be01a_2 = models.IntegerField() check_pub_be01a_2 = models.IntegerField(blank=True) pub_be02a_2 = models.IntegerField() check_pub_be02a_2 = models.IntegerField(blank=True) #ego_relevancy e_rank = models.IntegerField( min=0, max=10 ) e_score_guess = models.IntegerField( min=0, max=40 ) ego_update_p_random = models.IntegerField() ego_pub_bean = models.IntegerField( min=0, max=10 ) ego_pub_score = models.IntegerField( min=0, max=40 ) #Ego public initial perception different ego_pub_diff = models.BooleanField( choices=[ [True, "হ্যাঁ - ভিন্ন হবে"], [False, "না - ভিন্ন হবে না"] ] ) ego_pub2_bean = models.IntegerField( min=0, max=10 ) ego_pub2_score = models.IntegerField( min=0, max=40 ) #'e_rank_update_d0','e_rank_update_d1', 'e_score_update_d0','e_score_update_d1','e_rank_update_d0_p1','e_rank_update_d1_p1', 'e_score_update_d0_p1','e_score_update_d1_p1','e_rank_update_d0_p2','e_rank_update_d1_p2', 'e_score_update_d0_p2','e_score_update_d1_p2' e_rank_update_d0 = models.IntegerField( min=0, max=10 ) e_rank_update_d1 = models.IntegerField( min=0, max=10 ) e_rank_update_d0_p1 = models.IntegerField( min=0, max=10 ) e_rank_update_d1_p1 = models.IntegerField( min=0, max=10 ) e_update_p_diff_d0 = models.BooleanField( choices=[ [True, "হ্যাঁ - ভিন্ন হবে"], [False, "না - ভিন্ন হবে না"] ] ) e_update_p_diff_d1 = models.BooleanField( choices=[ [True, "হ্যাঁ - ভিন্ন হবে"], [False, "না - ভিন্ন হবে না"] ] ) e_rank_update_d0_p2 = models.IntegerField( min=0, max=10 ) e_rank_update_d1_p2 = models.IntegerField( min=0, max=10 ) e_score_update_d0 = models.IntegerField( min=0, max=40 ) e_score_update_d1 = models.IntegerField( min=0, max=40 ) e_score_update_d0_p1 = models.IntegerField( min=0, max=40 ) e_score_update_d1_p1 = models.IntegerField( min=0, max=40 ) e_score_update_d0_p2 = models.IntegerField( min=0, max=40 ) e_score_update_d1_p2 = models.IntegerField( min=0, max=40 ) #How will respondent feel if public finds out d=0/1 e_mood_d0_p1 = models.IntegerField() e_mood_d0_p_diff = models.BooleanField( choices=[ [True, "হ্যাঁ - ভিন্ন হবে"], [False, "না - ভিন্ন হবে না"] ] ) e_mood_d0_p2 = models.IntegerField() e_mood_d1_p1 = models.IntegerField() e_mood_d1_p_diff = models.BooleanField( choices=[ [True, "হ্যাঁ - ভিন্ন হবে"], [False, "না - ভিন্ন হবে না"] ] ) e_mood_d1_p2 = models.IntegerField() #ego public actual ego_pub_act_score = models.IntegerField( min=0, max=40 ) ego_pub_act_rank = models.IntegerField( min=0, max=10 ) ego_pub_act_upd_sc_d0 = models.IntegerField( min=0, max=40 ) ego_pub_act_upd_rank_d0 = models.IntegerField( min=0, max=10 ) ego_pub_act_upd_sc_d1 = models.IntegerField( min=0, max=40 ) ego_pub_act_upd_rank_d1 = models.IntegerField( min=0, max=10 ) ego_plate_strong = models.IntegerField( choices=[ [0, 'Very likely weak'], [1, 'Likely weak'], [2, 'Neither weak or strong'], [3, 'Likely strong'], [4, 'Very likely strong'] ] ) #ego plate type randomizer ego_plate_good_first = models.IntegerField() ego_plate_type_1 = models.IntegerField( choices=[ [0, 'Very likely weak'], [1, 'Likely weak'], [2, 'Neither weak or strong'], [3, 'Likely strong'], [4, 'Very likely strong'] ] ) plt_type_1_RM_n = models.IntegerField( min = 0, max = 10 ) plt_type_1_NRM_n = models.IntegerField( min=0, max=10 ) ego_plate_type_2 = models.IntegerField( choices=[ [0, 'Very likely weak'], [1, 'Likely weak'], [2, 'Neither weak or strong'], [3, 'Likely strong'], [4, 'Very likely strong'] ] ) #open ended sound_reason = models.StringField() class Player(BasePlayer): ##ENUM PASS KEY TO PREVENT ACCIDENTAL NAVIGATION pass_key = models.IntegerField( label="" ) single_item_income = models.IntegerField() single_item_educ = models.IntegerField( choices=[ [0, 'কোনও ক্লাস পাস করেনি'], [1, 'প্রথম শ্রেণী'], [2, 'দ্বিতীয় শ্রেণী'], [3, 'তৃতীয় শ্রেণী'], [4, 'চতুর্থ শ্রেণী'], [5, 'পঞ্চম শ্রেণী'], [6, 'ষষ্ঠ শ্রেণী'], [7, 'সপ্তম শ্রেণী'], [8, 'অষ্টম শ্রেণী'], [9, 'নবম শ্রেণী'], [10, 'এসএসসি / সমমান'], [11, 'এইচএসসি প্রথম বর্ষ'], [12, 'এইচএসসি দ্বিতীয় বর্ষ'], [12, 'এইচএসসি পাস / সমমান'], [13, 'অনার্স ১ম বর্ষ'], [14, 'অনার্স ২য় বর্ষ'], [15, 'অনার্স ৩য় বর্ষ'], [16, 'অনার্স পাশ'], [17, 'মাস্টার্স পাশ'], [18, 'পিএইচডি / পোস্ট মাস্টার্স'], [19, 'পিধর্মীয় শিক্ষা / দাখিল/ আলিম/ ফাজিল'], [-99, 'বলতে অনিচ্ছুক'], [-98, 'জানি না'], ] ) single_item_income_other = models.IntegerField() listen_decide_p = models.IntegerField( label="", choices=[ [0, 'No, do not want to listen - শব্দ শুনতে চাই না'], [1, 'Yes, listen - হ্যাঁ, শব্দ শুনতে চাই'] ] ) listen_decide_c = models.IntegerField( label="", choices=[ [0, 'No, do not want to listen - শব্দ শুনতে চাই না'], [1, 'Yes, listen - হ্যাঁ, শব্দ শুনতে চাই'] ] ) #################################################################### # PRACTICE ROUND VARIABLES########################################### #################################################################### be01a_practice = models.IntegerField(blank=True) check_be01a_practice = models.IntegerField(blank=True) # be01b_practice = models.IntegerField(blank=True) # check_be01b_practice = models.IntegerField(blank=True) sound_annoying = models.IntegerField( choices=[ [0, "Not annoying at all - একদম বিরক্তিকর না"], [1, "Somewhat annoying - কিছুটা বিরক্তিকর"], [2, "Very annoying - খুব বিরক্তিকর"] ] ) #Understanding questions u_1 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) u_2 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) u_3 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) u_4 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) u_5 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) u_6 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) """ u_7 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) u_8 = models.BooleanField( label="", choices=[ [False, 'Incorrect - ভুল'], [True, 'Correct - সঠিক'] ] ) """ #Ego/SI practice e_prac = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) # RM Score e_1 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_2 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_3 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_4 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_5 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_6 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_7 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_8 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_9 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_10 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) e_score = models.IntegerField() e_high = models.BooleanField() e_other_scores = models.LongStringField() e_rank_actual = models.IntegerField() # Social Independence Score si_1 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_2 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_3 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_4 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_5 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_6 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_7 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_8 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_9 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_10 = models.IntegerField( choices=[ [0, 'Strongly Disagree'], [1, 'Disagree'], [2, 'Neither disagree nor agree'], [3, 'Agree'], [4, 'Strongly Agree'] ] ) si_score = models.IntegerField() si_high = models.BooleanField() # si_rank = models.IntegerField( # min=0, # max=10 # ) si_other_scores = models.LongStringField() si_rank_actual = models.IntegerField()