from otree.api import (
models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer,
Currency as c, currency_range
)
author = 'Tommaso Batistoni - t.batistoni@ucl.ac.uk'
doc = """
Survey on school performance, professional/study preferences, financial competencies, and others
"""
class Constants(BaseConstants):
name_in_url = 'questionnaire'
players_per_group = None
num_rounds = 1
# miscellaneous questions
miscellaneous_specialist_subjects = ['Mathematics',' Physics-chemistry ',' Life and Earth Sciences', 'Economic and social sciences',
' History', 'geography', 'geopolitics and political sciences', 'Humanities, literature and philosophy',
'Languages, literatures and foreign and regional cultures', 'Digital and computer science',
'Engineering sciences',' Literature, languages and cultures of Antiquity ',' Arts',
'Biology ecology']
miscellaneous_specialist_uni = ['Mathematics',' Physics-Chemistry ',' Life and Earth Sciences', 'Economic and Social Sciences',
' History Geography ',' Geopolitics and Political Sciences', 'Humanities',
'Literature and Philosophy', 'Languages ',' Foreign and Regional Literature and Cultures',
'Digital and Computer Sciences',' Engineering Sciences', 'Literature',
'Languages and Cultures of Antiquity', 'Arts',' Biology Ecology ']
miscellaneous_newspapaers = ['Le Parisien', 'Le Figaro', 'Le Monde', "L’Equipe", 'Les Echos', 'Libération',
'La Croix',
'La Tribune', "L’Humanité", "France-Soir"]
miscellaneous_questions = {
1: {'label': 'In second, you were asked to submit a list of 4
'
'specialty courses (of which 3 were retained).
Check the 4 options you'
' submitted from the following list:',
'choices': []}, # multi select dropdown menu
2: {'label': 'In second, you followed a course in Economic and Social Sciences (SES) or Fundamental Principles of'
'Economics and Management (PFEG).
'
'What was your average mark in Economic and Social Sciences (SES)',
'choices': []},
3: {'label': 'In second, you took a course in digital sciences and technology.
'
'What was your grade in digital science and technology?',
'choices': []},
4: {'label': 'If you are planning to pursue further education after high school, which area are you most interested in?
'
'(4 possible answers maximum)',
'choices': []},
5: {
'label': "What is the highest degree you think you will achieve?",
'choices': [(l.split(' ')[0], l) for l in ['Bac', 'Licence (bac+2)', 'Master (bac+5)', 'Doctorat (bac+8)']]
},
6: {
'label': 'What profession would you like to occupy?',
'choices': []},
7: {
'label': 'Could you please select the five students that you are the most'
'relatives in the classroom?',
'choices': []}, # multi select dropdown menu
8: {'label': 'Do you read a newspaper (online or in print) on a daily basis?',
'choices': [(0, 'No'), (1, 'Yes')]},
9: {'label': 'Which of the following newspapers do you read the most frequently?',
'choices': []},
10: {
'label': 'On average, boys are generally better than girls at science.',
'choices': []},
}
# financial literacy
financial_questions = [
{
"label": "Imagine you have $ 100 in a savings account and the interest rate is 2 percent per year."
"After 5 years, how much do you think you would have in this account if you let your money grow?",
"choices": [(n, c) for n, c in enumerate(
["More than 102 euros", "Exact 102 euros", "Less than 102 euros", "I do not know"])]},
{
"label": "Imagine the interest rate on your savings account is 1 percent per year and inflation is 2 percent per year."
"After 1 year, could you buy:",
"choices": [(n, c) for n, c in enumerate(
["More than today", "Exactly the same as today", "Less than today",
"I do not know"])]},
{
"label": "According to you, is the following statement true or false? Buying stocks from a single "
"ompany generally offers a safer return than a mutual fund in stocks. ",
"choices": [(n, c) for n, c in enumerate(["True", "False", "I do not know"])]}
]
# charity
charity_decision_choices = [(n + 1, c) for n, c in enumerate(
["Give all my credits to an NGO", "Give part of my credits to an NGO",
"Keep my credits which will be converted into gift vouchers"])]
charity_name_choices = [(c, c + ' (' + d + ')') for c, d in zip(
['Amnesty International', 'Attac', 'Greenpeace', 'Handicap International', 'Oxfam',
'United Nations Refugee Agency'],
['Human rights activist', 'Campaign for tax justice', 'social and ecological',
'Campaign for the protection of the environment', 'Combating discrimination against people with disabilities',
'Fight against poverty', 'Campaign for the rights and well-being of refugees'])]
class Subsession(BaseSubsession):
def creating_session(self):
for p in self.get_players():
# Just for testing all pages
p.participant.vars['year'] = 2
class Group(BaseGroup):
pass
class Player(BasePlayer):
# miscellaneous questions
for n in Constants.miscellaneous_questions.keys():
if n in (1, 5, 6):
locals()[f'misc_{n}'] = models.StringField(
label=Constants.miscellaneous_questions[n]['label'],
choices=Constants.miscellaneous_questions[n]['choices'])
elif n in (4, 7, 9):
locals()[f'misc_{n}'] = models.StringField(
label=Constants.miscellaneous_questions[n]['label'],
choices=Constants.miscellaneous_questions[n]['choices'], blank=True)
elif n == 8:
locals()[f'misc_{n}'] = models.BooleanField(
label=Constants.miscellaneous_questions[n]['label'],
choices=Constants.miscellaneous_questions[n]['choices'], widget=widgets.RadioSelectHorizontal())
elif n == 10:
locals()[f'misc_{n}'] = models.IntegerField(
label=Constants.miscellaneous_questions[n]['label'],
choices=Constants.miscellaneous_questions[n]['choices'])
del n
ses_term1 = models.FloatField(label="in the first trimester?", blank=True, max=20)
ses_term2 = models.FloatField(label="in the second trimester ?", blank=True, max=20)
ses_term3 = models.FloatField(label="in the third trimester?", blank=True, max=20)
ses_no = models.BooleanField(label="I didn't take this class.", widget=widgets.CheckboxInput, blank=True)
pfeg_term1 = models.FloatField(label="in the first trimester?", blank=True, max=20)
pfeg_term2 = models.FloatField(label="in the second trimester ?", blank=True, max=20)
pfeg_term3 = models.FloatField(label="in the third trimester?", blank=True, max=20)
pfeg_no = models.BooleanField(label="I didn't take this class.", widget=widgets.CheckboxInput, blank=True)
def misc_1_error_message(self, value):
if value and len(value.split('",')) != 4:
return 'Please select 4 options.'
def misc_4_error_message(self, value):
if value and len(value.split('",')) > 4:
return 'Please select 4 options maximum.'
def misc_5_error_message(self, value):
if value and len(value.split('",')) > 5:
return 'Please select a maximum of 5 students.'
# financial literacy
for n, q in enumerate(Constants.financial_questions):
locals()[f'financial_{n}'] = models.IntegerField(label=q["label"], choices=q["choices"])
del n, q
# charity
charity_decision = models.IntegerField(
label="If you are drawn, how would you like to use your credits (1 credit = 1 euro)?",
choices=Constants.charity_decision_choices
)
charity_amount = models.CurrencyField(label="How much would you like to donate to an NGO?", blank=True)
charity_name = models.StringField(
label="Which NGO would you like to give your credits to?", choices=Constants.charity_name_choices,
blank=True)
def charity_amount_max(self):
return self.participant.payoff