from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random from datetime import date from django import forms class Constants(BaseConstants): name_in_url = 'UK_survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): # randomize wedge for player in self.get_players(): player.payout_matchnum = random.choice(list(range(1, 5))) # player.wedge = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) player.wedge1 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) player.wedge2 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) player.wedge3 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) player.wedge4 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) # player.wedge5 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) player.treat = random.choice(["Control", "Subj. Beliefs", "Bookmaker Beliefs"]) pass class Group(BaseGroup): pass class Player(BasePlayer): def make_tenscale_field(label): return models.IntegerField(choices=[[0,''], [1,''], [2,''], [3,''], [4,''], [5,''], [6,''], [7,''], [8,''], [9,''], [10,'']], label=label, widget=widgets.RadioSelectHorizontal) payout_matchnum = models.IntegerField() # wedge = models.FloatField() wedge1 = models.FloatField() wedge2 = models.FloatField() wedge3 = models.FloatField() wedge4 = models.FloatField() # wedge5 = models.FloatField() treat = models.StringField() # declaration = models.IntegerField(choices=[[1, 'I consent to participating'], [0, 'I do not consent to participating']], # label='Do you consent to participating?', widget=widgets.RadioSelect) # follow_league_closely = models.StringField(choices=['Not at all', 'Rarely', 'Somewhat closely', 'Very closely'], # label='How closely do you follow the English Premier League?', widget=widgets.RadioSelect) # follow_league_years = models.IntegerField(label='How many years have you been following the English Premier League?', min=0, max=100) # fav_club = models.StringField(choices=['Arsenal', 'Chelsea', 'Liverpool', 'Manchester City', 'Manchester United', 'Tottenham Hotspur', # 'Aston Villa', 'Brentford', 'Brighton and Hove Albion', 'Burnley', 'Crystal Palace', 'Everton', # 'Leeds United', 'Leicester City', 'Newcastle United', 'Norwich City', 'Southampton', # 'Watford', 'West Ham United', 'Wolverhampton Wanderers', 'None'], # label='Which Premier League Club do you support the most (favourite team)? Please select one club or select None.') # fav_club_rank = models.IntegerField(label='The Premier League table ranks teams from 1 (best) to 20 (worst) based on their performance. ' # 'What rank (between 1 and 20) do you think your favourite team will achieve at the end of the league?', # min=1, max=20) # fav_club_rank_certain = models.IntegerField(label='How certain are you about your ranking of your favourite team above? ' # 'Use a scale of 1 (=very uncertain) to 5 (=completely certain) to indicate how certain you are.', # min=1, max=5, widget=widgets.Slider, initial=1) # soccer_bet_familiar = models.StringField(choices=['Yes', 'No'], # label='Are you familiar with football (soccer) betting?', widget=widgets.RadioSelect) # soccer_bet_freq = models.StringField(choices=['Never', 'Rarely', 'Sometimes', 'Often', 'Every Matchday'], # label='How regularly do you bet on football (soccer) matches?', widget=widgets.RadioSelect) # league_watch_freq = models.IntegerField(label='How many Premier League matches do you watch per year? Please state your best estimate.', # min=0, max=100) # fav_club_support = models.IntegerField(label='How strongly do you support your favourite team on a scale of 1 (do not support at all) ' # 'to 5 (support very strongly)?', # min=1, max=5, widget=widgets.Slider, initial=1) # fav_club_years = models.IntegerField(label='How many years have you been a supporter of your favourite team?', # min=0, max=100) # fav_club_2nd = models.StringField(choices=['Arsenal', 'Chelsea', 'Liverpool', 'Manchester City', 'Manchester United', 'Tottenham Hotspur', # 'Aston Villa', 'Brentford', 'Brighton and Hove Albion', 'Burnley', 'Crystal Palace', 'Everton', # 'Leeds United', 'Leicester City', 'Newcastle United', 'Norwich City', 'Southampton', # 'Watford', 'West Ham United', 'Wolverhampton Wanderers', 'None'], # label='Besides your favourite team stated above, what is your second most favourite team?') # fav_club_2nd_support = models.IntegerField(label='How strongly do you support your second favorite team on a scale of 1 ' # '(do not support at all) to 5 (support very strongly)?', # min=1, max=5, widget=widgets.Slider, initial=1) # least_fav_club = models.StringField(choices=['Arsenal', 'Chelsea', 'Liverpool', 'Manchester City', 'Manchester United', 'Tottenham Hotspur', # 'Aston Villa', 'Brentford', 'Brighton and Hove Albion', 'Burnley', 'Crystal Palace', 'Everton', # 'Leeds United', 'Leicester City', 'Newcastle United', 'Norwich City', 'Southampton', # 'Watford', 'West Ham United', 'Wolverhampton Wanderers', 'None'], # label='Which of the following teams is your least favorite team?') # least_fav_club_dislike = models.IntegerField(label='How strongly do you dislike your least favorite team on a scale of 1 ' # '(do not dislike at all) to 5 (dislike very strongly)?', # min=1, max=5, widget=widgets.Slider, initial=1) # least_fav_club_2nd = models.StringField(choices=['Arsenal', 'Chelsea', 'Liverpool', 'Manchester City', 'Manchester United', 'Tottenham Hotspur', # 'Aston Villa', 'Brentford', 'Brighton and Hove Albion', 'Burnley', 'Crystal Palace', 'Everton', # 'Leeds United', 'Leicester City', 'Newcastle United', 'Norwich City', 'Southampton', # 'Watford', 'West Ham United', 'Wolverhampton Wanderers', 'None'], # label='Which of the following teams is your second least favorite team?') # least_fav_club_2nd_dislike = models.IntegerField(label='How strongly do you dislike your second least favorite team on a scale of 1 ' # '(do not dislike at all) to 5 (dislike very strongly)?', # min=1, max=5, widget=widgets.Slider, initial=1) # risk = make_tenscale_field("") bet_primer1 = models.IntegerField(min=0, label="") bet_primer2 = models.IntegerField(min=0, label="") match_1_win = models.IntegerField(min=0, max=100, initial=0) match_1_draw = models.IntegerField(min=0, max=100, initial=0) match_1_lose = models.IntegerField(min=0, max=100, initial=0) match_1_sum = models.IntegerField() def match_1_sum_error_message(player, value): print('value is', value) if value != 100 : return 'Probabilities need to sum to 100%' match_2_win = models.IntegerField(min=0, max=100, initial=0) match_2_draw = models.IntegerField(min=0, max=100, initial=0) match_2_lose = models.IntegerField(min=0, max=100, initial=0) match_2_sum = models.IntegerField() def match_2_sum_error_message(player, value): print('value is', value) if value != 100: return 'Probabilities need to sum to 100%' match_3_win = models.IntegerField(min=0, max=100, initial=0) match_3_draw = models.IntegerField(min=0, max=100, initial=0) match_3_lose = models.IntegerField(min=0, max=100, initial=0) match_3_sum = models.IntegerField() def match_3_sum_error_message(player, value): print('value is', value) if value != 100: return 'Probabilities need to sum to 100%' match_4_win = models.IntegerField(min=0, max=100, initial=0) match_4_draw = models.IntegerField(min=0, max=100, initial=0) match_4_lose = models.IntegerField(min=0, max=100, initial=0) match_4_sum = models.IntegerField() def match_4_sum_error_message(player, value): print('value is', value) if value != 100: return 'Probabilities need to sum to 100%' # match_5_win = models.IntegerField(min=0, max=100, initial=0) # match_5_draw = models.IntegerField(min=0, max=100, initial=0) # match_5_lose = models.IntegerField(min=0, max=100, initial=0) # match_5_sum = models.IntegerField() # def match_5_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Probabilities need to sum to 100%' # matchbet_win = models.IntegerField(min=0, max=100, initial=0) # matchbet_draw = models.IntegerField(min=0, max=100, initial=0) # matchbet_lose = models.IntegerField(min=0, max=100, initial=0) # matchbet_winodds = models.FloatField() # matchbet_drawodds = models.FloatField() # matchbet_loseodds = models.FloatField() # matchbet_sum = models.IntegerField() # def matchbet_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Tokens need to sum to 100' matchbet_1_win = models.IntegerField(min=0, max=100, initial=0) matchbet_1_draw = models.IntegerField(min=0, max=100, initial=0) matchbet_1_lose = models.IntegerField(min=0, max=100, initial=0) matchbet_1_winodds = models.FloatField() matchbet_1_drawodds = models.FloatField() matchbet_1_loseodds = models.FloatField() matchbet_1_sum = models.IntegerField() def matchbet_1_sum_error_message(player, value): print('value is', value) if value != 100: return 'Tokens need to sum to 100' matchbet_2_win = models.IntegerField(min=0, max=100, initial=0) matchbet_2_draw = models.IntegerField(min=0, max=100, initial=0) matchbet_2_lose = models.IntegerField(min=0, max=100, initial=0) matchbet_2_winodds = models.FloatField() matchbet_2_drawodds = models.FloatField() matchbet_2_loseodds = models.FloatField() matchbet_2_sum = models.IntegerField() def matchbet_2_sum_error_message(player, value): print('value is', value) if value != 100: return 'Tokens need to sum to 100' matchbet_3_win = models.IntegerField(min=0, max=100, initial=0) matchbet_3_draw = models.IntegerField(min=0, max=100, initial=0) matchbet_3_lose = models.IntegerField(min=0, max=100, initial=0) matchbet_3_winodds = models.FloatField() matchbet_3_drawodds = models.FloatField() matchbet_3_loseodds = models.FloatField() matchbet_3_sum = models.IntegerField() def matchbet_3_sum_error_message(player, value): print('value is', value) if value != 100: return 'Tokens need to sum to 100' matchbet_4_win = models.IntegerField(min=0, max=100, initial=0) matchbet_4_draw = models.IntegerField(min=0, max=100, initial=0) matchbet_4_lose = models.IntegerField(min=0, max=100, initial=0) matchbet_4_winodds = models.FloatField() matchbet_4_drawodds = models.FloatField() matchbet_4_loseodds = models.FloatField() matchbet_4_sum = models.IntegerField() def matchbet_4_sum_error_message(player, value): print('value is', value) if value != 100: return 'Tokens need to sum to 100' # matchbet_5_win = models.IntegerField(min=0, max=100, initial=0) # matchbet_5_draw = models.IntegerField(min=0, max=100, initial=0) # matchbet_5_lose = models.IntegerField(min=0, max=100, initial=0) # matchbet_5_winodds = models.FloatField() # matchbet_5_drawodds = models.FloatField() # matchbet_5_loseodds = models.FloatField() # matchbet_5_sum = models.IntegerField() # def matchbet_5_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Tokens need to sum to 100' match_1_watch = models.StringField(choices=['Yes', 'No'], label= 'Are you planning to watch this match?', widget=widgets.RadioSelect) match_2_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', widget=widgets.RadioSelect) match_3_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', widget=widgets.RadioSelect) match_4_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', widget=widgets.RadioSelect) # match_5_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', widget=widgets.RadioSelect) match_1_desiredresult = models.StringField(choices=['Win Man United', 'Draw', 'Win Brighton', 'I don\'t care'], label='What result would you like to see?', widget=widgets.RadioSelect) match_2_desiredresult = models.StringField(choices=['Win Leeds', 'Draw', 'Win Arsenal', 'I don\'t care'], label='What result would you like to see?', widget=widgets.RadioSelect) match_3_desiredresult = models.StringField(choices=['Win Wolves', 'Draw', 'Win Chelsea', 'I don\'t care'], label='What result would you like to see?', widget=widgets.RadioSelect) match_4_desiredresult = models.StringField(choices=['Win Everton', 'Draw', 'Win Leicester', 'I don\'t care'], label='What result would you like to see?', widget=widgets.RadioSelect) # match_5_desiredresult = models.StringField(choices=['Win Liverpool', 'Draw', 'Win Aston Villa', 'I don\'t care'], label='What result would you like to see?', # widget=widgets.RadioSelect) match_1_changechoice = models.StringField(choices=['Yes', 'No'], label='', widget=widgets.RadioSelect) match_2_changechoice = models.StringField(choices=['Yes', 'No'], label='', widget=widgets.RadioSelect) match_3_changechoice = models.StringField(choices=['Yes', 'No'], label='', widget=widgets.RadioSelect) match_4_changechoice = models.StringField(choices=['Yes', 'No'], label='', widget=widgets.RadioSelect) # match_1_changechoice_a = models.StringField(choices=['Yes', 'No'], label='', widget=widgets.RadioSelect) # match_1_changechoice_b = models.StringField(choices=['Yes', 'No'], label='', widget=widgets.RadioSelect) # match_1_changechoice_c = models.StringField(choices=['Yes', 'No'], label='', widget=widgets.RadioSelect) matchbet_1_change_win = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_1_change_draw = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_1_change_lose = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_1_change_sum = models.IntegerField() def matchbet_1_change_sum_error_message(player, value): print('value is', value) if value < 100 and value > 0: return 'Tokens need to sum to 100' matchbet_2_change_win = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_2_change_draw = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_2_change_lose = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_2_change_sum = models.IntegerField() def matchbet_2_change_sum_error_message(player, value): print('value is', value) if value < 100 and value > 0: return 'Tokens need to sum to 100' matchbet_3_change_win = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_3_change_draw = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_3_change_lose = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_3_change_sum = models.IntegerField() def matchbet_3_change_sum_error_message(player, value): print('value is', value) if value < 100 and value > 0: return 'Tokens need to sum to 100' matchbet_4_change_win = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_4_change_draw = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_4_change_lose = models.IntegerField(min=0, max=100, initial=0, blank=True) matchbet_4_change_sum = models.IntegerField() def matchbet_4_change_sum_error_message(player, value): print('value is', value) if value < 100 and value > 0: return 'Tokens need to sum to 100' # matchbet_1_changea_win = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changea_draw = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changea_lose = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changea_sum = models.IntegerField() # def matchbet_1_changea_sum_error_message(player, value): # print('value is', value) # if value < 100 and value > 0: # return 'Tokens need to sum to 100' # matchbet_1_changeb_win = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changeb_draw = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changeb_lose = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changeb_sum = models.IntegerField() # def matchbet_1_changeb_sum_error_message(player, value): # print('value is', value) # if value < 100 and value > 0: # return 'Tokens need to sum to 100' # matchbet_1_changec_win = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changec_draw = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changec_lose = models.IntegerField(min=0, max=100, initial=0, blank=True) # matchbet_1_changec_sum = models.IntegerField() # def matchbet_1_changec_sum_error_message(player, value): # print('value is', value) # if value < 100 and value > 0: # return 'Tokens need to sum to 100' # match_1_affectresult = models.StringField(choices=['Yes', 'No'], # label='Do you think your bet affects the result of this match?', # widget=widgets.RadioSelect) # match_2_affectresult = models.StringField(choices=['Yes', 'No'], # label='Do you think your bet affects the result of this match?', # widget=widgets.RadioSelect) # match_3_affectresult = models.StringField(choices=['Yes', 'No'], # label='Do you think your bet affects the result of this match?', # widget=widgets.RadioSelect) Introduction_time = models.FloatField() # QuestionSet1_time = models.FloatField() # QuestionSet2_time = models.FloatField() # QuestionSet3_time = models.FloatField() # Risk_time = models.FloatField() BetIntro_time = models.FloatField() BetPrimer_time = models.FloatField() MatchBeliefs_a_time = models.FloatField() MatchBeliefs_b_time = models.FloatField() MatchBeliefs_c_time = models.FloatField() MatchBeliefs_d_time = models.FloatField() # MatchBeliefs_e_time = models.FloatField() MatchBet_a_time = models.FloatField() MatchBet_b_time = models.FloatField() MatchBet_c_time = models.FloatField() MatchBet_d_time = models.FloatField() # MatchBet_e_time = models.FloatField() MatchBet_a_change_time = models.FloatField() MatchBet_b_change_time = models.FloatField() MatchBet_c_change_time = models.FloatField() MatchBet_d_change_time = models.FloatField() # MatchBet_a_changea_time = models.FloatField() # MatchBet_a_changeb_time = models.FloatField() # MatchBet_a_changec_time = models.FloatField() # MatchBet_time = models.FloatField() PotentialBonus_time = models.FloatField() # ThankYou_time = models.FloatField()