from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random import pandas as pd author = 'Shakil Ayan' doc = """ Lottery App for sorting participants """ def import_scores(fname): filepath = "game_lottery_std/" + fname score_df = pd.read_csv(filepath) score_df_tail = score_df.tail(19) return score_df_tail 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_lottery_std' players_per_group = 4 num_rounds = 1 respectable_man_scores = import_scores("e_score.csv") rm_scores_list = respectable_man_scores['score'].tolist() rm_scores_string = ','.join(str(e) for e in rm_scores_list) #sw scores sw_scores = import_scores("si_score.csv") sw_scores_list = sw_scores['score'].tolist() sw_scores_string = ','.join(str(e) for e in sw_scores_list) #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) class Subsession(BaseSubsession): def creating_session(subsession): print(subsession.get_group_matrix()) class Group(BaseGroup): #password 456 pass_key = models.IntegerField() #pass info from qualtrics super_game_ID = models.IntegerField( label="Group ID" ) 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, 'non-image relevance'], [1, 'image relevance'], ] ) game_version = models.IntegerField( choices = [ [0,'standard'], [1,'xyz'] ] ) eph_elicit_regret = models.IntegerField( label="", choices=[ [1, "Elicit Regret"], [0, "Do not elicit regret"] ] ) cv_ante = models.BooleanField() class Player(BasePlayer): si_score = models.IntegerField() si_high = models.BooleanField() si_other_scores = models.LongStringField() si_rank_actual = models.IntegerField() e_score = models.IntegerField() e_high = models.BooleanField() e_other_scores = models.LongStringField() e_rank_actual = models.IntegerField() #Password for game pass_key = models.IntegerField() #Password for image relevance break_code = models.IntegerField() #pass info from participant label enum_name = models.IntegerField() #pass info from participant label male = models.BooleanField() #pass info from participant label HHID = models.FloatField() PID = models.FloatField() e_irscore = models.IntegerField( label = "Image relevance score RM", max = 20, min = 0 ) e_irscorecheck = models.IntegerField( label = "Image relevance score RM double check", max = 20, min = 0 ) si_irscore = models.IntegerField( label = "Image relevance score SW", max = 20, min = 0 ) si_irscorecheck = models.IntegerField( label = "Image relevance score SW double check", max = 20, min = 0 ) e_prac = models.IntegerField() e_1 = models.IntegerField() e_2 = models.IntegerField() e_3 = models.IntegerField() e_4 = models.IntegerField() e_5 = models.IntegerField() e_6 = models.IntegerField() e_7 = models.IntegerField() e_8 = models.IntegerField() e_9 = models.IntegerField() e_10 = models.IntegerField() e_score = models.IntegerField() e_rank_act = models.IntegerField() e_other_scores = models.LongStringField() si_score = models.IntegerField() si_rank_act = models.IntegerField() si_other_scores = models.LongStringField() lottery_num_pair = models.IntegerField( label = "Lottery number picked", max = 200, min = 1 ) coin_toss_winner = models.IntegerField( label = "Did the respondent win the coin toss?", choices= [ [1,'Yes'], [0,'No'] ] ) color_lottery = models.IntegerField( label = "Which color did the respondent pull out of the bag?", choices= [ [1,'White with headset'], [2,'Black with bowl'], [3,'Black with headset'], [4,'White with bowl'] ] ) lottery_num_role = models.IntegerField( label="Lottery number picked", max=200, min=1 ) spouse_lottery_num = models.IntegerField( label = "Spouse Lottery Number Picked", max = 200, min = 1 ) spouse_color_lottery = models.IntegerField( label = "Which color did the spouse get?", choices= [ [1,'White with headset'], [2,'Black with bowl'], [3,'Black with headset'], [4,'White with headset'] ] ) opponent_color_lottery = models.IntegerField( label = "Which color did the spouse get?", choices= [ [1,'White with headset'], [2,'Black with bowl'], [3,'Black with headset'], [4,'White with headset'] ] ) other_man_lottery_num = models.IntegerField( label = "Other HH man Lottery Number", max = 200, min = 1 ) other_woman_lottery_num = models.IntegerField( label = "Other HH woman Lottery Number", max = 200, min = 1 ) opponent_lottery_num_pair = models.IntegerField( label = "Opponent Lottery Number - pair ", max=200, min=1 ) opponent_groupID = models.IntegerField( label = "Opponent group ID" ) opponent_lottery_num_role = models.IntegerField( label="Opponent Lottery Number - role", max=200, min=1 ) group_pos_game = models.IntegerField( label = "Main game position", max=4, min=1 ) game_role = models.IntegerField( label = "Role in the game", choices= [ [1,'Punisher'], [0,'Chooser'] ] ) diagnostic_type = models.IntegerField( label="", choices=[ [0, "Not Diagnostic"], [1, "Diagnostic M v M"], [2, "Diagnostic M v W punisher"], [3, "Diagnostic W v W"] ] ) diagnostic = models.IntegerField() 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, 'non image-relevance'], [1, 'image-relevance'] ] )