from otree.api import * c = cu doc = '' class Constants(BaseConstants): name_in_url = 'my_survey' players_per_group = None num_rounds = 1 initial_money = cu(5000000) question1_monetary = (cu(0), cu(150000), cu(1500000), cu(750000), cu(2250000)) question1_environment = (0, 1, 3, 4, 5) question2_monetary = (cu(0), cu(12300), cu(45000), cu(30500), cu(150000), cu(80000)) question2_environment = (0, 1, 3, 2, 5, 4) question3_monetary = (0, 450000, 250000, 300000, 200000) question3_environment = (0, 5, 2, 3, 2) question4_monetary = (0, 0, 4000000, 3000000, 1500000) question4_environment = (0, 1, 5, 4, 3) def creating_session(subsession): session = subsession.session import itertools treatment = itertools.cycle([True, False]) for player in subsession.get_players(): player.is_primed = next(treatment) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent = models.BooleanField(choices=[[True, 'Yes'], [False, 'No']], label='Do you agree to participate?', widget=widgets.RadioSelect) gender = models.StringField(choices=[['Male', 'Male'], ['Female', 'Female'], ['Non-binary', 'Non-binary'], ['Other', 'Other']], label='What is your gender?', widget=widgets.RadioSelect) nationality = models.StringField(choices=[['Afghanistan', 'Afghanistan'], ['Albania', 'Albania'], ['Algeria', 'Algeria'], ['Andorra', 'Andorra'], ['Angola', 'Angola'], ['Antigua & Barbuda', 'Antigua & Barbuda'], ['Argentina', 'Argentina'], ['Armenia', 'Armenia'], ['Australia', 'Australia'], ['Austria', 'Austria'], ['Azerbaijan', 'Azerbaijan'], ['The Bahamas', 'The Bahamas'], ['Bahrain', 'Bahrain'], ['Bangladesh', 'Bangladesh'], ['Barbados', 'Barbados'], ['Belarus', 'Belarus'], ['Belgium', 'Belgium'], ['Belize', 'Belize'], ['Benin', 'Benin'], ['Bermuda', 'Bermuda'], ['Bhutan', 'Bhutan'], ['Bolivia', 'Bolivia'], ['Bosnia & Herzegovina', 'Bosnia & Herzegovina'], ['Botswana', 'Botswana'], ['Brazil', 'Brazil'], ['Brunei', 'Brunei'], ['Bulgaria', 'Bulgaria'], ['Burkina Faso', 'Burkina Faso'], ['Burundi', 'Burundi'], ['Cambodia', 'Cambodia'], ['Cameroon', 'Cameroon'], ['Canada', 'Canada'], ['Cape Verde', 'Cape Verde'], ['Central African Republic', 'Central African Republic'], ['Chad', 'Chad'], ['Chile', 'Chile'], ['China', 'China'], ['Colombia', 'Colombia'], ['Comoros', 'Comoros'], ['Costa Rica', 'Costa Rica'], ["Cote d'Ivoire", "Cote d'Ivoire"], ['Croatia', 'Croatia'], ['Cuba', 'Cuba'], ['Cyprus', 'Cyprus'], ['Czech Republic', 'Czech Republic'], ['Democratic Republic of the Congo', 'Democratic Republic of the Congo'], ['Denmark', 'Denmark'], ['Djibouti', 'Djibouti'], ['Dominica', 'Dominica'], ['Dominican Republic', 'Dominican Republic'], ['East Timor', 'East Timor'], ['Ecuador', 'Ecuador'], ['Egypt', 'Egypt'], ['El Salvador', 'El Salvador'], ['Equatorial Guinea', 'Equatorial Guinea'], ['Eritrea', 'Eritrea'], ['Estonia', 'Estonia'], ['Ethiopia', 'Ethiopia'], ['Federated States of Micronesia', 'Federated States of Micronesia'], ['Fiji', 'Fiji'], ['Finland', 'Finland'], ['France', 'France'], ['Gabon', 'Gabon'], ['Gambia', 'Gambia'], ['Georgia', 'Georgia'], ['Germany', 'Germany'], ['Ghana', 'Ghana'], ['Greece', 'Greece'], ['Grenada', 'Grenada'], ['Guatemala', 'Guatemala'], ['Guinea', 'Guinea'], ['Guinea-Bissau', 'Guinea-Bissau'], ['Guyana', 'Guyana'], ['Haiti', 'Haiti'], ['Honduras', 'Honduras'], ['Hungary', 'Hungary'], ['Iceland', 'Iceland'], ['India', 'India'], ['Indonesia', 'Indonesia'], ['Iran', 'Iran'], ['Iraq', 'Iraq'], ['Ireland', 'Ireland'], ['Israel', 'Israel'], ['Italy', 'Italy'], ['Jamaica', 'Jamaica'], ['Japan', 'Japan'], ['Jordan', 'Jordan'], ['Kazakhstan', 'Kazakhstan'], ['Kenya', 'Kenya'], ['Kiribati', 'Kiribati'], ['Kosovo', 'Kosovo'], ['Kuwait', 'Kuwait'], ['Kyrgyzstan', 'Kyrgyzstan'], ['Laos', 'Laos'], ['Latvia', 'Latvia'], ['Lebanon', 'Lebanon'], ['Lesotho', 'Lesotho'], ['Liberia', 'Liberia'], ['Libya', 'Libya'], ['Liechtenstein', 'Liechtenstein'], ['Lithuania', 'Lithuania'], ['Luxembourg', 'Luxembourg'], ['North Macedonia', 'North Macedonia'], ['Madagascar', 'Madagascar'], ['Malawi', 'Malawi'], ['Malaysia', 'Malaysia'], ['Maldives', 'Maldives'], ['Mali', 'Mali'], ['Malta', 'Malta'], ['Marshall Islands', 'Marshall Islands'], ['Mauritania', 'Mauritania'], ['Mauritius', 'Mauritius'], ['Mexico', 'Mexico'], ['Moldova', 'Moldova'], ['Monaco', 'Monaco'], ['Mongolia', 'Mongolia'], ['Montenegro', 'Montenegro'], ['Morocco', 'Morocco'], ['Mozambique', 'Mozambique'], ['Myanmar', 'Myanmar'], ['Namibia', 'Namibia'], ['Nauru', 'Nauru'], ['Nepal', 'Nepal'], ['Netherlands', 'Netherlands'], ['New Zealand', 'New Zealand'], ['Nicaragua', 'Nicaragua'], ['Niger', 'Niger'], ['Nigeria', 'Nigeria'], ['North Korea', 'North Korea'], ['Norway', 'Norway'], ['Oman', 'Oman'], ['Pakistan', 'Pakistan'], ['Palau', 'Palau'], ['Palestine', 'Palestine'], ['Panama', 'Panama'], ['Papua New Guinea', 'Papua New Guinea'], ['Paraguay', 'Paraguay'], ['Peru', 'Peru'], ['Philippines', 'Philippines'], ['Poland', 'Poland'], ['Portugal', 'Portugal'], ['Qatar', 'Qatar'], ['Republic of the Congo', 'Republic of the Congo'], ['Romania', 'Romania'], ['Russia', 'Russia'], ['Rwanda', 'Rwanda'], ['Saint Kitts & Nevis', 'Saint Kitts & Nevis'], ['Saint Lucia', 'Saint Lucia'], ['Saint Vincent and the Grenadines', 'Saint Vincent and the Grenadines'], ['Samoa', 'Samoa'], ['San Marino', 'San Marino'], ['Sao Tome & Principe', 'Sao Tome & Principe'], ['Saudi Arabia', 'Saudi Arabia'], ['Senegal', 'Senegal'], ['Serbia', 'Serbia'], ['Seychelles', 'Seychelles'], ['Sierra Leone', 'Sierra Leone'], ['Singapore', 'Singapore'], ['Slovakia', 'Slovakia'], ['Slovenia', 'Slovenia'], ['Solomon Islands', 'Solomon Islands'], ['Somalia', 'Somalia'], ['South Africa', 'South Africa'], ['South Korea', 'South Korea'], ['South Sudan', 'South Sudan'], ['Spain', 'Spain'], ['Sri Lanka', 'Sri Lanka'], ['Sudan', 'Sudan'], ['Suriname', 'Suriname'], ['eSwatini', 'eSwatini'], ['Sweden', 'Sweden'], ['Switzerland', 'Switzerland'], ['Syria', 'Syria'], ['Taiwan', 'Taiwan'], ['Tajikistan', 'Tajikistan'], ['Tanzania', 'Tanzania'], ['Thailand', 'Thailand'], ['Togo', 'Togo'], ['Tonga', 'Tonga'], ['Trinidad & Tobago', 'Trinidad & Tobago'], ['Tunisia', 'Tunisia'], ['Turkey', 'Turkey'], ['Turkmenistan', 'Turkmenistan'], ['Tuvalu', 'Tuvalu'], ['Uganda', 'Uganda'], ['Ukraine', 'Ukraine'], ['United Arab Emirates', 'United Arab Emirates'], ['United Kingdom', 'United Kingdom'], ['United States', 'United States'], ['Uruguay', 'Uruguay'], ['Uzbekistan', 'Uzbekistan'], ['Vanuatu', 'Vanuatu'], ['Vatican City', 'Vatican City'], ['Venezuela', 'Venezuela'], ['Vietnam', 'Vietnam'], ['Yemen', 'Yemen'], ['Zambia', 'Zambia'], ['Zimbabwe', 'Zimbabwe']], label='What is your nationality?') is_primed = models.BooleanField() understanding_difficulty = models.StringField(choices=[['Very difficult', 'Very difficult'], ['Difficult', 'Difficult'], ['Okay', 'Okay'], ['Easy', 'Easy'], ['Very easy', 'Very easy']], label='How difficult was it for you to understand the information?', widget=widgets.RadioSelectHorizontal) budget_difficulty = models.StringField(choices=[['Very difficult', 'Very difficult'], ['Difficult', 'Difficult'], ['Okay', 'Okay'], ['Easy', 'Easy'], ['Very easy', 'Very easy']], label='How difficult was it for you to allocate the budget?', widget=widgets.RadioSelectHorizontal) comments = models.LongStringField(blank=True, label='Comments for the researchers (optional)') email = models.StringField(blank=True, label='Your e-mail address') survey_results = models.BooleanField(choices=[[True, 'Yes'], [False, 'No']], initial=True, label='Would you like us to share the results of this research with you?', widget=widgets.RadioSelect) edu_level = models.StringField(choices=[['No schooling completed', 'No schooling completed'], ['Elementary up to secondary school ', 'Elementary up to secondary school '], ['High school', 'High school'], ['Trade/technical/vocational training', 'Trade/technical/vocational training'], ['Bachelor’s degree', 'Bachelor’s degree'], ['Master’s degree', 'Master’s degree'], ['Doctorate degree', 'Doctorate degree']], label='What is the highest level of education you have completed?') age = models.StringField(choices=[['18-24 years old', '18-24 years old'], ['25-34 years old', '25-34 years old'], ['35-44 years old', '35-44 years old'], ['45-54 years old', '45-54 years old'], ['55-64 years old', '55-64 years old'], ['65-74 years old', '65-74 years old'], ['75 years or older', '75 years or older']], label='What is your age?') edu_field = models.StringField(choices=[['Not Applicable', 'Not Applicable'], ['Agriculture, Forestry, Fishery, Veterinary Medicine', 'Agriculture, Forestry, Fishery, Veterinary Medicine'], ['Arts & Humanities', 'Arts & Humanities'], ['Business Administration', 'Business Administration'], ['Education', 'Education'], ['Engineering and Construction', 'Engineering and Construction'], ['Environmental Sciences', 'Environmental Sciences'], ['Health and Welfare', 'Health and Welfare'], ['Law', 'Law'], ['Life Sciences', 'Life Sciences'], ['Mathematics and Statistics', 'Mathematics and Statistics'], ['Physical Sciences', 'Physical Sciences'], ['Services', 'Services'], ['Social and Behavioral Sciences', 'Social and Behavioral Sciences'], ['Other not listed', 'Other not listed']], label='If applicable, what is your field of studies?') question1 = models.IntegerField(choices=[[1, 'Polyester'], [2, 'Cotton'], [3, 'Hemp'], [4, 'Lyocell']], initial=0, label='
Remarks
Environmental Performance Index: 100 means perfect environmental performance/state of sustainability, 0 means no consideration of environmental issues and sustainability at all. For comparison, Austria’s Environmental Performance Index is 79,6.
Minimum wage as percent of living wage means the percentage at which someone can finance their life with the minimum wage in order to live above the poverty line.
', widget=widgets.RadioSelect) question3 = models.IntegerField(choices=[[1, 'Company A'], [2, 'Company B'], [3, 'Company C'], [4, 'Company D']], initial=0, label='Remarks
Transparency: A score of 100 means the company clearly and accurately communicates all its environmental and social impacts, while a score of 0 means they don’t disclose any information at all.
', widget=widgets.RadioSelect) question4 = models.IntegerField(choices=[[1, 'Landfill'], [2, 'Second-Hand'], [3, 'Recycling'], [4, 'Downcycling']], initial=0, label='Remarks
Landfill: you follow current industry practices by providing no after-life care, so the used clothes end up in the landfill.
Second-Hand: you set up collection points for the used textiles and ship them to developing countries where they are reused.
Recycling: you process the textiles to make new clothes again.
Downcycling: you process the textiles and sell them to make insulation materials for buildings.
', widget=widgets.RadioSelect) class Welcome(Page): form_model = 'player' form_fields = ['consent'] @staticmethod def error_message(player, values): if not values['consent']: return "Please select 'Yes' to continue." class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'nationality', 'edu_level', 'edu_field'] class Instructions(Page): form_model = 'player' class SceneSetting(Page): form_model = 'player' class Article(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.is_primed class Game(Page): form_model = 'player' form_fields = ['question1', 'question2', 'question3', 'question4'] @staticmethod def vars_for_template(player): return dict() @staticmethod def js_vars(player): return { "initialMoney": Constants.initial_money, "monetaryImpact": [Constants.question1_monetary, Constants.question2_monetary, Constants.question3_monetary, Constants.question4_monetary], "environmentImpact": [Constants.question1_environment, Constants.question2_environment, Constants.question3_environment, Constants.question4_environment], "decisions": [player.question1, player.question2,player.question3,player.question4] } @staticmethod def error_message(player, values): if Constants.initial_money - Constants.question1_monetary[values['question1']] - Constants.question2_monetary[values['question2']] - Constants.question3_monetary[values['question3']] - Constants.question4_monetary[values['question4']] < 0: return "You cannot spend more money than you have. Check your selections." class Closing(Page): form_model = 'player' form_fields = ['understanding_difficulty', 'budget_difficulty', 'survey_results', 'comments', 'email'] @staticmethod def vars_for_template(player): final_money = Constants.initial_money - Constants.question1_monetary[player.question1] - Constants.question2_monetary[player.question2] - Constants.question3_monetary[player.question3] - Constants.question4_monetary[player.question4] thousand = 1000 million = thousand * thousand if 4 * million <= final_money: donation_amount = 5 elif 3 * million <= final_money: donation_amount = 10 elif 2 * million <= final_money: donation_amount = 15 elif 1 * million <= final_money: donation_amount = 20 else: donation_amount = 25 win_amount = 30 - donation_amount return { "donation_amount": donation_amount, "win_amount": win_amount } @staticmethod def js_vars(player): return { "final_money": Constants.initial_money - Constants.question1_monetary[player.question1] - Constants.question2_monetary[player.question2] - Constants.question3_monetary[player.question3] - Constants.question4_monetary[player.question4], "star_sum": (Constants.question1_environment[player.question1] + Constants.question2_environment[player.question2] + Constants.question3_environment[player.question3] + Constants.question4_environment[player.question4]) } @staticmethod def before_next_page(player, timeout_happened): pass class Final(Page): form_model = 'player' page_sequence = [Welcome, Demographics, Instructions, SceneSetting, Article, Game, Closing, Final]