from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random import itertools from random import shuffle # author = 'Dan Way' doc = """ Cost Allocation """ class Constants(BaseConstants): name_in_url = 'bsw3' players_per_group = 2 num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): if 'condition' in self.session.config: for g in self.get_groups(): #for p in g.get_players(): p1 = g.get_player_by_id(1) p2 = g.get_player_by_id(2) #...they'll be rematched later anyway p1.participant.vars['condition'] = self.session.config['condition'] p2.participant.vars['condition'] = self.session.config['condition'] class Group(BaseGroup): pass class DecodeStrings(models.Model): id = models.IntegerField(null=False,primary_key=True) letters = models.CharField(max_length=50) numbers = models.CharField(max_length=50) def decode_results(self, s_id): return self.objects.filter(id = s_id) class Player(BasePlayer): condition = models.IntegerField() informed_consent = models.CharField(initial=None, choices=[('Yes', 'Yes'), ('No', 'No')], verbose_name='', widget=widgets.RadioSelect()) kc1 = models.CharField(initial=None, choices=['True', 'False'], verbose_name='', widget=widgets.RadioSelect()) kc2 = models.CharField(initial=None, choices=[('a', 'a. One randomly selected period'), ('b', 'b. All periods combined')], verbose_name='', widget=widgets.RadioSelect()) kc3 = models.CharField(initial=None, choices=[('a', 'a. The division managed by the participant that decoded 15 strings.'), ('b', 'b. The division managed by the participant that decoded 20 strings.'), ('c', 'c. The net income of the two divisions will be identical.'), ('d', 'd. None of the above are correct.')], verbose_name='', widget=widgets.RadioSelect()) kc4 = models.CharField(initial=None, choices=[('a', 'a. Costs are allocated based on the proportion of total firm net income generated by each division.'), ('b', 'b. Costs are allocated equally between the two divisions, no matter what.'), ('c', 'c. Costs are allocated by a random computer-generated draw.')], verbose_name='', widget=widgets.RadioSelect()) kc5 = models.CharField(initial=None, choices=[('a', 'a. 80%'), ('b', 'b. 60%'), ('c', 'c. 40%'), ('d', 'd. It varies by period.')], verbose_name='', widget=widgets.RadioSelect()) kc6 = models.CharField(initial=None, choices=[('a', 'a. It decreases your division’s total net income by half.'), ('b', 'b. It increases your division’s total net income by a random amount.'), ('c', 'c. It decreases the amount of net income generated by each string you correctly decode in the period.'), ('d', 'd. There is no possible effect on profitability.')], verbose_name='', widget=widgets.RadioSelect()) practice_time = models.CharField() worker_id = models.CharField(initial='e') mturk_dupe = models.IntegerField()