from otree.api import * c = Currency class C(BaseConstants): NAME_IN_URL = 'results' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 CUSTOM_POINTS_NAME = 'Token' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def make_field(label): return models.IntegerField( choices=[1,2,3,4,5,6,7,8,9,10], label = label, widget = widgets.RadioSelect, ) class Player(BasePlayer): debriefing = models.BooleanField(initial= True, choices=[ [True, 'I give permission for the data collected from me to be included in the study.'], [False, 'I DO NOT give permission for the data collected from me to be included in the study.']]) q1 = models.IntegerField(label = "What is your gender?", choices=[ [0, 'Female'], [1, 'Male'], [2, 'Other'], [3, 'Prefer not to say'] ]) q2 = models.IntegerField(label = "What is your age?") q3 = models.IntegerField(label = "What is the highest degree or level of education you have completed?", choices=[ [0, 'Less than a high school diploma'], [1, 'High School'], [2, 'Bachelor Degree'], [3, 'Masters Degree'], [4, 'Doctoral degree'], [5, 'Other/Unknown'], [6, 'Prefer not to say'] ]) q4 = make_field('I am very willing to take risk (1 ="Completely Disagree" and 10 = "Completely Agree"). ') q5 = make_field('Most people can be trusted (1 ="Completely Disagree" and 10 = "Completely Agree").') q6 = make_field('Our leaders know what is best for us (1 ="Completely Disagree" and 10 = "Completely Agree").') q7 = make_field('Obedience and respect for authority are the most important values children should learn (1 ="Completely Disagree" and 10 = "Completely Agree").') q8 = make_field('I feel like I have a great deal of choice/control over the way my life turns out (1 ="Completely Disagree" and 10 = "Completely Agree").') q9 = make_field('I think government should prioritize being effective over being democratic (1 ="Completely Disagree" and 10 = "Completely Agree").') q10 = make_field('I feel that me and other group members are achieving a common goal as a team (1 ="Completely Disagree" and 10 = "Completely Agree").') q11 = models.BooleanField(label = "With which one of the following statements do you agree most?", choices=[ [True, 'If both a dictator and a democratic process could choose a good project for me to invest, I prefer to the democratic process.'], [False, 'As long as the project is the good one, I do not care whether the decision-making process of chooseing projects is democratic']]) # FUNCTIONS def set_participant_payoff(participant: Player.participant, exchange_rate: float): participant.payoff_real = round(participant.game_payoff * exchange_rate, 2) # PAGES class TimeOut(Page): @staticmethod def is_displayed(player: Player): return player.participant.dropout class Excluded(Page): @staticmethod def is_displayed(player: Player): return player.participant.excluded class Survey(Page): form_model = "player" form_fields = ["q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11"] class Debriefing(Page): form_model = "player" form_fields = ["debriefing"] class Results(Page): @staticmethod def vars_for_template(player: Player): exchange_rate = player.session.config['real_world_currency_per_point'] participant = player.participant set_participant_payoff(participant, exchange_rate) payoff = participant.payoff_real participant.payoff = participant.payoff_real return{ "payoff": payoff } @staticmethod def before_next_page(player: Player, timeout_happened): player.participant.finished = True class Redirect(Page): pass page_sequence = [TimeOut, Excluded, Survey, Debriefing, Results, Redirect]