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 = 'WorldCup_Survey_Part3' players_per_group = None # tasks = ['A', '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_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_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_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_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%' Part3Intro_time = models.FloatField() MatchBeliefs_a_time = models.FloatField() MatchBeliefs_b_time = models.FloatField() MatchBeliefs_c_time = models.FloatField() MatchBeliefs_d_time = models.FloatField()