from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random import itertools author = 'Zeyu Qiu' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'emotion_follower_anger_l' players_per_group = 11 num_rounds = 1 # """Amount allocated to each player""" pounds = 0.01 fixed = 1.5 multiplier = 0.75 endowment = 20 def set_scale_choices_list(length): choices_list = [] for i in range(length): choices_list.append((i + 1, str(i + 1))) return choices_list def make_scale_field(label_string, length): return models.IntegerField( choices=set_scale_choices_list(length), widget=widgets.RadioSelectHorizontal, label=label_string # blank=True ) class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.Prolific_ID = p.participant.label class Group(BaseGroup): treatment = models.StringField() code_treatment = models.IntegerField() un_total_contribution = models.IntegerField() total_contribution = models.IntegerField() individual_share = models.FloatField() total_contribution_estimate = models.IntegerField() total_payoff = models.FloatField() decision = models.IntegerField() class Player(BasePlayer): Prolific_ID = models.StringField( label="Prolific ID", ) your_type = models.StringField() treatment = models.StringField() other_un_contribution = models.IntegerField() other_payoff = models.FloatField() bonus_earnings = models.CurrencyField() fixed_earnings = models.CurrencyField() final_earnings = models.CurrencyField() my_payoff = models.FloatField() estimate_pay1 = models.IntegerField() estimate_pay2 = models.IntegerField() contribution_estimate1 = models.IntegerField() warmth_before = make_scale_field("Warmth", 9) anger_before = make_scale_field("Anger", 9) fear_before = make_scale_field("Fear", 9) envy_before = make_scale_field("Envy", 9) sadness_before = make_scale_field("Sadness", 9) happiness_before = make_scale_field("Happiness", 9) shame_before = make_scale_field("Shame", 9) irritation_before = make_scale_field("Irritation", 9) contempt_before = make_scale_field("Contempt", 9) guilt_before = make_scale_field("Guilt", 9) joy_before = make_scale_field("Joy", 9) jealousy_before = make_scale_field("Jealousy", 9) surprise_before = make_scale_field("Surprise", 9) warmth_after = make_scale_field("Warmth", 9) anger_after = make_scale_field("Anger", 9) fear_after = make_scale_field("Fear", 9) envy_after = make_scale_field("Envy", 9) sadness_after = make_scale_field("Sadness", 9) happiness_after = make_scale_field("Happiness", 9) shame_after = make_scale_field("Shame", 9) irritation_after = make_scale_field("Irritation", 9) contempt_after = make_scale_field("Contempt", 9) guilt_after = make_scale_field("Guilt", 9) joy_after = make_scale_field("Joy", 9) jealousy_after = make_scale_field("Jealousy", 9) surprise_after = make_scale_field("Surprise", 9) un_contribution = models.IntegerField( label="How many Tokens do you want to contribute to the group project? ", min=0, max=20 ) first_estimate_1 = models.IntegerField( label="How much do you think the eleven Second Movers will contribute in total to the group project?", min=0, max=220 ) first_estimate_2 = models.IntegerField( label="How many Tokens do you think the Second Movers expect you to contribute? Add together your estimates for all eleven Second Movers.", min=0, max=220 ) second_estimate_1 = models.IntegerField( label="How much do you think the First Mover will contribute to the group project?", min=0, max=20 ) second_estimate_2 = models.IntegerField( label="How many Tokens do you think the First Mover expects Second Movers to contribute in Total? ", min=0, max=220 ) control_question = models.StringField( choices=[ ['1', 'I agree to take part. Take me to the study.'], ['2', 'I do not agree to take part in this study. Take me back to Prolific.'], ], label="Do you agree to participate in this study?", widget=widgets.RadioSelect ) def control_question_error_message(self, value): correct_answer = '1' if value != correct_answer: error_message = "If you do not agree to take part in this study, please close your browser tab." return error_message gender = models.StringField( choices=[ ['1', 'Male'], ['2', 'Female'], ['3', 'Other'], ], label="1. What is your gender?", widget=widgets.RadioSelect ) age = models.IntegerField( label="2. What is your age?", min = 0, max = 120 ) language = models.StringField( choices=[ ['1', 'Yes'], ['2', 'No'], ], label="3. Is English your first language?", widget=widgets.RadioSelect ) max_income = models.StringField( choices=[ ['1', 'Very important'], ['2', 'Important'], ['3', 'Indifferent'], ['4', 'Not important'], ['5', 'Not important at all'], ], label="4. How important was for you to maximise your own income during the experiment?", widget=widgets.RadioSelect ) trust = models.StringField( choices=[ ['1', 'Most people can be trusted'], ['2', 'You need to be very careful in dealing with people'], ], label="5. Generally speaking, would you say that most people can be trusted or that you need to be very " "careful in dealing with people?", widget=widgets.RadioSelect ) risk = models.StringField( choices=[ ['1', ''], ['2', ''], ['3', ''], ['4', ''], ['5', ''], ['6', ''], ['7', ''], ['8', ''], ['9', ''], ['10', ''], ], label="", widget=widgets.RadioSelectHorizontal ) instructions = models.StringField( choices=[ ['1', 'Very difficult'], ['2', 'Difficult'], ['3', 'Neutral'], ['4', 'Easy'], ['5', 'Very easy'], ], label="7. How did you find the instructions?", widget=widgets.RadioSelect ) same = models.StringField( choices=[ ['1', 'Yes, they watched the same video clip.'], ['2', 'No, they watched a different video clip.'], ['3', 'I do not know.'], ], label="8. Do you think that the FIRST MOVER watched the same video like you did?", widget=widgets.RadioSelect ) econ_exp = models.IntegerField( label="9. How many economics experiments have you participated in before this one? ", ) feedback = models.StringField( blank=True, label="10. Do you have any other comments or feedback regarding this experiment?", )