import random from otree.api import * class C(BaseConstants): NAME_IN_URL = 'exp' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): vectorHotelH = models.IntegerField(initial=0) vectorFlightH = models.IntegerField(initial=0) vectorTourH = models.IntegerField(initial=0) vectorConcertH = models.IntegerField(initial=0) vectorMatchH= models.IntegerField(initial=0) vectorDinnerH=models.IntegerField(initial=0) maxWTPhotel=models.IntegerField(label="What is the maximum € amount that you are willing to pay for the hotel room for two people?", min=10, max=100000) maxWTPflight = models.IntegerField(label="What is the maximum € amount that you are willing to pay for the flight for one person?", min=10, max=100000) maxWTPtour = models.IntegerField(label="What is the maximum € amount that you are willing to pay for the tour for one person?", min=10, max=100000) maxWTPconcert= models.IntegerField(label="What is the maximum € amount that you are willing to pay for the concert ticket for one person?", min=10, max=100000) maxWTPmatch = models.IntegerField(label="What is the maximum € amount that you are willing to pay for the match for one person?", min=10, max=100000) maxWTPdinner = models.IntegerField(label="What is the maximum € amount that you are willing to pay for the dinner per person (excluding drinks)?", min=1, max=100000) age = models.IntegerField(label='What is your age?', min=13, max=125, blank=True) nationality=models.StringField( choices=[['AD', 'Andorra'], ['AE', 'United Arab Emirates'], ['AF', 'Afghanistan'], ['AG', 'Antigua and Barbuda'], ['AL', 'Albania'], ['AM', 'Armenia'], ['AO', 'Angola'], ['AR', 'Argentina'], ['AT', 'Austria'], ['AU', 'Australia'], ['AZ', 'Azerbaijan'], ['BA', 'Bosnia and Herzegovina'], ['BB', 'Barbados'], ['BD', 'Bangladesh'], ['BE', 'Belgium'], ['BF', 'Burkina Faso'], ['BG', 'Bulgaria'], ['BH', 'Bahrain'], ['BI', 'Burundi'], ['BJ', 'Benin'], ['BN', 'Brunei'], ['BO', 'Bolivia'], ['BR', 'Brazil'], ['BS', 'Bahamas'], ['BT', 'Bhutan'], ['BW', 'Botswana'], ['BY', 'Belarus'], ['BZ', 'Belize'], ['CA', 'Canada'], ['CD', 'Democratic Republic of the Congo'], ['CF', 'Central African Republic'], ['CG', 'Congo (Brazzaville)'], ['CH', 'Switzerland'], ['CI', 'Cote d Ivoire'], ['CK', 'Cook Islands'], ['CL', 'Chile'], ['CM', 'Cameroon'], ['CN', 'China'], ['CO', 'Colombia'], ['CR', 'Costa Rica'], ['CU', 'Cuba'], ['CV', 'Cabo Verde'], ['CY', 'Cyprus'], ['CZ', 'Czechia'], ['DE', 'Germany'], ['DJ', 'Djibouti'], ['DK', 'Denmark'], ['DM', 'Dominica'], ['DO', 'Dominican Republic'], ['DZ', 'Algeria'], ['EC', 'Ecuador'], ['EE', 'Estonia'], ['EG', 'Egypt'], ['EH', 'Western Sahara'], ['ER', 'Eritrea'], ['ES', 'Spain'], ['ET', 'Ethiopia'], ['FI', 'Finland'], ['FJ', 'Fiji'], ['FM', 'Micronesia (Federated States of)'], ['FR', 'France'], ['GA', 'Gabon'], ['GB', 'United Kingdom of Great Britain and Northern Ireland'], ['GD', 'Grenada'], ['GE', 'Georgia'], ['GH', 'Ghana'], ['GM', 'Gambia'], ['GN', 'Guinea'], ['GQ', 'Equatorial Guinea'], ['GR', 'Greece'], ['GT', 'Guatemala'], ['GW', 'Guinea-Bissau'], ['GY', 'Guyana'], ['HN', 'Honduras'], ['HR', 'Croatia'], ['HT', 'Haiti'], ['HU', 'Hungary'], ['ID', 'Indonesia'], ['IE', 'Ireland'], ['IL', 'Israel'], ['IN', 'India'], ['IQ', 'Iraq'], ['IR', 'Iran (Islamic Republic of)'], ['IS', 'Iceland'], ['IT', 'Italy'], ['JM', 'Jamaica'], ['JO', 'Jordan'], ['JP', 'Japan'], ['KE', 'Kenya'], ['KG', 'Kyrgyzstan'], ['KH', 'Cambodia'], ['KI', 'Kiribati'], ['KM', 'Comoros'], ['KN', 'Saint Kitts and Nevis'], ['KP', 'North Korea'], ['KR', 'South Korea'], ['KW', 'Kuwait'], ['KZ', 'Kazakhstan'], ['LA', 'Laos'], ['LB', 'Lebanon'], ['LC', 'Saint Lucia'], ['LI', 'Liechtenstein'], ['LK', 'Sri Lanka'], ['LR', 'Liberia'], ['LS', 'Lesotho'], ['LT', 'Lithuania'], ['LU', 'Luxembourg'], ['LV', 'Latvia'], ['LY', 'Libya'], ['MA', 'Morocco'], ['MC', 'Monaco'], ['MD', 'Moldova'], ['ME', 'Montenegro'], ['MG', 'Madagascar'], ['MH', 'Marshall Islands'], ['MK', 'Macedonia'], ['ML', 'Mali'], ['MM', 'Myanmar'], ['MN', 'Mongolia'], ['MR', 'Mauritania'], ['MT', 'Malta'], ['MU', 'Mauritius'], ['MV', 'Maldives'], ['MW', 'Malawi'], ['MX', 'Mexico'], ['MY', 'Malaysia'], ['MZ', 'Mozambique'], ['NA', 'Namibia'], ['NE', 'Niger'], ['NG', 'Nigeria'], ['NI', 'Nicaragua'], ['NL', 'Netherlands'], ['NO', 'Norway'], ['NP', 'Nepal'], ['NR', 'Nauru'], ['NZ', 'New Zealand'], ['OM', 'Oman'], ['PA', 'Panama'], ['PE', 'Peru'], ['PG', 'Papua New Guinea'], ['PH', 'Philippines'], ['PK', 'Pakistan'], ['PL', 'Poland'], ['PS', 'Palestine'], ['PT', 'Portugal'], ['PW', 'Palau'], ['PY', 'Paraguay'], ['QA', 'Qatar'], ['RO', 'Romania'], ['RS', 'Serbia'], ['RU', 'Russia'], ['RW', 'Rwanda'], ['SA', 'Saudi Arabia'], ['SB', 'Solomon Islands'], ['SC', 'Seychelles'], ['SD', 'Sudan'], ['SE', 'Sweden'], ['SG', 'Singapore'], ['SI', 'Slovenia'], ['SK', 'Slovakia'], ['SL', 'Sierra Leone'], ['SM', 'San Marino'], ['SN', 'Senegal'], ['SO', 'Somalia'], ['SR', 'Suriname'], ['SS', 'South Sudan'], ['ST', 'Sao Tome and Principe'], ['SV', 'El Salvador'], ['SY', 'Syria'], ['SZ', 'Eswatini'], ['TD', 'Chad'], ['TG', 'Togo'], ['TH', 'Thailand'], ['TJ', 'Tajikistan'], ['TL', 'Timor-Leste'], ['TM', 'Turkmenistan'], ['TN', 'Tunisia'], ['TO', 'Tonga'], ['TR', 'Turkey'], ['TT', 'Trinidad and Tobago'], ['TV', 'Tuvalu'], ['TW', 'Taiwan'], ['TZ', 'Tanzania'], ['UA', 'Ukraine'], ['UG', 'Uganda'], ['US', 'United States'], ['UY', 'Uruguay'], ['UZ', 'Uzbekistan'], ['VA', 'Vatican City'], ['VC', 'Saint Vincent and the Grenadines'], ['VE', 'Venezuela'], ['VN', 'Vietnam'], ['VU', 'Vanuatu'], ['WS', 'Samoa'], ['YE', 'Yemen'], ['ZA', 'South Africa'], ['ZM', 'Zambia'], ['ZW', 'Zimbabwe'], ['Other', 'Other']], label="What is your nationality?", blank=True, ) #countryResidence=models.StringField(label="What is your current country of residence?", blank=True) gender = models.StringField( choices=[['Male', 'Male'], ['Female', 'Female'], ['None', 'None of the above']], label='What is your gender?', widget=widgets.RadioSelect, blank = True, ) att1 = models.IntegerField( label="1. Before making a purchase, I usually monitor prices for about a week (or longer)", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) att2 = models.IntegerField( label="2. Before making a purchase, I compare the prices offered by different sellers to choose the cheapest option", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) att3 = models.IntegerField( label="3. When I plan to purchase a good, I am concerned that the product will run out of stock before I can make the purchase", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) att4 = models.IntegerField( label="4. I often purchase goods when they are on sale", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) att5 = models.IntegerField( label="5. I like to wait for prices to drop before making a purchase", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) att6 = models.IntegerField( label="6. I often make purchases online", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) att7 = models.IntegerField( label="7. I often (at least three times a year) book a flight for leisure", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) buyHotel = models.StringField( choices=[['Yes', 'Yes'], ['No', 'No']], label='Given the price history you have observed in the last 10 days, would you book the hotel room at the current price (the price is for two people)?', widget=widgets.RadioSelect, ) buyFlight = models.StringField( choices=[['Yes', 'Yes'], ['No', 'No']], label='Given the price history you have observed in the last 10 days, would you buy the flight at the current price (price per person)?', widget=widgets.RadioSelect, ) buyTour= models.StringField( choices=[['Yes', 'Yes'], ['No', 'No']], label='Given the price history you have observed in the last 10 days, would you book the tour at the current price (price per person)?', widget=widgets.RadioSelect, ) buyConcert= models.StringField( choices=[['Yes', 'Yes'], ['No', 'No']], label='Given the price history you have observed in the last 10 days, would you buy the ticket at the current price (single ticket)?', widget=widgets.RadioSelect, ) buyMatch= models.StringField( choices=[['Yes', 'Yes'], ['No', 'No']], label='Given the price history you have observed in the last 10 days, would you buy the ticket at the current price (single ticket)?', widget=widgets.RadioSelect, ) buyDinner = models.StringField( choices=[['Yes', 'Yes'], ['No', 'No']], label='Given the price history you have observed in the last 10 days, would you book the dinner (excluding drinks) at the current price per person?', widget=widgets.RadioSelect, ) pref1 = models.StringField( choices=[['Opt1', '40€ with probability of 10% and 32€ with probability of 90%'], ['Opt2', '77€ with probability of 10% and 2€ with probability of 90%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref2 = models.StringField( choices=[['Opt1', '40€ with probability of 20% and 32€ with probability of 80%'], ['Opt2', '77€ with probability of 20% and 2€ with probability of 80%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref3 = models.StringField( choices=[['Opt1', '40€ with probability of 30% and 32€ with probability of 70%'], ['Opt2', '77€ with probability of 30% and 2€ with probability of 70%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref4 = models.StringField( choices=[['Opt1', '40€ with probability of 40% and 32€ with probability of 60%'], ['Opt2', '77€ with probability of 40% and 2€ with probability of 60%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref5 = models.StringField( choices=[['Opt1', '40€ with probability of 50% and 32€ with probability of 50%'], ['Opt2', '77€ with probability of 50% and 2€ with probability of 50%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref6 = models.StringField( choices=[['Opt1', '40€ with probability of 60% and 32€ with probability of 40%'], ['Opt2', '77€ with probability of 60% and 2€ with probability of 40%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref7 = models.StringField( choices=[['Opt1', '40€ with probability of 70% and 32€ with probability of 30%'], ['Opt2', '77€ with probability of 70% and 2€ with probability of 30%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref8 = models.StringField( choices=[['Opt1', '40€ with probability of 80% and 32€ with probability of 20%'], ['Opt2', '77€ with probability of 80% and 2€ with probability of 20%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref9 = models.StringField( choices=[['Opt1', '40€ with probability of 90% and 32€ with probability of 10%'], ['Opt2', '77€ with probability of 90% and 2€ with probability of 10%']], label='Would you prefer to get', widget=widgets.RadioSelectHorizontal, ) pref10 = models.StringField( choices=[['Opt1', '40€ with probability of 100% and 32€ with probability of 0%'], ['Opt2', '77€ with probability of 100% and 2€ with probability of 0%']], label='Would you prefer', widget=widgets.RadioSelectHorizontal, ) good1 = models.IntegerField( label="1. A hotel room for a weekend out in a major European city", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) good2 = models.IntegerField( label="2. A flight to a European destination", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) good3 = models.IntegerField( label="3. A guided tour in a European capital", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) good4 = models.IntegerField( label="4. A concert of a famous international star/band", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) good5 = models.IntegerField( label="5. A ticket for the final Champions League football match", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) good6 = models.IntegerField( label="6. A dinner in a one-star Michelin restaurant", choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelectHorizontal ) game1 = models.StringField( choices=[['43', '43'], ['14', '14'], ['36', '36'], ['24', '24']], label='There are 50 dogs signed up for a dog show. There are 36 more small dogs than large dogs. How many small dogs have signed up to compete? ', widget=widgets.RadioSelect, ) game2 = models.StringField( choices=[['26', '26'], ['39', '39'], ['41', '41'], ['54', '54']], label='Sally is 54 years old and her mother is 80, how many years ago was Sally’s mother three times her age?', widget=widgets.RadioSelect, ) game3 = models.StringField( choices=[['Opt1', '57'], ['Opt2', '124'], ['Opt3', '81'], ['Opt4', '99']], label = 'A man is climbing up a mountain which is inclined. He has to travel 100 km to reach the top of the mountain. Every day He climbs up 2 km forward in the day time. Exhausted, he then takes rest there at night time. At night, while he is asleep, he slips down 1 km backwards because the mountain is inclined. Then how many days does it take him to reach the mountain top? ', widget = widgets.RadioSelect, ) game4 = models.StringField( choices=[['Opt1', '18'], ['Opt2', '16'], ['Opt3', '20'], ['Opt4', '22']], label = 'Look at this series: 36, 34, 30, 28, 24, … What number should come next?', widget = widgets.RadioSelect, ) game5 = models.StringField( choices=[['Opt1', '1'], ['Opt2', '2'], ['Opt3', 'None']], label = 'How many of your above 2 answers do you think are correct?', widget = widgets.RadioSelect, ) comments=models.LongStringField(label="Please provide your comments and suggestions on the experiment.", blank=True) # FUNCTIONS def creating_session(subsession): for player in subsession.get_players(): res = random.sample(range(0, 6), 6) res[3] = 6 + res[3] res[4] = 6 + res[4] res[5] = 6 + res[5] random.shuffle(res) player.vectorHotelH = res[0] player.vectorFlightH = res[1] player.vectorTourH = res[2] player.vectorConcertH = res[3] player.vectorMatchH = res[4] player.vectorDinnerH = res[5] # PAGES class Instructions(Page): form_model = 'player' class Section2(Page): form_model = 'player' class HotelReservation(Page): form_model = 'player' form_fields = ['maxWTPhotel'] class HotelReservationChart(Page): form_model = 'player' form_fields=['buyHotel'] @staticmethod def js_vars(player): return dict( a=player.maxWTPhotel, rand=player.vectorHotelH ) class Flight(Page): form_model = 'player' form_fields = ['maxWTPflight'] class FlightChart(Page): form_model = 'player' form_fields=['buyFlight'] @staticmethod def js_vars(player): return dict( a=player.maxWTPflight, rand=player.vectorFlightH ) class Tour(Page): form_model = 'player' form_fields = ['maxWTPtour'] class TourChart(Page): form_model = 'player' form_fields=['buyTour'] @staticmethod def js_vars(player): return dict( a=player.maxWTPtour, rand=player.vectorTourH ) class Concert(Page): form_model = 'player' form_fields = ['maxWTPconcert'] class ConcertChart(Page): form_model = 'player' form_fields=['buyConcert'] @staticmethod def js_vars(player): return dict( a=player.maxWTPconcert, rand=player.vectorConcertH ) class Match(Page): form_model = 'player' form_fields = ['maxWTPmatch'] class MatchChart(Page): form_model = 'player' form_fields=['buyMatch'] @staticmethod def js_vars(player): return dict( a=player.maxWTPmatch, rand=player.vectorMatchH ) class Dinner(Page): form_model = 'player' form_fields = ['maxWTPdinner'] class DinnerChart(Page): form_model = 'player' form_fields=['buyDinner'] @staticmethod def js_vars(player): return dict( a=player.maxWTPdinner, rand=player.vectorDinnerH ) class DemographicsExp(Page): form_model = 'player' form_fields = ['age', 'gender', 'nationality'] class Games(Page): form_model='player' form_fields = ['pref1', 'pref2', 'pref3', 'pref4', 'pref5', 'pref6', 'pref7', 'pref8', 'pref9', 'pref10'] class Games2(Page): form_model = 'player' form_fields = ['game1', 'game2', 'game5'] class ResultsGames(Page): form_model = 'player' @staticmethod def js_vars(player): return dict( g1=player.game1, g2=player.game2 ) class PilotComments(Page): form_model='player' form_fields= ['comments'] class Attitudes(Page): form_model='player' form_fields=['att1', 'att2', 'att3', 'att4', 'att5', 'att6', 'att7'] class GoodsInterests(Page): form_model = 'player' form_fields = ['good1', 'good2', 'good3', 'good4', 'good5', 'good6'] page_sequence = [Instructions, HotelReservation, Flight, Tour, Concert, Match, Dinner, GoodsInterests, DemographicsExp, Attitudes, Games, Games2, HotelReservationChart, FlightChart, TourChart, ConcertChart, MatchChart, DinnerChart, ResultsGames] #page_sequence = [GoodsInterests, HotelReservation, Flight, Tour, Concert, Match, Dinner, HotelReservationChart, FlightChart, TourChart, ConcertChart, MatchChart, DinnerChart]