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 = 'LRQ' players_per_group = None num_rounds = 30 K=100 determined_order1 = [54, 78, 60, 14, 58, 43, 93, 71, 64, 60, 27, 16, 57, 47, 47, 55, 54, 32, 55, 65, 58, 72, 57, 55, 40, 33, 45, 31, 79, 48] determined_order2 = [77, 41, 45, 47, 56, 68, 46, 35, 73, 73, 26, 46, 52, 64, 17, 62, 53, 79, 35, 23, 74, 28, 30, 53, 82, 46, 45, 36, 65, 56] instructions_template = 'LRQ/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.'