from otree.api import * import time doc = """ Survey for the end of the Multi-Group Public Goods Game for all Sessions (Regardless of Treatment) """ class C(BaseConstants): NAME_IN_URL = 'SurveyQs' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass # Functions def make_survey_question(label): return models.LongStringField(label=label) class Player(BasePlayer): password_to_start = models.StringField() gender = models.IntegerField( 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?") grade = models.IntegerField( choices=[ [1, 'Freshman'], [2, 'Sophomore'], [3, 'Junior'], [4, 'Senior'], [5, 'Graduate'] ], label="3. What year are you in?", widget=widgets.RadioSelect ) major = models.StringField(label="4. What is your major?") risk = models.IntegerField( choices=[ [1, 'Strongly Disagree'], [2, 'Disagree'], [3, 'Slightly Disagree'], [4, 'Neutral'], [5, 'Slightly Agree'], [6, 'Agree'], [7, 'Strongly Agree'] ], widget=widgets.RadioSelectHorizontal, label='5. You are a person who is fully prepared to take risks.' ) reasoning = make_survey_question("6. What factors influenced your decision to invest / not to invest in a Group's" " Joint Account?") signaling = make_survey_question("7. What were you hoping to achieve by your investment / non-investment to a" " Group's Joint Account?") decision_style_facts = models.IntegerField( choices=[ [1, 'Always'], [2, 'Usually'], [3, 'Sometimes'], [4, 'Rarely'], [5, 'Never'] ], widget=widgets.RadioSelectHorizontal, label='A. When making important decisions I focus on facts and logic.' ) decision_style_feelings = models.IntegerField( choices=[ [1, 'Always'], [2, 'Usually'], [3, 'Sometimes'], [4, 'Rarely'], [5, 'Never'] ], widget=widgets.RadioSelectHorizontal, label='B. When making important decisions I trust my feelings and intuition.' ) clarity = models.IntegerField( choices=[ [1, 'Strongly Disagree'], [2, 'Disagree'], [3, 'Agree'], [4, 'Strongly Agree'], [5, "Don't know"] ], widget=widgets.RadioSelectHorizontal, label='9. The instructions for the experiment were clear and easy to follow.' ) suggestions = make_survey_question("10. We value your feedback, so please use the following text box for comments" " or suggestions.") # Did not include in final survey (below) perception = models.StringField(label="8. How much did you expect other participants to invest to the Group's" " Joint Account?") future = make_survey_question("If you were to play this game again, would you change your strategy? If so, how?") advice = make_survey_question("If you were able to advise a player about to enter into their first period of this" " game, what would you recommend them to do?") # Track Survey Time start_time = models.FloatField(initial=0) time_spent_survey_one = models.FloatField(initial=0) time_spent_survey_two = models.FloatField(initial=0) time_spent_survey_three = models.FloatField(initial=0) # PAGES class ThankYou(Page): form_model = 'player' form_fields = ['password_to_start'] def error_message(player: Player, values): if values['password_to_start'] != 'Questionnaire': return 'Check your spelling or ask the experimenter for help' class SurveyOne(Page): form_model = 'player' form_fields = ['gender', 'age', 'grade', 'major', 'risk', 'reasoning', 'signaling'] @staticmethod def is_displayed(player: Player): player.start_time = time.time() return True @staticmethod def before_next_page(player: Player, timeout_happened): player.time_spent_survey_one = time.time() - player.start_time # Save invest decision time spent class SurveyTwo(Page): form_model = 'player' form_fields = ['decision_style_feelings', 'decision_style_facts'] @staticmethod def is_displayed(player: Player): player.start_time = time.time() return True @staticmethod def before_next_page(player: Player, timeout_happened): player.time_spent_survey_two = time.time() - player.start_time # Save invest decision time spent class SurveyThree(Page): form_model = 'player' form_fields = ['clarity', 'suggestions'] @staticmethod def is_displayed(player: Player): player.start_time = time.time() return True @staticmethod def before_next_page(player: Player, timeout_happened): player.time_spent_survey_three = time.time() - player.start_time # Save invest decision time spent class EndPage(Page): pass page_sequence = [ThankYou, SurveyOne, SurveyTwo, SurveyThree, EndPage]