# -*- coding: utf-8 -*- # from __future__ import division from otree.constants import BaseConstants from otree.models import BaseSubsession, BaseGroup, BasePlayer from otree import widgets import random from otree.common import Currency as c, currency_range # import django.forms.widgets #to delete block below # from jsonfield import JSONField from otree.db import models import otree.models import otree.constants from otree import widgets from otree import forms from otree.common import Currency as c, currency_range import random from django.core.validators import MaxLengthValidator, MinLengthValidator from django import forms #end of deleting block doc = """ “as to foresight they [men] were utter strangers to it, and far from troubling their heads about a distant futurity, they scarce thought of the day following. Was a deer to be taken? Every one saw that to succeed he must faithfully stand to his post; but suppose a hare to have slipped by within reach of any one of them, it is not to be doubted but he pursued it without scruple, and when he had seized his prey never reproached himself with having made his companions miss theirs.” Jean-Jacques Rousseau. “A Discourse Upon the Origin and the Foundation Of The Inequality Among Mankind.” pp 64-65. . """ from otree.db import models class Constants(BaseConstants): priming_time = 50 hunting_time = 75 #before:57 delayarray=[9,15,11,17,17] #before:[9,15,11,17] #when calculating splits relative to total hunting #time, consider that timer restarts at value+1 name_in_url = 'decision_making' players_per_group = None num_rounds = 1 waiting_partner_time=15 #how long waiting partner page will be shown frequency=5000 #first is the payoff of a player, second - a payoff of another stag_stag_amount = c(1) #trial4:2, trial1:3, trial2: 2 stag_hare_amount = c(0) # hare_stag_amount = c(.5) #trial1 .5, trial2: 1 hare_hare_amount = c(.5) #trial1 .5, trial2: 1 postgame_earnings =c(0.3) class Subsession(BaseSubsession): def before_session_starts(self): for p in self.get_players(): p.treatment = random.choice([True, False]) class Group(BaseGroup): pass #for time experimenting from django.utils import timezone #dont forget to delete above later # Columsn of player attributes class Player(BasePlayer): #########experimenting with own timer questionnaire_start_time = models.DateTimeField() priming_start_time = models.DateTimeField() hunting_start_time = models.DateTimeField() last_page_time = models.DateTimeField() hunting_refreshed=models.PositiveSmallIntegerField() hunting_thinkingtime = models.CharField() over_ontimeout=models.PositiveSmallIntegerField() def hunting_time_left(self): start = self.hunting_start_time now = timezone.now() time_left = Constants.hunting_time - (now - start).seconds return time_left if time_left > 0 else 0 def priming_time_left(self): start = self.priming_start_time now = timezone.now() time_left = Constants.priming_time - (now - start).seconds return time_left if time_left > 0 else 0 #end of exper with timer treatment=models.BooleanField() age = models.IntegerField( verbose_name="How old are you (in years)?", ) gender = models.CharField( verbose_name="Please indicate your sex", choices=['Male', 'Female'], ) education = models.CharField( verbose_name="What is the highest level of education you have completed?", choices= [ "No formal schooling completed, or less than 1 year", "Some primary schooling (not completed)", "Primary school completed", "Some high school (not completed)", "High school completed (or equivalent)", "Some college (1-4 years, not completed)", "Associate’s degree (including occupational or academic degrees)", "Bachelor’s degree (BA, BS, AB, etc)", "Master’s degree (MA, MS, MENG, MSW, etc)", "Professional school degree (MD, DDC, JD, etc)", "Doctorate degree (PhD, EdD, etc)" ], ) occupation = models.CharField( verbose_name="What is your principal occupation?", choices=[ "Doing housework, looking after children or other persons", "Full-time work", "Part-time work", "In education", "Unemployed/looking for a job", "Retired", "Other", ], ) hhsize = models.CharField( verbose_name="Including you, how many people live in your household?", choices=[ "1", "2", "3", "4", "5", "6", "7", "8", "9 or more", ], ) income = models.CharField( verbose_name="What is your current annual household income before tax?", choices=[ "Currently have no income", "0-10,000$/year", "10,000-20,000$/year", "20,000-30,000$/year", "30,000-40,000$/year", "40,000-60,000$/year", "60,000-100,000$/year" , "over 100,000$/year", ], ) satisfied = models.CharField( verbose_name="Overall, how satisfied are you with your life?", choices=[ "Very satisfied", "Satisfied", "Neither unsatisfied nor satisfied", "Unsatisfied", "Very unsatisfied", ], ) poverty = models.BooleanField( verbose_name="During the last month, did you experience any difficulties in paying your regular bills?", # choices=['Yes', 'No'], ) savings = models.CharField( verbose_name="How much money do you manage to save each month?", choices=["Practically none", "Under $50", "$50-$100", "$100-$200", "$200-$500", "$500-$1,000", "$1,000 or more", ], ) race = models.CharField( verbose_name="Which category describes you best?", choices = ["Hispanic", "Black or African American", "White", "Asian", "American Indian or Alaska Native", "Middle Eastern or North African" , "Native Hawaiian or Other Pacific Islander", "Another race, ethnicity, or origin", ], # # widget = forms.CheckboxSelectMultiple, ) children = models.CharField( verbose_name="Do you have children?", choices=["no", "yes, 1 child", "yes, 2 children", "yes, 3 children", "yes, 4 children", "yes, 5 children", "yes, 6 children", "yes, 7 children or more", ] ) states = { 'AK': 'Alaska', 'AL': 'Alabama', 'AR': 'Arkansas', 'AS': 'American Samoa', 'AZ': 'Arizona', 'CA': 'California', 'CO': 'Colorado', 'CT': 'Connecticut', 'DC': 'District of Columbia', 'DE': 'Delaware', 'FL': 'Florida', 'GA': 'Georgia', 'GU': 'Guam', 'HI': 'Hawaii', 'IA': 'Iowa', 'ID': 'Idaho', 'IL': 'Illinois', 'IN': 'Indiana', 'KS': 'Kansas', 'KY': 'Kentucky', 'LA': 'Louisiana', 'MA': 'Massachusetts', 'MD': 'Maryland', 'ME': 'Maine', 'MI': 'Michigan', 'MN': 'Minnesota', 'MO': 'Missouri', 'MP': 'Northern Mariana Islands', 'MS': 'Mississippi', 'MT': 'Montana', 'NA': 'National', 'NC': 'North Carolina', 'ND': 'North Dakota', 'NE': 'Nebraska', 'NH': 'New Hampshire', 'NJ': 'New Jersey', 'NM': 'New Mexico', 'NV': 'Nevada', 'NY': 'New York', 'OH': 'Ohio', 'OK': 'Oklahoma', 'OR': 'Oregon', 'PA': 'Pennsylvania', 'PR': 'Puerto Rico', 'RI': 'Rhode Island', 'SC': 'South Carolina', 'SD': 'South Dakota', 'TN': 'Tennessee', 'TX': 'Texas', 'UT': 'Utah', 'VA': 'Virginia', 'VI': 'Virgin Islands', 'VT': 'Vermont', 'WA': 'Washington', 'WI': 'Wisconsin', 'WV': 'West Virginia', 'WY': 'Wyoming', 'Xouts': 'Outside the USA', } STATE_CHOICE=[] temp = [] for key, value in sorted(states.items()): temp = [key, value] STATE_CHOICE.append(temp) state = models.CharField( verbose_name="Which state do you currently live in?", choices=STATE_CHOICE, ) # passed_the_test=models.BooleanField() remember_sum = models.CharField( verbose_name="What was the sum required for the treatment?", choices=["$50", "$100", "$150", "$500", "$1,000", "$1,500", "$2,000", "$3,500", "$4,500"] ) think_stag = models.CharField( verbose_name="How present in your mind was the dentist scenario while you made your decisions in the hunting task?", choices=["Very present", "Somewhat present", "Not very present", "Not present at all"] ) stress_sum = models.CharField( verbose_name="Do you feel financially stressed when thinking about this scenario?", choices=["Yes, a lot", "Yes, somewhat", "No, not very much", "No, not at all"] # previously: verbose_name="The decision would cause me severe financial stress.", # choices=["Agree fully", "Agree somewhat", "Neither agree nor disagree", "Disagree somewhat", "Fully disagree"] ) touch= models.BooleanField( verbose_name="The decision would require me to touch my savings.") loan = models.BooleanField(verbose_name="The decision would require me to take out a loan.") friends = models.BooleanField(verbose_name="I would ask my friends or family for financial support.") payrate = models.CharField( verbose_name="How frequently are you paid/how frequently do you receive your salary, wage, pension etc.?", choices=[ "Once every week", "Once every two weeks", "Once every month", "At a different rate", "Not applicable", ] ) lastpay = models.CharField( verbose_name="When were you last paid/when did you receive your last salary, wage, pension etc.?", choices=[ "This week", "Last week", "Two weeks ago", "Three weeks ago", "Four weeks ago", "More than four weeks ago", "Not applicable", ] ) traveltime = models.CharField( verbose_name="Imagine you went shopping for a new home appliance. You find yourself at a store that sells the model you have decided on for $500. Earlier that day, you had seen another store that sells exactly the same model for $470 (i.e. $30 less), however. Assuming that there were no additional costs for traveling: Would you travel back to the other store, and what would be the maximum amount of time you would spend on traveling back there?", choices=[ "No, I would not travel back to the other store", "I would travel back if it took me 15 min or less", "I would travel back if it took me 30 min or less", "I would travel back if it took me 45 min or less", "I would travel back if it took me 1 hours or less", "I would travel back if it took me 2 hours or less", "I would travel back if it took me 3 hours or less", "I would travel back if it took me 4 hours or less", "I would travel back even if it took me 5 hours or more", ] ) risks = models.CharField( verbose_name="How much do you like to take risks?", choices=[ "I like to take risks", "I don’t mind taking risks", "I am careful not to take too many risks", "I do not like to take risks", ] ) paid_tomorrow = models.CharField( verbose_name="Imagine you could choose to be paid $15 today, or you could choose to be paid $30 in two weeks. Which of the following describes best what you feel:", choices=[ "I much prefer to be paid $15 today", "I slightly prefer to be paid $15 today", "I don't mind whether I am paid $15 today, or $30 in two weeks", "I slightly prefer to be paid $30 in two weeks", "I much prefer to be paid $30 in two weeks", ] ) while_waiting= models.CharField( verbose_name="In the hunting task, what did you do while waiting?", choices=[ "I did something else", "I was just waiting", ] ) understand= models.TextField( verbose_name="Was there anything you found difficult to understand, or is there anything else that you want to let us know?", blank=True ) # Before: # understand= models.TextField( # verbose_name="What did you find difficult to understand in this study?", # blank=True # ) # # letknow= models.TextField( # verbose_name="Is there anything else that you want to let us know?", # blank=True # ) treatprimetext= models.TextField( verbose_name="Most of us from time to time run into financial difficulties. Please think back to a situation when you were very short on money and/or had financial obligations that you found difficult to meet. Please describe this situation in some detail. Do not mention specific places or names (to protect individuals' anonymity), but describe the situation in some detail so that it is possible to imagine it. Please write a text of at least 800 characters (~ 140 words).", blank=True, validators=[ MinLengthValidator( 500, message="Please write a text of at least 500 characters (~ 80 words)", ), ] ) controlprimetext= models.TextField( verbose_name="Most of us from time to time spend a day away from home. Please think back to the last time you spent a day away from your home. Please describe this situation in some detail. Do not mention specific places or names (to protect individuals' anonymity), but describe the situation in some detail so that it is possible to imagine it. Please write a text of at least 800 characters (~ 140 words).", blank=True, validators=[ MinLengthValidator( 500, message="Please write a text of at least 500 characters (~ 80 words)", ), ] ) decision=models.CharField(choices=["Stag","Hare"]) def set_payoff(self): self.payoff = c(1)