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 = 'HRQ' players_per_group = None num_rounds = 30 K=100 determined_order1 = [104, 128, 110, 14, 108, 93, 143, 121, 114, 110, 27, 16, 107, 97, 47, 105, 104, 82, 55, 65, 108, 122, 57, 105, 90, 33, 45, 31, 129, 98] determined_order2 = [127, 91, 95, 47, 106, 118, 96, 85, 123, 123, 26, 46, 102, 114, 17, 112, 103, 129, 35, 23, 124, 78, 30, 103, 132, 46, 45, 36, 115, 106] instructions_template = 'HRQ/Instructions.html' class Subsession(BaseSubsession): def before_session_starts(self): players = self.get_players() for p in players: p.order1 = Constants.determined_order1[p.round_number-1] p.order2 = Constants.determined_order2[p.round_number-1] p.total = p.order1 + p.order2 class Group(BaseGroup): pass class Player(BasePlayer): order1 = models.IntegerField() order2 = models.IntegerField() total = models.IntegerField() allocation1 = models.IntegerField() allocation2 = models.IntegerField() #shortage1 = models.IntegerField() #shortage2 = models.IntegerField() total_allocation = models.IntegerField() q11 = models.IntegerField() def q11_error_message(self, value): if value !=100: return "The sum of allocations to the retailers should be equal or less than your capacity. Your capacity is 100 products." q12 = models.IntegerField() def q12_error_message(self, value): if value !=100: return "Since the wholesale price is 1 token, you can earn up to Profit (tokens) = Wholesale price X the total number of products allocated = 1 x 100 = 100." q21 = models.IntegerField() def q21_error_message(self, value): if value !=60: return 'A retailer will not receive products more than his order quantity. The sum of order quantities from retailer A and B is 60, which is the maximum number of products that you can allocate.' q22 = models.IntegerField() def q22_error_message(self, value): if value !=60: return 'Since the wholesale price is 1 token, you can earn up to Profit (tokens) = Wholesale price X the total number of products allocated = 1 x 60 = 60.'