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 = """ Decoding Task """ class Constants(BaseConstants): name_in_url = 'Decoding_Task' players_per_group = None 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 self.get_players(): p.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() first_name = models.CharField() last_name = models.CharField() #Store num attempted/decoded per period...plus partner's performance for calcs num_attempted_1 = models.IntegerField() num_decoded_1 = models.IntegerField() num_attempted_2 = models.IntegerField() num_decoded_2 = models.IntegerField() num_refreshes = models.CharField() peq_task_difficulty = models.CharField(initial=None, choices=[('1', '1 = Not at all difficult.'), ('2', '2'), ('3', '3'), ('4', '4 = Somewhat difficult.'), ('5', '5'), ('6', '6'), ('7', '7 = Very difficult.')], verbose_name='', widget=widgets.RadioSelect()) peq_task_enjoyment = models.CharField(initial=None, choices=[('1', '1 = Not at all enjoyable.'), ('2', '2'), ('3', '3'), ('4', '4 = Somewhat enjoyable.'), ('5', '5'), ('6', '6'), ('7', '7 = Very enjoyable.')], verbose_name='', widget=widgets.RadioSelect()) peq_average = models.CharField(initial=None, choices=[('1', '1 = I think the average person would be able to complete much LESS decoding work in the time given than I did.'), ('2', '2'), ('3', '3'), ('4', '4 = I think the average person would be able to complete about the same amount of decoding work in the time given as I did.'), ('5', '5'), ('6', '6'), ('7', '7 = I think the average person would be able to complete much MORE decoding work in the time given than I did.')], verbose_name='') peq_affect_excited = models.CharField(initial=None, choices=[('1', '1 = Not at all.'), ('2', '2'), ('3', '3'), ('4', '4 = Moderately.'), ('5', '5'), ('6', '6'), ('7', '7 = Extremely.')], verbose_name='', widget=widgets.RadioSelect()) peq_affect_upset = models.CharField(initial=None, choices=[('1', '1 = Not at all.'), ('2', '2'), ('3', '3'), ('4', '4 = Moderately.'), ('5', '5'), ('6', '6'), ('7', '7 = Extremely.')], verbose_name='', widget=widgets.RadioSelect()) peq_affect_proud = models.CharField(initial=None, choices=[('1', '1 = Not at all.'), ('2', '2'), ('3', '3'), ('4', '4 = Moderately.'), ('5', '5'), ('6', '6'), ('7', '7 = Extremely.')], verbose_name='', widget=widgets.RadioSelect()) peq_affect_irritable = models.CharField(initial=None, choices=[('1', '1 = Not at all.'), ('2', '2'), ('3', '3'), ('4', '4 = Moderately.'), ('5', '5'), ('6', '6'), ('7', '7 = Extremely.')], verbose_name='', widget=widgets.RadioSelect()) peq_affect_inspired = models.CharField(initial=None, choices=[('1', '1 = Not at all.'), ('2', '2'), ('3', '3'), ('4', '4 = Moderately.'), ('5', '5'), ('6', '6'), ('7', '7 = Extremely.')], verbose_name='', widget=widgets.RadioSelect()) peq_affect_nervous = models.CharField(initial=None, choices=[('1', '1 = Not at all.'), ('2', '2'), ('3', '3'), ('4', '4 = Moderately.'), ('5', '5'), ('6', '6'), ('7', '7 = Extremely.')], verbose_name='', widget=widgets.RadioSelect()) peq_gender = models.CharField(initial=None, choices=[('1', 'Male'), ('2', 'Female')], verbose_name='', widget=widgets.RadioSelect()) peq_major = models.CharField(initial=None, choices=[('a', 'a. Accounting'), ('b', 'b. Economics'), ('c', 'c. Financial Management'), ('d', 'd. Management'), ('e', 'e. Marketing'), ('f', 'f. Other') ], verbose_name='', widget=widgets.RadioSelect())