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 = 'survey_end' players_per_group = None num_rounds = 1 show_up_fee = 100 exchange_rate = 0.09 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): ## Survey Responses age = models.IntegerField(label="Your age:") gender = models.StringField(choices=["female", "male", "other"], label="Please indicate the gender you most identify with:") study = models.StringField(label="Please indicate your field of study:") semester = models.IntegerField(label="In which semester are you?") education = models.StringField(choices=["HighSchoolDegree", "Bachelor", "Master", "PhD", "Other"], label="Please indicate your highest degree:") concentrated = models.IntegerField(label="How concentrated were you during the experiment?", choices=[ [1, 'not at all'], [2, 'little concentrated'], [3, 'medium'], [4, 'mostly concentrated'], [5, 'very concentrated'], ] ) understood = models.IntegerField(label="How well did you understand the experiment?", choices=[ [1, 'not at all'], [2, 'not well'], [3, 'medium'], [4, 'mostly understood it'], [5, 'understood it well'], ] ) ##Payoff Relevant Fields Have to get real fields for this, since the vars tables do not get saved. Do everything! # Beliefs from the contest #payoffBeliefA = models.IntegerField() #payoffBeliefB = models.IntegerField() #payoffRoundBelief = models.IntegerField() #beliefA = models.IntegerField() #beliefB = models.IntegerField() #averageA = models.FloatField() #averageB = models.FloatField() # payoffs from the contest payoff1 = models.IntegerField() payoff2 = models.IntegerField() payoff3 = models.IntegerField() payoffRound1 = models.IntegerField() payoffRound2 = models.IntegerField() payoffRound3 = models.IntegerField() contest_total = models.FloatField() donations1 = models.FloatField() donations2 = models.FloatField() donations3 = models.FloatField() donations_total = models.FloatField() donations_totalEuro = models.FloatField() # payoff from SVO payoff_svo = models.IntegerField() payoff_svo_partner = models.IntegerField() svo_scenario = models.IntegerField() svo_who = models.StringField() # payoff from risk_lists payoff_risk = models.IntegerField() risk_list = models.StringField() risk_row = models.IntegerField() risk_choice = models.StringField() # Total Payoff totalPayoffPoints = models.FloatField() totalPayoffEuro = models.FloatField() def set_payoffs(self): # Beliefs from the contest #self.payoffBeliefA = self.participant.vars['payoffBeliefA'] #self.payoffBeliefB = self.participant.vars['payoffBeliefB'] #self.payoffRoundBelief = self.participant.vars['payoffRoundBelief'] #self.beliefA = self.participant.vars['beliefA'] #self.beliefB = self.participant.vars['beliefB'] #self.averageA = self.participant.vars['averageA'] #self.averageB = self.participant.vars['averageB'] # payoffs from the contest self.payoff1 = self.participant.vars['payoff1'] self.payoff2 = self.participant.vars['payoff2'] self.payoff3 = self.participant.vars['payoff3'] self.payoffRound1 = self.participant.vars['payoffRound1'] self.payoffRound2 = self.participant.vars['payoffRound2'] self.payoffRound3 = self.participant.vars['payoffRound3'] self.contest_total = (self.payoff1 + self.payoff2 + self.payoff3)/3 # donations from the contest self.donations1 = self.participant.vars['donations1'] self.donations2 = self.participant.vars['donations2'] self.donations3 = self.participant.vars['donations3'] self.donations_total = (self.donations1 + self.donations2 + self.donations3) / 3 self.donations_totalEuro = round(self.donations_total * Constants.exchange_rate, 2) # payoff from SVO self.payoff_svo = self.participant.vars['payoffSVO'] self.payoff_svo_partner = self.participant.vars['payoffSVO_partner'] self.svo_scenario = self.participant.vars['svo_scenario'] self.svo_who = self.participant.vars['svo_who'] # payoff from risk_lists self.payoff_risk = self.participant.vars['payoff_risk_aversion'] self.risk_list = self.participant.vars['payoff_relevant_list'] self.risk_row = self.participant.vars['payoff_risk_aversion_row'] self.risk_choice = self.participant.vars['payoff_risk_aversion_choice'] self.totalPayoffPoints = self.contest_total #+ self.payoffBeliefA + self.payoffBeliefB self.totalPayoffEuro = round(self.totalPayoffPoints * Constants.exchange_rate + (Constants.show_up_fee + self.payoff_svo + self.payoff_risk) / 100, 2)