# APP: oathexp (First Mover) # FILE: tests.py # # Run bots locally with: # otree test oathexp # Run on oTree Hub via the "Sessions" → "Create session" → "Run with bots" option. from otree.api import Bot, Submission from . import pages import random class PlayerBot(Bot): def play_round(self): # ── Welcome ──────────────────────────────────────────────────────────── yield Submission(pages.Welcome, { 'control_question': '1', 'recaptcha_token': 'test-token', }, check_html=False) # EndStudy is only shown if control_question == '2' — skip in bots # ── Prolific ID ──────────────────────────────────────────────────────── yield pages.ProlificID # ── General Instructions ─────────────────────────────────────────────── yield pages.General_Instructions # ── Description ─────────────────────────────────────────────────────── yield pages.Description # ── Comprehension Quiz — must answer correctly ───────────────────────── # Scenario: A=5, B=10, C=15 → total=30, project share=15 # A payoff = 15+15=30, B = 10+15=25, C = 5+15=20 yield Submission(pages.ComprehensionQuiz, { 'quiz_payoff_a': 30, 'quiz_payoff_b': 25, 'quiz_payoff_c': 20, }, check_html=False) # ── Oath pages (only shown in T2–T5) ────────────────────────────────── oath_text = self.player.participant.vars.get('oath_text') or '' if oath_text: take = random.choice([True, False]) yield Submission(pages.Oath, {'take_oath': take}, check_html=False) if take: yield Submission(pages.Oath_Take, { 'typed_oath': oath_text, 'typed_initials': 'A', }, check_html=False) # ── Contribution ─────────────────────────────────────────────────────── yield Submission(pages.Contributions, { 'contribution': random.randint(0, 20), }, check_html=False) # ── Beliefs ─────────────────────────────────────────────────────────── yield Submission(pages.Beliefs, { 'leader_belief_1': random.randint(0, 20), 'leader_belief_2': random.randint(0, 20), }, check_html=False) # ── Questionnaire (IOS + demographics) ──────────────────────────────── yield Submission(pages.Questionnaire, { 'ios_distance': round(random.uniform(0, 1), 3), 'ios_overlap': round(random.uniform(0, 1), 3), 'ios_number': random.randint(1, 7), 'age_questionnaire': random.randint(18, 65), 'gender_questionnaire': random.choice(['Male', 'Female', 'Non-binary', 'Prefer not to say']), 'political_affiliation': random.choice(['Democrat', 'Republican', 'Independent', 'Other', 'Prefer not to say']), 'religious_affiliation': random.choice(['Catholic', 'Protestant', 'Jewish', 'Muslim', 'Hindu', 'Buddhist', 'Atheist', 'Other']), 'religious_affiliation_other': '', }, check_html=False) # ── Faith Questionnaire ──────────────────────────────────────────────── yield Submission(pages.FaithQuestionnaire, { 'faith_pray_daily': random.randint(1, 4), 'faith_meaning_purpose': random.randint(1, 4), 'faith_active': random.randint(1, 4), 'faith_enjoy_community': random.randint(1, 4), 'faith_impacts_decisions': random.randint(1, 4), 'attention_check': 'Orange juice', 'additional_comments': '', }, check_html=False) # ── Thanks ───────────────────────────────────────────────────────────── yield pages.Thanks