Test_Johanne/exp_e4c_en_p5_questfin/models.py

627 lines
18 KiB
Python
Raw Normal View History

2025-03-06 10:28:01 +01:00
from otree.api import (
models,
widgets,
BaseConstants,
BaseSubsession,
BaseGroup,
BasePlayer,
Currency as c,
currency_range,
)
doc = """
author = 'Wael Bousselmi'
Exp E4C
version: EN
"""
class Constants(BaseConstants):
name_in_url = 'exp_e4c_en_p5_questfin'
players_per_group = None
num_rounds = 1
showupfee = 5
instructions_GP_template = 'exp_e4c_en_p5_questfin/instructions.html'
instructions_BW_template = 'exp_e4c_en_p5_questfin/Risk_BinsWanger_qc.html'
gainriskAred = 8#4
gainriskBred = 6#3
gainriskCred = 4#2
gainriskDred = 2#1
gainriskEred = 0#0
gainriskAgreen = 8#4
gainriskBgreen = 12#6
gainriskCgreen = 16#8
gainriskDgreen = 20#10
gainriskEgreen = 24#12
tauxchange = 0.8 # 1 ecu = 0.8 €
class Subsession(BaseSubsession):
def vars_for_admin_report(self):
report = list()
for p in self.get_players():
report.append(dict(id=p.participant.id_in_session,
label=p.participant.label,
treatmentname = p.treatmentname,
jeu_tire=p.jeu_tire,
jeuname = p.jeuname,
gainfinal=p.gainfinal,
gaineur=p.gaineur,
gainfinaleur=p.gainfinaleur,
))
return dict(report=report)
class Group(BaseGroup):
pass
class Player(BasePlayer):
treatment = models.IntegerField()
treatmentname = models.StringField()
langue = models.StringField()
langue_nn = models.IntegerField()
def role(self):
return {1: 'A', 2: 'B'}[self.id_in_group]
######### var jeu Binswanger
choicerisk = models.IntegerField(
blank=False,
)
choicerisknn = models.StringField()
tc3 = models.StringField()
tiragecolor = models.FloatField()
colorbutton = models.IntegerField()
colorselect = models.IntegerField()
colorselectnn = models.StringField()
gainrisk = models.FloatField()
gainriskeur = models.FloatField()
gainriskeurfinal = models.FloatField()
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.",
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
)
### jeu 2 : Gneezy&Potters
tirageriskresult_j1 = models.StringField()
risk11_a_j1 = models.FloatField()
risk11_b_j1 = models.FloatField()
gainrisk_j1 = models.FloatField()
tirageausort = models.FloatField()
jeu_tire = models.IntegerField()
gainfinal = models.FloatField()
#gainfinalecu = models.FloatField()
#gainfinalplushowup = models.FloatField()
gaineur = models.FloatField()
gainfinaleur = models.FloatField()
gainfinaleur_v1 = models.FloatField()
jeuname = models.StringField()
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",
blank=False
)