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 = 'motivation_survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def vars_for_admin_report(self): number = 0 social_you_l = [] social_others_l = [] money_you_l = [] money_others_l = [] recognition_you_l = [] recognition_others_l = [] autonomy_you_l = [] autonomy_others_l = [] working_env_you_l = [] working_env_others_l = [] for p in self.get_players(): number=+1 social_you_l.append(p.social_impact_you) social_you_mean = sum(social_you_l)/len(social_you_l) social_others_l.append(p.social_impact_others) social_others_mean = sum(social_others_l) / len(social_others_l) money_you_l.append(p.money_you) money_you_mean = sum(money_you_l) / len(money_you_l) money_others_l.append(p.money_others) money_others_mean = sum(money_others_l) / len(money_others_l) recognition_you_l.append(p.recognition_you) recognition_you_mean = sum(recognition_you_l) / len(recognition_you_l) recognition_others_l.append(p.recognition_others) recognition_others_mean = sum(recognition_others_l) / len(recognition_others_l) autonomy_you_l.append(p.autonomy_you) autonomy_you_mean = sum(autonomy_you_l) / len(autonomy_you_l) autonomy_others_l.append(p.autonomy_others) autonomy_others_mean = sum(autonomy_others_l) / len(autonomy_others_l) working_env_you_l.append(p.working_env_you) working_env_you_mean = sum(working_env_you_l) / len(working_env_you_l) working_env_others_l.append(p.working_env_others) working_env_others_mean = sum(working_env_others_l) / len(working_env_others_l) return { 'number': number, 'social_you_mean': social_you_mean, 'social_you_list': social_you_l, 'social_others_mean': social_others_mean, 'social_others_list': social_others_l, 'money_you_mean': money_you_mean, 'money_you_list': money_you_l, 'money_others_mean': money_others_mean, 'money_others_list': money_others_l, 'recognition_you_mean': recognition_you_mean, 'recognition_you_list': recognition_you_l, 'recognition_others_mean': recognition_others_mean, 'recognition_others_list': recognition_others_l, 'autonomy_you_mean': autonomy_you_mean, 'autonomy_you_list': autonomy_you_l, 'autonomy_others_mean': autonomy_others_mean, 'autonomy_others_list': autonomy_others_l, 'working_env_you_mean': working_env_you_mean, 'working_env_you_list': working_env_you_l, 'working_env_others_mean': working_env_others_mean, 'working_env_others_list': working_env_others_l, } class Group(BaseGroup): pass class Player(BasePlayer): def set_payoff(self): """Calculate payoff, which is zero for the survey""" self.payoff = 0 social_impact_you = models.PositiveIntegerField( choices=range(0,10+1), widget=widgets.RadioSelectHorizontal(), verbose_name='Social impact (e.g., want to make a difference for the world)') social_impact_others = models.PositiveIntegerField( choices=range(0,10+1), widget=widgets.RadioSelectHorizontal(), verbose_name='Social impact (e.g., want to make a difference for the world)') money_you = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='Money and prestige (e.g., reach high socio-economic status)') money_others = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='Money and prestige (e.g., reach high socio-economic status)') recognition_you = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='''Intellectual challenge & recognition (e.g., apply your skills and talent to solve a problem, being recognized for your competence)''') recognition_others = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='''Intellectual challenge & recognition (e.g., apply your skills and talent to solve a problem, being recognized for your competence)''') autonomy_you = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='''Autonomy (e.g., being able of making decisions, taking initiatives, being independent, organize your work as you like)''') autonomy_others = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='''Autonomy (e.g., being able of making decisions, taking initiatives, being independent, organize your work as you like)''') working_env_you = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='''Nice working environment (e.g., being treated fairly, getting along well with boss and colleagues, non-monetary perks like good mensa)''') working_env_others = models.PositiveIntegerField( choices=range(0, 10 + 1), widget=widgets.RadioSelectHorizontal(), verbose_name='''Nice working environment (e.g., being treated fairly, getting along well with boss and colleagues, non-monetary perks like good mensa)''')