##################################################### ##################################################### # README # # Program Name: __init__.py # Purpose: Interface Code ##################################################### # # Author: Andrew Olsen # Date Created: 02.03.2026 # Last Updated: 02.03.2026 # ##################################################### #### Modules from otree.api import * import numpy as np import itertools import pandas as pd import random import math import os import pickle c = cu doc = '' #################### #### File Paths #### #################### # Constants class C(BaseConstants): NAME_IN_URL = 'stb_rdm_tmp' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 NUM_ROUNDS_PER_BLOCK = 5 NUM_APPS = 1 NUM_SURVEY = 9 NUM_PLAYERS = 150 NUM_QUOTA = 25 NUM_CAP = 2 # Subsessions (do not exist in single-player option) class Subsession(BaseSubsession): pass # Groups class Group(BaseGroup): pass # Player. class Player(BasePlayer): pass ###### Functions # Creating def creating_session(subsession: Subsession): # Initialize the uid counter on the session when the session is created. # Assignment to individual participants happens in TmpPage.before_next_page. if subsession.round_number == 1: subsession.session.uid_counter = 0 subsession.session.recycled_uids = [] ## Initialize the internal ID, mobile check, passed quiz for player in subsession.get_players(): participant = player.participant participant.uid = 1000 participant.timed_out = False participant.is_mobile = False participant.passed_quiz = True class TmpPage(Page): @staticmethod def before_next_page(player, timeout_happened): participant = player.participant # Only assign if not already assigned (guards against page refreshes). if participant.uid == 1000: session = player.session recycled = session.recycled_uids if recycled: participant.uid = recycled.pop(0) session.recycled_uids = recycled else: participant.uid = session.uid_counter session.uid_counter += 1 num_rounds = C.NUM_ROUNDS_PER_BLOCK # one entry per round in stb_rdm_main mkt_ord_cap = list(range(num_rounds)) mkt_ord_nocap = list(range(num_rounds)) random.shuffle(mkt_ord_cap) random.shuffle(mkt_ord_nocap) participant.mkt_ord_cap = mkt_ord_cap participant.mkt_ord_nocap = mkt_ord_nocap page_sequence = [TmpPage]