from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Your name here' doc = """ Your app description """ # class Constants(BaseConstants): # name_in_url = 'empathy' # players_per_group = None # num_rounds = 1 # # # class Subsession(BaseSubsession): # pass # # # class Group(BaseGroup): # pass # # # class Player(BasePlayer): # pass class Constants(BaseConstants): name_in_url = 'empathy' players_per_group = None import csv with open('empathy/webpage.csv', encoding='utf-8') as file: rows = list(csv.DictReader(file)) weblink = [] for line in rows: weblink.append(line["link"]) import csv with open('empathy/webpage.csv', encoding='utf-8') as file: rows = list(csv.DictReader(file)) labels = [] for line in rows: labels.append(line["label"]) # with open('judgment/autofill.csv', encoding="utf-8") as file: # reader = csv.DictReader(file) # judgment_db = [ # {"sl": row["sl_no"], # "judge_name": row["judge_name"].title(), # "not_in_db": False } # for row in reader] # judge_names = list(set([r["judge_name"] for r in judgment_db])) num_repetitions = 1 num_participants = 215 num_rounds = int(len(weblink) / num_participants) * num_repetitions print('num_rounds', num_rounds) print('len(weblinks)', len(weblink)) class Subsession(BaseSubsession): def creating_session(self): players = self.get_players() round_number = self.round_number labels = Constants.labels for p, label in zip(players, labels): p.participant.label = label if round_number == 1: tripled = Constants.weblink * Constants.num_repetitions start = 0 for p in players: end = start+Constants.num_rounds p.participant.vars['weblinks'] = tripled[start:end] start = end for p in players: p.weblink = p.participant.vars['weblinks'][round_number - 1] if round_number == Constants.num_rounds: del p.participant.vars['weblinks'] class Group(BaseGroup): pass class Player(BasePlayer): weblink = models.StringField() total_seconds = models.FloatField() question1 = models.StringField(label="How important do you think empathy i.e. taking other peoples perspective is in public policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"]) question2 = models.StringField(label="How important do you think quantitative analysis is in public policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"]) question3 = models.StringField(label="You are in charge of assigning people to a public policy program and before rolling it out, you want to learn if the policy is effective, what would you do?", choices=["Run a randomized control trial or a pilot", "survey feelings of respondents regarding the policy", "survey if there is demand for policy", "compare two groups of people who had previously benefited most from the policy with those that did not?"]) question4 = models.StringField(label="Continuing with previous example, why the previous answer makes sense:", choices=["Because people in a RCT are apples to applies comparisons", "People feelings are important determinant whether the public policy will work", "survey methods are known to produce causal effects", "comparing two groups of non-randomly selected people allows us to infer causality"]) question5 = models.StringField(label="How important is reflecting on the decision before acting is important in policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"]) question6 = models.StringField(label="How important do you think emotional intelligence i.e. the ability to monitor one's own and other people's emotions, to discriminate between different emotions is in public policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"]) question1_1 = models.StringField(label="How important do you think empathy i.e. taking other peoples perspective is in public policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"]) question2_1 = models.StringField(label="How important do you think quantitative analysis is in public policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"]) question3_1 = models.StringField(label="You are in charge of assigning people to a public policy program and before rolling it out, you want to learn if the policy is effective, what would you do?", choices=["Run a randomized control trial or a pilot", "survey feelings of respondents regarding the policy", "survey if there is demand for policy", "compare two groups of people who had previously benefited most from the policy with those that did not?"]) question4_1 = models.StringField(label="Continuing with previous example, why the previous answer makes sense:", choices=["Because people in a RCT are apples to applies comparisons", "People feelings are important determinant whether the public policy will work", "survey methods are known to produce causal effects", "comparing two groups of non-randomly selected people allows us to infer causality"]) question5_1 = models.StringField(label="How important is reflecting on the decision before acting is important in policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"]) question6_1 = models.StringField(label="How important do you think emotional intelligence i.e. the ability to monitor one's own and other people's emotions, to discriminate between different emotions is in public policy making?", choices=["1 : not important at all", "2 : somewhat important", "3 : neutral", "4 : important", "5 : very important"])