##################################################### ##################################################### # README # # Program Name: __init__.py # Purpose: Survey Code. ##################################################### # # Author: Andrew Olsen # Date Created: 04.24.2026 # Last Updated: 04.24.2026 # ##################################################### #### Modules from otree.api import * import numpy as np import random from stb_rdm_constants import RAVEN_BONUS c = cu doc = '' # Constants class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 RAVEN_BONUS = RAVEN_BONUS # Subsessions class Subsession(BaseSubsession): pass # Groups class Group(BaseGroup): pass # Player class Player(BasePlayer): ## Investment decisions (Questions 1-4) risk1_invest = models.IntegerField(min=0, max=50) risk2_invest = models.IntegerField(min=0, max=50) amb1_invest = models.IntegerField(min=0, max=50) amb2_invest = models.IntegerField(min=0, max=50) ## Raven's Matrix def make_raven_field(): return models.IntegerField(label = "Please make your choice:", widget = widgets.RadioSelect, choices = [[1, 'A'], [2, 'B'], [3, 'C'], [4, 'D'], [5, 'E'], [6, 'F']]) raven1 = make_raven_field() raven2 = make_raven_field() raven3 = make_raven_field() raven4 = make_raven_field() raven5 = make_raven_field() ###### Pages class SurveyIntro1(Page): form_model = 'player' @staticmethod def vars_for_template(player): session = player.session return {'points_per_dollar' : round(1/session.real_world_currency_per_point)} class SurveyIntro2(Page): form_model = 'player' class Risk1(Page): form_model = 'player' form_fields = ['risk1_invest'] class Risk2(Page): form_model = 'player' form_fields = ['risk2_invest'] class Amb1(Page): form_model = 'player' form_fields = ['amb1_invest'] class Amb2(Page): form_model = 'player' form_fields = ['amb2_invest'] class RavenIntro(Page): form_model = 'player' class Raven1(Page): timeout_seconds = 60 form_model = 'player' form_fields = ['raven1'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.raven1 = 1 # Set to an incorrect answer class Raven2(Page): timeout_seconds = 60 form_model = 'player' form_fields = ['raven2'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.raven2 = 1 # Set to an incorrect answer class Raven3(Page): timeout_seconds = 60 form_model = 'player' form_fields = ['raven3'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.raven3 = 1 # Set to an incorrect answer class Raven4(Page): timeout_seconds = 60 form_model = 'player' form_fields = ['raven4'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.raven4 = 1 # Set to an incorrect answer class Raven5(Page): timeout_seconds = 60 form_model = 'player' form_fields = ['raven5'] @staticmethod def before_next_page(player: Player, timeout_happened): ## Flag that they finished player.participant.finished = True if timeout_happened: player.raven5 = 1 # Set to an incorrect answer page_sequence = [SurveyIntro1, SurveyIntro2, Risk1, Risk2, Amb1, Amb2, RavenIntro, Raven1, Raven2, Raven3, Raven4, Raven5, ]