from otree.api import * import itertools import random doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Instructions' PLAYERS_PER_GROUP = None NUM_ROUNDS = 2 num_attention_check_tries = NUM_ROUNDS ENDOWMENT = cu(10) MULTIPLICATION_FACTOR = 3 attention_check_points_answer=0 attention_check_multiplied_answer=3 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): ##Attention check questions attention_check_points = models.IntegerField( label="At the start of a round, Player A receives 10 points. How many points does Player B receive?") attention_check_multiplied = models.FloatField( label="The amount Player A sends will be multiplied by ___ before Player B receives it?") class Instructions(Page): @staticmethod def is_displayed(player: Player): if player.round_number == 1: return True else: return player.participant.vars["failed_attention_check"] class ExampleGames(Page): @staticmethod def is_displayed(player: Player): if player.round_number == 1: return True class AttentionCheck(Page): form_model = 'player' form_fields = ["attention_check_points", "attention_check_multiplied"] @staticmethod def is_displayed(player: Player): if player.round_number == 1: return True else: return player.participant.vars["failed_attention_check"] @staticmethod def before_next_page(player: Player, timeout_happened): if ( player.attention_check_points == C.attention_check_points_answer and player.attention_check_multiplied == C.attention_check_multiplied_answer ): player.participant.vars["failed_attention_check"] = False else: player.participant.vars["failed_attention_check"] = True class FailedAttentionCheck(Page): @staticmethod def is_displayed(player: Player): return player.participant.vars["failed_attention_check"] page_sequence = [Instructions, ExampleGames, AttentionCheck, FailedAttentionCheck]