from otree.api import *
doc = """
Your app description
"""
class C(BaseConstants):
NAME_IN_URL = 'survey'
PLAYERS_PER_GROUP = None
NUM_ROUNDS = 1
class Subsession(BaseSubsession):
pass
def creating_session(subsession):
if subsession.round_number == 1:
for p in subsession.get_players():
p.participant.vars['num_pages'] = 7
if p.participant.vars['role'] == 'P':
p.participant.vars['num_pages'] = 6
class Group(BaseGroup):
pass
class Player(BasePlayer):
#####cognitive reflection task############
Crt_Bat = models.FloatField(
label='',
# A bat and a ball cost 1.10 AUD in total. The bat costs 1.00 AUD more than the ball. How many cents does the ball cost?''',
)
Crt_Widget = models.FloatField(
label='',
# If it takes 5 machines 5 minutes to make 5 widgets, how many minutes would it take 100 machines to make 100 widgets?''',
)
Crt_Lake = models.FloatField(
label='',
# In a lake, there is a patch of lily pads. Every day, the patch doubles in size. If it takes 48 days for the patch to cover the entire lake, how many days would it take for the patch to cover half of the lake?''',
)
Crt_barrel = models.FloatField(
label='',
# In a lake, there is a patch of lily pads. Every day, the patch doubles in size. If it takes 48 days for the patch to cover the entire lake, how many days would it take for the patch to cover half of the lake?''',
)
Crt_student = models.FloatField(
label='',
# In a lake, there is a patch of lily pads. Every day, the patch doubles in size. If it takes 48 days for the patch to cover the entire lake, how many days would it take for the patch to cover half of the lake?''',
)
Crt_pig = models.FloatField(
label='',
# In a lake, there is a patch of lily pads. Every day, the patch doubles in size. If it takes 48 days for the patch to cover the entire lake, how many days would it take for the patch to cover half of the lake?''',
)
Crt_simon = models.StringField(
label='',
widget=widgets.RadioSelect,
choices= [
[0, "a atteint le seuil de rentabilité en bourse"],
[1, "a gagné de l'argent"],
[-1, "a perdu de l'argent"],
]
# In a lake, there is a patch of lily pads. Every day, the patch doubles in size. If it takes 48 days for the patch to cover the entire lake, how many days would it take for the patch to cover half of the lake?''',
)
Know = models.IntegerField(
widget=widgets.RadioSelect,
choices=[
[1, "Oui"],
[0, "Non"],
],
label='',
# Have you ever seen or answered the previous set of questions?''',
# widget=widgets.RadioSelect()
)
Know2 = models.IntegerField(
widget=widgets.RadioSelect,
choices=[
[1, "Oui"],
[0, "Non"],
],
label='',
# Have you ever seen or answered the previous set of questions?''',
# widget=widgets.RadioSelect()
)
##### Regret questions in the loss and gain domain #######################
# Regret_G = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
#
# Regret_L = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
########## Locus of Control
#
# Locus_1 = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
#
# Locus_2 = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
#
# Locus_3 = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
#
# Locus_4 = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
#
# Locus_5 = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
#
# Locus_6 = models.IntegerField(
# label='',
# choices=[1, 2, 3, 4, 5],
# widget=widgets.RadioSelectHorizontal
# )
##### Risk questions #############################
Q_risk = models.IntegerField(
label='',
# Q10. How do you see yourself: are you a person who is generally willing to take risks
# or do you try to avoid taking risks (0 means
# “completely unwilling to take risks”, and 10 means “very willing to take risks”)
# ?''',
choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
widget=widgets.RadioSelectHorizontal
)
###### Demographic questions ###########
Age = models.IntegerField(
label='Quel âge avez-vous? ',
# Q18. What is your age?',
min=1, max=100)
gender = models.StringField(
choices=[
['Male', 'Homme'],
['Female', 'Femme'],
['Other', 'Autre'],
],
label='Quel est votre genre ? ',
# Q19. What is your gender?',
widget=widgets.RadioSelect)
Gender_other = models.StringField(blank=True,
label='Si "Autre", veuillez préciser. '
# If "Other", please specify'
)
Nation = models.StringField(
label='Quelle est votre nationalité? ',
# Q20. What is your nationality?'
)
Major = models.StringField(
widget=widgets.RadioSelect,
choices=[
['Accounting', 'Comptabilité'],
['Economics', 'Economie'],
['Law', 'Droit'],
['Finance', 'Finance'],
['Business Administration, other than Accounting, Economics, or Finance', "Administration des entreprises, autre que la comptabilité, l'économie ou la finance"],
['Education', 'Éducation'],
['Engineering', 'Ingénierie'],
['Health Professions', 'Professions de la santé'],
['Social Sciences or History', 'Sciences sociales ou histoire'],
['Math, Computer Sciences, or Physical Sciences', 'Maths, Informatique Sciences, ou Sciences physiques'],
['Biological Sciences', 'Sciences biologiques'],
['Humanities', ' Humanités '],
['Public Affairs or Social Services', 'Affaires publiques ou services sociaux'],
[' Psychology', 'Psychologie'],
['Other', "Autre (si vous n'êtes pas étudiant, veuillez sélectionner «autre» et préciser votre profession.)"],
],
label="Quel est votre domaine d'études?",
# Q21. What is your major?',
)
Major_other = models.StringField(blank=True,
label='Si "Autre", veuillez préciser. ',
# If "Other", please specify:'
)
Education = models.StringField(
choices=[
['Undergraduate', 'Licence'],
['Masters', 'Master'],
['Doctoral', 'Doctorat'],
['Other', 'Autre'],
],
label='Quel est votre niveau actuel?',
widget=widgets.RadioSelect
)
HH_income = models.StringField(
choices=[
['Less than 500', 'Moins de 500'],
['500-1000', '500-1000'],
['1000-1500', '1000-1500'],
['1500-2000', '1500-2000'],
['More than 2000', 'Plus de 2000'],
],
label='Quel est votre revenu mensuel (en euros) ? ',
widget=widgets.RadioSelect
)
know_other = models.StringField()
s_french = models.StringField()
# questionnaire reasons for bonus payments
Choice_quality = models.IntegerField(
label='',
# With my bonus decisions, I rewarded the blue players if they made good choices.
# (1 means
# “Does not apply not at all”, and 9 means “Applies completely”).''',
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9],
widget=widgets.RadioSelectHorizontal
)
Outcome_quality = models.IntegerField(
label='',
# With my bonus decisions, I rewarded the blue players if they yielded a high outcome.
#
(1 means “Does not apply not at all”, and 9 means “Applies completely”).''',
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9],
widget=widgets.RadioSelectHorizontal
)
Counterfactual = models.IntegerField(
label='',
# With my bonus decisions, I rewarded the blue players if they chose an option that yielded the highest
# outcome, given the turn of the wheel of fortune.
# (1 means
# “Does not apply not at all”, and 9 means “Applies completely”).''',
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9],
widget=widgets.RadioSelectHorizontal,
blank=True
)
altruism = models.IntegerField(
label='',
# I simply gave as much as possible.
# (1 means
# “Does not apply not at all”, and 9 means “Applies completely”).''',
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9],
widget=widgets.RadioSelectHorizontal
)
open_end = models.LongStringField(label='',
# Are there any other aspects that influenced your bonus decision?
# You can also leave any comments regarding the experiments here.''',
blank=True
)
A_good = models.IntegerField(
label='',
# Do you think the blue players were able to influence the outcome of the wheel of fortune?
# (1 means
# “Not at all”, and 9 means “Absolutely”).''',
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9],
widget=widgets.RadioSelectHorizontal
)
A_bonus = models.IntegerField(
label='',
# Do you think the blue players were able to influence the outcome of the wheel of fortune?
# (1 means
# “Not at all”, and 9 means “Absolutely”).''',
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9],
widget=widgets.RadioSelectHorizontal
)
A_bad = models.IntegerField(
label='',
# Do you think the blue players were able to influence the outcome of the wheel of fortune?
# (1 means
# “Not at all”, and 9 means “Absolutely”).''',
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9],
widget=widgets.RadioSelectHorizontal
)
A_open_end = models.LongStringField(label='',
# Are there any other aspects that influenced your bonus decision?
# You can also leave any comments regarding the experiments here.''',
blank=True
)
b_cond_choice = models.IntegerField(
widget=widgets.RadioSelect,
choices=[
[1, "Vrai"],
[0, "Faux"],
],
label="Les joueurs orange peuvent conditionner leur décision de récompense au choix des joueurs bleus. Par "
"exemple, un joueur orange pourrait décider de donner la récompense au joueur bleu apparié si celui-ci "
"choisit l'option A, mais pas s'il choisit l'option B.",
# Have you ever seen or answered the previous set of questions?''',
# widget=widgets.RadioSelect()
)
b_cond_outcomes = models.IntegerField(
widget=widgets.RadioSelect,
choices=[
[1, "Vrai"],
[0, "Faux"],
],
label="Les joueurs orange peuvent conditionner leur décision de récompense au résultat du lancé de roue de la "
"fortune. Par exemple, un joueur orange pourrait décider de donner la récompense au joueur bleu "
"correspondant si celui-ci choisit l'option A et que la roue de la fortune s'arrête sur une case entre 1 et 20, mais "
"pas s'il choisit l'option A et que la roue de la fortune s'arrête sur l'une des autres cases.",
# Have you ever seen or answered the previous set of questions?''',
# widget=widgets.RadioSelect()
)
participated = models.IntegerField(
widget=widgets.RadioSelect,
choices=[
[1, "Oui"],
[0, "Non"],
],
label="Nous avons mené une expérience très similaire avec des joueurs orange et bleus l'année dernière. Vous souvenez-vous d'avoir participé à cette expérience l'année dernière ?",
)
# PAGES
class Demographics(Page):
form_model = 'player'
form_fields = ['Age',
'gender',
'Gender_other',
'Nation',
'Major', 'Major_other', 'Education',
'HH_income']
def vars_for_template(self):
french = self.participant.vars['french']
majors_form = ['Accounting', 'Economics', 'Law', 'Finance',
'Business Administration, other than Accounting, Economics, or Finance',
' Education', 'Engineering', 'Health Professions', 'Social Sciences or History',
'Math, Computer Sciences, or Physical Sciences', 'Biological Sciences', 'Humanities',
'Public Affairs or Social Services', ' Psychology',
'Other (if you are not a student, please select "other" and specify your occupation.)'
]
education_form = ['Undergraduate', 'Masters', 'Doctorat', 'Does not apply']
education_text = education_form
income_form = ['Less than 500', '500-900', '900-1300', '1300-1700', 'More than 1700']
if french == 1:
majors_text = ['Comptabilité', 'Economie', 'Droit', 'Finance', "Administration des entreprises, autre que la comptabilité, "
"l'économie ou la finance", 'Éducation', 'Ingénierie', 'Professions de la santé',
'Sciences sociales ou histoire', 'Maths, Informatique Sciences, ou Sciences physiques',
'Sciences biologiques', 'Humanités', 'Affaires publiques ou services sociaux', 'Psychologie',
"Autre (si vous n'êtes pas étudiant, veuillez sélectionner «autre» et préciser votre profession.)"]
education_text = ['Licence', 'Master', 'Doctoral', "Ne s'applique pas"]
income_text = ['Moins de 500', '500-900', '900-1300', '1300-1700', 'Plus de 1700']
else:
majors_text = majors_form
education_form = education_form
income_text = income_form
if self.participant.vars['role'] == 'P':
page_number = 5
else:
page_number = 6
return dict(
french=self.participant.vars['french'],
majors=zip(majors_form, majors_text),
education=zip(education_form, education_text),
income=zip(income_form, income_text),
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
)
class Risk(Page):
form_model = 'player'
form_fields = ['Q_risk']
def vars_for_template(self):
if self.participant.vars['role'] == 'P':
page_number = 4
else:
page_number = 5
return dict(
french=self.participant.vars['french'],
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
)
class Cognitive(Page):
form_model = 'player'
form_fields = ['Crt_Bat', 'Crt_Widget', 'Crt_Lake', 'Know']
def vars_for_template(self):
if self.participant.vars['role'] == 'P':
page_number = 3
else:
page_number = 4
return dict(
french=self.participant.vars['french'],
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
)
class Cognitive2(Page):
form_model = 'player'
form_fields = ['Crt_barrel', 'Crt_student', 'Crt_pig', 'Crt_simon', 'Know2']
def vars_for_template(self):
if self.participant.vars['role'] == 'P':
page_number = 2
else:
page_number = 3
return dict(
french=self.participant.vars['french'],
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
)
class Locus(Page):
form_model = 'player'
form_fields = ['Locus_1', 'Locus_2', 'Locus_3', 'Locus_4', 'Locus_5', 'Locus_6']
def vars_for_template(self):
role = self.participant.vars['role']
if role == 'P':
page_number = 5
else:
page_number = 6
return dict(
french=self.participant.vars['french'],
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
)
class Start(Page):
def vars_for_template(self):
return dict(
french=self.participant.vars['french'],
)
class End(Page):
def vars_for_template(self):
return dict(
french=self.participant.vars['french'],
)
class BonusReasons(Page):
form_model = 'player'
form_fields = ['Choice_quality', 'Outcome_quality', 'Counterfactual', 'altruism', 'open_end']
def is_displayed(self):
return self.participant.vars['role'] == 'P'
def vars_for_template(self):
role = self.participant.vars['role']
return dict(
role=self.participant.vars['role'],
french=self.participant.vars['french'],
treatment=self.participant.vars['treatment'],
num_pages=self.participant.vars['num_pages'],
page_number=1,
)
class DecisionReasons(Page):
form_model = 'player'
form_fields = ['A_good', 'A_bad', 'A_bonus', 'A_open_end']
def is_displayed(self):
return self.participant.vars['role'] == 'A'
def vars_for_template(self):
return dict(
role=self.participant.vars['role'],
french=self.participant.vars['french'],
page_number=1,
num_pages=self.participant.vars['num_pages'],
)
class Regret_Loss_Gain(Page):
form_model = 'player'
form_fields = ['Regret_G', 'Regret_L']
def vars_for_template(self):
role = self.participant.vars['role']
if role == 'P':
num_pages = 6
page_number = 2
else:
num_pages = 7
page_number = 3
return dict(
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
french=self.participant.vars['french'],
)
class Comprehension(Page):
form_model = 'player'
form_fields = ['b_cond_choice', 'b_cond_outcomes']
def is_displayed(player: Player):
return player.participant.vars['role'] == 'A'
def vars_for_template(self):
role = self.participant.vars['role']
if role == 'P':
page_number = 2
else:
page_number = 2
return dict(
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
french=self.participant.vars['french'],
)
class Participated(Page):
form_model = 'player'
form_fields = ['participated']
def vars_for_template(self):
role = self.participant.vars['role']
if role == 'P':
page_number = 6
else:
page_number = 7
return dict(
num_pages=self.participant.vars['num_pages'],
page_number=page_number,
french=self.participant.vars['french'],
)
# page_sequence = []
page_sequence = [Start, BonusReasons, DecisionReasons, Comprehension, Cognitive2, Cognitive, Risk, Demographics, Participated]
# page_sequence = [Risk]