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 = 'PremierLeague_UK_Part1_1' players_per_group = None tasks = ['B', 'C', 'D'] num_rounds = len(tasks) # num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): # randomize match sequence if self.round_number == 1: for player in self.get_players(): round_numbers = list(range(1, Constants.num_rounds + 1)) random.shuffle(round_numbers) player.participant.vars['task_rounds'] = dict(zip(Constants.tasks, round_numbers)) player.task_rounds = str(dict(zip(Constants.tasks, round_numbers))) pass class Group(BaseGroup): pass class Player(BasePlayer): task_rounds = models.StringField() # 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%' # match_6_win = models.IntegerField(min=0, max=100, initial=0) # match_6_draw = models.IntegerField(min=0, max=100, initial=0) # match_6_lose = models.IntegerField(min=0, max=100, initial=0) # match_6_sum = models.IntegerField() # def match_6_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Probabilities need to sum to 100%' # 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() # MatchBeliefs_f_time = models.FloatField() # Part1Intro_time = models.FloatField()