from otree.api import * from . import ret_functions import random doc = """ Introduction and Consent """ class C(BaseConstants): NAME_IN_URL = 'consent_intro' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 WORKER_ROLE = 'Worker' CUSTOMER_ROLE = 'Customer' Conversion_GBP = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # --- FIX IS HERE --- # Corrected structure for models.BooleanField with custom choices: # 1. 'choices' argument is passed to models.BooleanField # 2. 'widget' argument is passed the RadioSelect class name without parentheses/arguments label = models.StringField(default=str(" ")) consent = models.BooleanField( label='With full knolwedge of all foregoing, I agree, of my own free will, to participate in this study', choices=[ [True, 'Yes'], [False, 'No'] ], widget=widgets.RadioSelect # 👈 MINIMAL FIX: Removed the parentheses and arguments here ) # PAGES class Screen1_IntroPage(Page): def vars_for_template(self): # Store participant label for debugging label = getattr(self.participant, 'label', None) if not label: label = 'WORKER' # default for pilot testing self.participant.label = label self.participant.vars['url_role_label'] = label # Assign role only once if not self.participant.vars.get('role'): first_letter = label[0].upper() if first_letter == 'W': self.participant.vars['role'] = C.WORKER_ROLE elif first_letter == 'C': self.participant.vars['role'] = C.CUSTOMER_ROLE else: # Fallback to CUSTOMER if unrecognized self.participant.vars['role'] = C.CUSTOMER_ROLE class Screen2_BackGroundPage(Page): def vars_for_template(self): return dict( Conversion=C.Conversion_GBP ) class Screen3_RoleAssignmentPage(Page): def vars_for_template(self): role = self.participant.vars['role'] return dict( role=role.upper(), ) # ************************************************************* DISPLAYED ONLY TO WORKERS************************************************************** class Screen4_WorkerTask(Page): @staticmethod def is_displayed(player): # Only Workers see this page return player.participant.vars.get('role') == "Worker" def vars_for_template(player): # Generate one sample decoding task task = ret_functions.Decoding() # Send variables to the template return dict( question=task.question, task_dict=task.task_dict, correct_answer=task.correct_answer, total_correct=0, task_time=120 ) page_sequence = [Screen1_IntroPage, Screen2_BackGroundPage, Screen3_RoleAssignmentPage, Screen4_WorkerTask, ]