from otree.api import Bot from . import * import random class PlayerBot(Bot): def play_round(self): if self.round_number == 1: # Since the fields are randomized in Questionnaire and Questionnaire1 pages, # we need to ensure we are submitting the correct fields. # The following approach is a general idea and may need to be adjusted # based on the exact logic of your field randomization. # Fill out the Questionnaire page questionnaire_fields = { 'q1_understanding': random.randint(1, 7), 'q2_understanding': random.randint(1, 7), 'q3_understanding': random.randint(1, 7), 'q1_progress': random.randint(1, 7), 'q2_progress': random.randint(1, 7), 'q3_progress': random.randint(1, 7), } yield Questionnaire, questionnaire_fields # Fill out the Questionnaire1 page questionnaire1_fields = { 'q1_control': random.randint(1, 7), 'q2_control': random.randint(1, 7), 'q3_control': random.randint(1, 7), 'q1_satisfaction': random.randint(1, 7), 'q2_satisfaction': random.randint(1, 7), 'q3_satisfaction': random.randint(1, 7), 'attention': 2, # Intentionally choosing a non-"Disagree" option } yield Questionnaire1, questionnaire1_fields # Fill out the ManipulationCheck page yield ManipulationCheck, { 'ManipulationCheck': random.randint(1, 4) } # Fill out the ManipulationCheck2 page yield ManipulationCheck2, { 'ManipulationCheck2': random.randint(1, 3) } # Fill out the Questionnaire2 page abandonment_consideration = random.choice([True, False]) skipped = random.choice([True, False]) questionnaire2_fields = { 'satisfaction_experience': random.randint(1, 7), 'frustration_level': random.randint(1, 100), 'patience_level': random.randint(1, 100), 'abandonment_consideration': abandonment_consideration, 'abandonment_reason': "Sample reason" if abandonment_consideration else "", 'skipped': skipped, 'skip_reason': "Sample reason" if skipped else "", } yield Questionnaire2, questionnaire2_fields # Fill out the Demographics page demographics_fields = { 'age': random.randint(16, 125), 'experience_with_similar_tasks': random.randint(1, 5), 'value_tasks': random.randint(1, 5), # Add this line to include the missing field 'gender': random.choice(['Male', 'Female', 'Other', 'Prefer not to disclose']), 'country': random.choice( ['United States', 'India', 'Germany', 'Canada', 'Italy', 'China', 'Spain', 'Netherlands']), 'education': random.choice( ['GED equivalent', 'High school', 'Some college but not degree', 'Bachelor degree', 'Master/Doctoral or professional degree', 'Prefer not to disclose']), 'employment': random.choice( ["Full-time employed", "Part-time employed", "Not employed", "Retired", "Student", "Other"]), 'income': random.choice( ['Less than 15,000$', '15,000$ - 30,000$', '30,000$-45,000$', '45,000$-60,000$', '60,000$-75,000$', '75,000$-90,000$', 'More than 90,000$']), } yield Demographics, demographics_fields yield Submission(Thanks, check_html=False)