e4c_expe2/a5_questfin/models.py

735 lines
25 KiB
Python
Raw Permalink Normal View History

2025-03-30 12:32:15 +02:00
from otree.api import (
models,
widgets,
BaseConstants,
BaseSubsession,
BaseGroup,
BasePlayer,
Currency as c,
currency_range,
)
doc = """
author = 'Wael Bousselmi'
Exp E4C
"""
class Constants(BaseConstants):
name_in_url = 'a5_questfin'
players_per_group = None
num_rounds = 1
app_seq1 = ["gp", "bw", "MDG_asso", "MDG_class"]
app_seq2 = ["gp", "bw", "MDG_class", "MDG_asso"]
app_seq3 = ["bw", "gp", "MDG_asso", "MDG_class"]
app_seq4 = ["bw", "gp", "MDG_class", "MDG_asso"]
exchangerate_gp_bw = 0.8
exchangerate_DGM = 0.1
showupfee = 5
instructions_GP_template = 'a5_questfin/instructions_gp.html'
instructions_bw_template = 'a5_questfin/instructions_bw.html'
instructions_DCL_template = 'a5_questfin/instructions_dcl.html'
instructions_DAS_template = 'a5_questfin/instructions_das.html'
instructions_colors_template = 'a5_questfin/instructions_colors.html'
class Subsession(BaseSubsession):
def vars_for_admin_report(self):
report = list()
for p in self.get_players():
report.append(dict(
gainrisk_eur = p.field_maybe_none('gainrisk_eur') or 0.0,
gain_bw_eur = p.field_maybe_none('gain_bw_eur') or 0.0,
mdgasso_gain_dgm_eur = p.field_maybe_none('mdgasso_gain_dgm_eur') or 0.0,
mdgasso_gain_asso_eur = p.field_maybe_none('mdgasso_gain_asso_eur') or 0.0,
mdgclass_gain_dgm_eur = p.field_maybe_none('mdgclass_gain_dgm_eur') or 0.0,
mdgclass_dgm_selected = p.field_maybe_none('mdgclass_dgm_selected') or 0,
mdgclass_round_selected = p.field_maybe_none('mdgclass_round_selected') or 0,
mdgclass_dot1_select = p.field_maybe_none('mdgclass_dot1_select') or 0,
mdgclass_s1_select = p.field_maybe_none('mdgclass_s1_select') or 0,
mdgclass_g1_select = p.field_maybe_none('mdgclass_g1_select') or 0,
mdgclass_keep_select = p.field_maybe_none('mdgclass_keep_select') or 0,
mdgclass_sent_select = p.field_maybe_none('mdgclass_sent_select') or 0,
mdgclass_gain_joueur2 = p.field_maybe_none('mdgclass_gain_joueur2') or 0.0,
mdgclass_gain_joueur2_eur = p.field_maybe_none('mdgclass_gain_joueur2_eur') or 0.0,
dictatorYES = p.field_maybe_none('dictatorYES') or False,
app_sequence_select_n = p.field_maybe_none('app_sequence_select_n') or 0,
game_num_select = p.field_maybe_none('game_num_select') or 0,
firstname = p.field_maybe_none('firstname') or "",
lastname = p.field_maybe_none('lastname') or "",
email = p.field_maybe_none('email') or "",
room = p.field_maybe_none('room') or "",
game_select_n = p.field_maybe_none('room') or "",
gainfinal_eur_f = p.field_maybe_none('gainfinal_eur_f') or 0.0,
gainfinal_eur_showupfee_f2025 = p.field_maybe_none('gainfinal_eur_showupfee_f2025') or 0.0,
gainfinal_asso_eur_f = p.field_maybe_none('gainfinal_asso_eur_f') or 0.0,
))
return dict(report=report)
class Group(BaseGroup):
pass
class Player(BasePlayer):
app_sequence_select = models.IntegerField(blank=True, null=True)
app_sequence_select_n = models.StringField(blank=True, null=True)
questionnaire_before = models.IntegerField(blank=True, null=True)
game_num_select = models.IntegerField(blank=True, null=True)
game_select_n = models.StringField(blank=True, null=True)
game_select = models.IntegerField(blank=True, null=True)
# result of GP
tirageriskresult = models.StringField(blank=True, null=True)
tirageriskresult_en = models.StringField(blank=True, null=True)
risk11_a = models.FloatField(blank=True, null=True)
risk11_b = models.FloatField(blank=True, null=True)
gainrisk = models.FloatField(blank=True, null=True)
gainrisk_eur = models.FloatField(blank=True, null=True)
# result of BW
tirage_color_n = models.StringField(blank=True, null=True)
gain_bw = models.FloatField(blank=True, null=True)
gain_bw_eur = models.FloatField(blank=True, null=True)
# result of MDG_asso
mdgasso_dgm_selected = models.IntegerField(blank=True, null=True)
mdgasso_round_selected = models.IntegerField(blank=True, null=True)
mdgasso_dot1_select = models.IntegerField(blank=True, null=True)
mdgasso_s1_select = models.IntegerField(blank=True, null=True)
mdgasso_g1_select = models.IntegerField(blank=True, null=True)
mdgasso_keep_select = models.FloatField(blank=True, null=True)
mdgasso_sent_select = models.FloatField(blank=True, null=True)
mdgasso_gain_dgm = models.FloatField(blank=True, null=True)
mdgasso_gain_asso = models.FloatField(blank=True, null=True)
mdgasso_gain_dgm_eur = models.FloatField(blank=True, null=True)
mdgasso_gain_asso_eur = models.FloatField(blank=True, null=True)
# result of MDG_classique
mdgclass_dgm_selected = models.IntegerField(blank=True, null=True)
mdgclass_round_selected = models.IntegerField(blank=True, null=True)
mdgclass_dot1_select = models.IntegerField(blank=True, null=True)
mdgclass_s1_select = models.IntegerField(blank=True, null=True)
mdgclass_g1_select = models.IntegerField(blank=True, null=True)
mdgclass_keep_select = models.FloatField(blank=True, null=True)
mdgclass_sent_select = models.FloatField(blank=True, null=True)
mdgclass_gain_dgm = models.FloatField(blank=True, null=True)
mdgclass_gain_joueur2 = models.FloatField(blank=True, null=True)
mdgclass_gain_dgm_eur = models.FloatField(blank=True, null=True)
mdgclass_gain_joueur2_eur = models.FloatField(blank=True, null=True)
dictatorYES = models.IntegerField(blank=True, null=True)
dictatorYES_n = models.StringField(blank=True, null=True)
# new 2025
# g1_easy_to_understand = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g1_involves_risk = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g1_annoying_boring = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
#
# g2_easy_to_understand = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g2_involves_risk = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g2_annoying_boring = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
#
# g3_easy_to_understand = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g3_involves_altruism = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g3_annoying_boring = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
#
# g4_easy_to_understand = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g4_involves_altruism = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
# g4_annoying_boring = models.IntegerField(
# choices=[(1, 'Strongly Disagree'), (2, 'Disagree'), (3, 'Neutral'), (4, 'Agree'), (5, 'Strongly Agree')],
# label="",
# blank=False
# )
crt1 = models.FloatField(
label="",
blank=True
) # Correct Answer: 5.
crt2 = models.FloatField(
label="",
blank=True
) # Correct Answer: 5
crt3 = models.FloatField(
label="",
blank=True
) # Correct Answer: 47
gain_crt = models.IntegerField()
# demographic quetsionnaire
q_40_etude = models.IntegerField(
choices=[
[1, '1- Arts and / or literature'],
[2, '2- Economy and / or management'],
[3, '3- Scientific / engineering'],
[4, '4- Other'],
],
widget=widgets.RadioSelect,
label="a. Your field of study ",
blank=False
)
q_41_gender = models.IntegerField(
choices=[
[1, '1- Woman'],
[2, '2- Male'],
[3, '3- Non-binary'],
[4, '4- Do not wish to answer'],
],
widget=widgets.RadioSelect,
label="b. You are ",
blank=False
)
q_42_age = models.IntegerField(
label="c. How old are you?",
blank=False,
min=15,
max=100,
)
q_43_nationalite = models.IntegerField(
choices=[
[1, "Afghanistan"],
[2, "Albania"],
[3, "Algeria"],
[4, "Andorra"],
[5, "Angola"],
[6, "Antigua and Barbuda"],
[7, "Argentina"],
[8, "Armenia"],
[9, "Australia"],
[10, "Austria"],
[11, "Azerbaijan"],
[12, "Bahamas"],
[13, "Bahrain"],
[14, "Bangladesh"],
[15, "Barbados"],
[16, "Belarus"],
[17, "Belgium"],
[18, "Belize"],
[19, "Benin"],
[20, "Bhutan"],
[21, "Bolivia"],
[22, "Bosnia and Herzegovina"],
[23, "Botswana"],
[24, "Brazil"],
[25, "Brunei Darussalam"],
[26, "Bulgaria"],
[27, "Burkina Faso"],
[28, "Burundi"],
[29, "Cambodia"],
[30, "Cameroon"],
[31, "Canada"],
[32, "Cape Verde"],
[33, "Central African Republic"],
[34, "Chad"],
[35, "Chile"],
[36, "China"],
[37, "Colombia"],
[38, "Comoros"],
[39, "Congo, Republic of the..."],
[40, "Costa Rica"],
[41, "Côte d'Ivoire"],
[42, "Croatia"],
[43, "Cuba"],
[44, "Cyprus"],
[45, "Czech Republic"],
[46, "Democratic People's Republic of Korea"],
[47, "Democratic Republic of the Congo"],
[48, "Denmark"],
[49, "Djibouti"],
[50, "Dominica"],
[51, "Dominican Republic"],
[52, "Ecuador"],
[53, "Egypt"],
[54, "El Salvador"],
[55, "Equatorial Guinea"],
[56, "Eritrea"],
[57, "Estonia"],
[58, "Ethiopia"],
[59, "Fiji"],
[60, "Finland"],
[61, "France"],
[62, "Gabon"],
[63, "Gambia"],
[64, "Georgia"],
[65, "Germany"],
[66, "Ghana"],
[67, "Greece"],
[68, "Grenada"],
[69, "Guatemala"],
[70, "Guinea"],
[71, "Guinea-Bissau"],
[72, "Guyana"],
[73, "Haiti"],
[74, "Honduras"],
[75, "Hong Kong (S.A.R.)"],
[76, "Hungary"],
[77, "Iceland"],
[78, "India"],
[79, "Indonesia"],
[80, "Iran, Islamic Republic of..."],
[81, "Iraq"],
[82, "Ireland"],
[83, "Israel"],
[84, "Italy"],
[85, "Jamaica"],
[86, "Japan"],
[87, "Jordan"],
[88, "Kazakhstan"],
[89, "Kenya"],
[90, "Kiribati"],
[91, "Kuwait"],
[92, "Kyrgyzstan"],
[93, "Lao People's Democratic Republic"],
[94, "Latvia"],
[95, "Lebanon"],
[96, "Lesotho"],
[97, "Liberia"],
[98, "Libyan Arab Jamahiriya"],
[99, "Liechtenstein"],
[100, "Lithuania"],
[101, "Luxembourg"],
[102, "Madagascar"],
[103, "Malawi"],
[104, "Malaysia"],
[105, "Maldives"],
[106, "Mali"],
[107, "Malta"],
[108, "Marshall Islands"],
[109, "Mauritania"],
[110, "Mauritius"],
[111, "Mexico"],
[112, "Micronesia, Federated States of..."],
[113, "Monaco"],
[114, "Mongolia"],
[115, "Montenegro"],
[116, "Morocco"],
[117, "Mozambique"],
[118, "Myanmar"],
[119, "Namibia"],
[120, "Nauru"],
[121, "Nepal"],
[122, "Netherlands"],
[123, "New Zealand"],
[124, "Nicaragua"],
[125, "Niger"],
[126, "Nigeria"],
[127, "North Korea"],
[128, "Norway"],
[129, "Oman"],
[130, "Pakistan"],
[131, "Palau"],
[132, "Panama"],
[133, "Papua New Guinea"],
[134, "Paraguay"],
[135, "Peru"],
[136, "Philippines"],
[137, "Poland"],
[138, "Portugal"],
[139, "Qatar"],
[140, "Republic of Korea"],
[141, "Republic of Moldova"],
[142, "Romania"],
[143, "Russian Federation"],
[144, "Rwanda"],
[145, "Saint Kitts and Nevis"],
[146, "Saint Lucia"],
[147, "Saint Vincent and the Grenadines"],
[148, "Samoa"],
[149, "San Marino"],
[150, "Sao Tome and Principe"],
[151, "Saudi Arabia"],
[152, "Senegal"],
[153, "Serbia"],
[154, "Seychelles"],
[155, "Sierra Leone"],
[156, "Singapore"],
[157, "Slovakia"],
[158, "Slovenia"],
[159, "Solomon Islands"],
[160, "Somalia"],
[161, "South Africa"],
[162, "South Korea"],
[163, "Spain"],
[164, "Sri Lanka"],
[165, "Sudan"],
[166, "Suriname"],
[167, "Swaziland"],
[168, "Sweden"],
[169, "Switzerland"],
[170, "Syrian Arab Republic"],
[171, "Tajikistan"],
[172, "Thailand"],
[173, "The former Yugoslav Republic of Macedonia"],
[174, "Timor-Leste"],
[175, "Togo"],
[176, "Tonga"],
[177, "Trinidad and Tobago"],
[178, "Tunisia"],
[179, "Turkey"],
[180, "Turkmenistan"],
[181, "Tuvalu"],
[182, "Uganda"],
[183, "Ukraine"],
[184, "United Arab Emirates"],
[185, "United Kingdom of Great Britain and Northern Ireland"],
[186, "United Republic of Tanzania"],
[187, "United States of America"],
[188, "Uruguay"],
[189, "Uzbekistan"],
[190, "Vanuatu"],
[191, "Venezuela, Bolivarian Republic of..."],
[192, "Viet Nam"],
[193, "Yemen"],
[194, "Zambia"],
[195, "Zimbabwe"],
],
blank=False,
label="d. Country of citizenship",
)
q_44_revenu = models.IntegerField(
choices=[
[1, '1- Less than 5,000 Euros'],
[2, '2- Between 5,000 and 10,000 Euros'],
[3, '3- Between 10,000 and 15,000 Euros'],
[4, '4- Between 15,000 and 20,000 Euros'],
[5, '5- Between 20,000 and 25,000 Euros'],
[6, '6- Greater than 25,000 Euros'],
],
widget=widgets.RadioSelect,
label="e. Please estimate your gross annual income (including your scholarships and student loan) in Euros. (Note: Your own income, not that of your parents)",
blank=False
)
q3_countries = models.IntegerField(
choices=[
[1, "Afghanistan"],
[2, "Albania"],
[3, "Algeria"],
[4, "Andorra"],
[5, "Angola"],
[6, "Antigua and Barbuda"],
[7, "Argentina"],
[8, "Armenia"],
[9, "Australia"],
[10, "Austria"],
[11, "Azerbaijan"],
[12, "Bahamas"],
[13, "Bahrain"],
[14, "Bangladesh"],
[15, "Barbados"],
[16, "Belarus"],
[17, "Belgium"],
[18, "Belize"],
[19, "Benin"],
[20, "Bhutan"],
[21, "Bolivia"],
[22, "Bosnia and Herzegovina"],
[23, "Botswana"],
[24, "Brazil"],
[25, "Brunei Darussalam"],
[26, "Bulgaria"],
[27, "Burkina Faso"],
[28, "Burundi"],
[29, "Cambodia"],
[30, "Cameroon"],
[31, "Canada"],
[32, "Cape Verde"],
[33, "Central African Republic"],
[34, "Chad"],
[35, "Chile"],
[36, "China"],
[37, "Colombia"],
[38, "Comoros"],
[39, "Congo, Republic of the..."],
[40, "Costa Rica"],
[41, "Côte d'Ivoire"],
[42, "Croatia"],
[43, "Cuba"],
[44, "Cyprus"],
[45, "Czech Republic"],
[46, "Democratic People's Republic of Korea"],
[47, "Democratic Republic of the Congo"],
[48, "Denmark"],
[49, "Djibouti"],
[50, "Dominica"],
[51, "Dominican Republic"],
[52, "Ecuador"],
[53, "Egypt"],
[54, "El Salvador"],
[55, "Equatorial Guinea"],
[56, "Eritrea"],
[57, "Estonia"],
[58, "Ethiopia"],
[59, "Fiji"],
[60, "Finland"],
[61, "France"],
[62, "Gabon"],
[63, "Gambia"],
[64, "Georgia"],
[65, "Germany"],
[66, "Ghana"],
[67, "Greece"],
[68, "Grenada"],
[69, "Guatemala"],
[70, "Guinea"],
[71, "Guinea-Bissau"],
[72, "Guyana"],
[73, "Haiti"],
[74, "Honduras"],
[75, "Hong Kong (S.A.R.)"],
[76, "Hungary"],
[77, "Iceland"],
[78, "India"],
[79, "Indonesia"],
[80, "Iran, Islamic Republic of..."],
[81, "Iraq"],
[82, "Ireland"],
[83, "Israel"],
[84, "Italy"],
[85, "Jamaica"],
[86, "Japan"],
[87, "Jordan"],
[88, "Kazakhstan"],
[89, "Kenya"],
[90, "Kiribati"],
[91, "Kuwait"],
[92, "Kyrgyzstan"],
[93, "Lao People's Democratic Republic"],
[94, "Latvia"],
[95, "Lebanon"],
[96, "Lesotho"],
[97, "Liberia"],
[98, "Libyan Arab Jamahiriya"],
[99, "Liechtenstein"],
[100, "Lithuania"],
[101, "Luxembourg"],
[102, "Madagascar"],
[103, "Malawi"],
[104, "Malaysia"],
[105, "Maldives"],
[106, "Mali"],
[107, "Malta"],
[108, "Marshall Islands"],
[109, "Mauritania"],
[110, "Mauritius"],
[111, "Mexico"],
[112, "Micronesia, Federated States of..."],
[113, "Monaco"],
[114, "Mongolia"],
[115, "Montenegro"],
[116, "Morocco"],
[117, "Mozambique"],
[118, "Myanmar"],
[119, "Namibia"],
[120, "Nauru"],
[121, "Nepal"],
[122, "Netherlands"],
[123, "New Zealand"],
[124, "Nicaragua"],
[125, "Niger"],
[126, "Nigeria"],
[127, "North Korea"],
[128, "Norway"],
[129, "Oman"],
[130, "Pakistan"],
[131, "Palau"],
[132, "Panama"],
[133, "Papua New Guinea"],
[134, "Paraguay"],
[135, "Peru"],
[136, "Philippines"],
[137, "Poland"],
[138, "Portugal"],
[139, "Qatar"],
[140, "Republic of Korea"],
[141, "Republic of Moldova"],
[142, "Romania"],
[143, "Russian Federation"],
[144, "Rwanda"],
[145, "Saint Kitts and Nevis"],
[146, "Saint Lucia"],
[147, "Saint Vincent and the Grenadines"],
[148, "Samoa"],
[149, "San Marino"],
[150, "Sao Tome and Principe"],
[151, "Saudi Arabia"],
[152, "Senegal"],
[153, "Serbia"],
[154, "Seychelles"],
[155, "Sierra Leone"],
[156, "Singapore"],
[157, "Slovakia"],
[158, "Slovenia"],
[159, "Solomon Islands"],
[160, "Somalia"],
[161, "South Africa"],
[162, "South Korea"],
[163, "Spain"],
[164, "Sri Lanka"],
[165, "Sudan"],
[166, "Suriname"],
[167, "Swaziland"],
[168, "Sweden"],
[169, "Switzerland"],
[170, "Syrian Arab Republic"],
[171, "Tajikistan"],
[172, "Thailand"],
[173, "The former Yugoslav Republic of Macedonia"],
[174, "Timor-Leste"],
[175, "Togo"],
[176, "Tonga"],
[177, "Trinidad and Tobago"],
[178, "Tunisia"],
[179, "Turkey"],
[180, "Turkmenistan"],
[181, "Tuvalu"],
[182, "Uganda"],
[183, "Ukraine"],
[184, "United Arab Emirates"],
[185, "United Kingdom of Great Britain and Northern Ireland"],
[186, "United Republic of Tanzania"],
[187, "United States of America"],
[188, "Uruguay"],
[189, "Uzbekistan"],
[190, "Vanuatu"],
[191, "Venezuela, Bolivarian Republic of..."],
[192, "Viet Nam"],
[193, "Yemen"],
[194, "Zambia"],
[195, "Zimbabwe"],
],
label="f. Country - previous accommodation",
blank=False
)
q_46_logement_ville = models.StringField(
label="g. City - previous accommodation",
blank=False
)
q_31 = models.IntegerField() # nbre d'enfant
q_47_residence = models.IntegerField(
label="i. You currently live in:",
choices=[
[1, 'Bâtiment 103'],
[2, 'Another residence '],
],
widget=widgets.RadioSelect,
blank=False
)
q_48_satisfaction = models.IntegerField(
choices=[
[1, '1 - Very satisfied'],
[2, '2 - Satisfied '],
[3, '3 - Unsatisfied '],
[4, '4 - Very unsatisfied'],
],
widget=widgets.RadioSelect,
label="j. How satisfied are you with your place of residence? ",
blank=True
)
q_49_propositions = models.StringField(
label="k. Do you have any ideas or suggestions for improvements concerning your place of residence?",
blank=True
)
lastname = models.StringField(
label="Last Name",
blank=False
)
firstname = models.StringField(
label="First Name",
blank=False
)
email = models.StringField(
label="Email",
blank=False
)
room = models.StringField(
label="Room number (for example: 103.3.09)",
blank=False
)
id_in_group_nn = models.IntegerField(blank=True, null=True)
gainfinal_eur = models.FloatField(blank=True, null=True)
gainfinal_eur_showupfee = models.FloatField(blank=True, null=True)
gainfinal_asso_eur = models.FloatField(blank=True, null=True)
gainfinal_eur_f = models.FloatField(blank=True, null=True)
gainfinal_eur_showupfee_f = models.FloatField(blank=True, null=True)
gainfinal_asso_eur_f = models.FloatField(blank=True, null=True)
gainfinal_eur_showupfee_f2025 = models.FloatField(blank=True, null=True)