from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import csv import random author = """ Tobias Brevik t.brevik@fsu.edu """ doc = """ graph_attempt1 """ class Constants(BaseConstants): name_in_url = 'graph_attempt2' players_per_group = None num_rounds = 1 bleck=11 time_per_return = 500 riskfree=.9 initial_wealth = 5000 class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.rr1=random.randint(1,2) p.r1 = random.randint(1, 2) if p.rr1==1: if p.r1==1: p.c1=1 if p.r1==2: p.c1=2 if p.rr1==2: if p.r1==1: p.c1=3 if p.r1==2: p.c1=4 # p.p1=random.randint(1,20) #series=[] # series.append({ # 'name': 'Test 1', # 'data': [p.p1] # }) #return { # 'highcharts_series': series, # 'round_numbers': list(range(1, Constants.num_rounds + 5)) ## The list of numbers generated using the "list(range(min,max))" command will be ## min to max-1 I think, since list, by itself, starts with 0 as the beginning of the index, ## But I think if it's used in a graph, the categories at the bottom will not exceed ## the data #} def vars_for_admin_report(self): group = self.get_groups()[0] series = [] #transaction_prices = [g.sale_price for g in group.in_all_rounds()] #series.append({ # 'name': 'Transaction Price', # 'data': transaction_prices}) for player in group.get_players(): series.append({ 'name': 'Test 1', # 'data': [p1,p2,p3,p4] 'data': [1, 2, 3, 4] }) # payoffs = [p.payoff for p in player.in_all_rounds()] # series.append( # {'name': 'Earnings for {}'.format(player.role()), # 'data': payoffs}) #def creating_session(self): #r1=random.randint(1,5) #p1=10+r1 p1=5 r2 = random.randint(2, 7) p2 = 20 + r2 r3 = random.randint(3, 9) p3 = 30 + r3 r4 = random.randint(4, 11) p4 = 40 + r4 rr1 = random.randint(25, 30) # for p in self.get_players(self): # p.rr1=random.randint(25,30) return { 'high_series': series, 'round_numbers': list(range(1, Constants.num_rounds + 5)), 'nonsense_categories': ["fuck", "this", "shit"] ## The list of numbers generated using the "list(range(min,max))" command will be ## min to max-1 I think, since list, by itself, starts with 0 as the beginning of the index, ## But I think if it's used in a graph, the categories at the bottom will not exceed ## the data } class Group(BaseGroup): pass class Player(BasePlayer): # p1 = models.IntegerField() r1 = models.IntegerField() rr1 = models.IntegerField() c1 = models.IntegerField()