import numpy as np from numpy import log as ln import math from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'question_page' PLAYERS_PER_GROUP = 2 INSTRUCTIONS_TEMPLATE = 'question/question_page.html' NUM_ROUNDS = 2 num_attention_check_tries = 2 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): q1 = models.StringField(choices=[['1', '1,5'], ['2', '6,6'], ['3', '5,1'], ['4', '2,2']], label='1. Based on given score table, if you choose Tree, and your co-player chooses rock, how much your score and your co-player score respectively are going to be?', widget=widgets.RadioSelect) q2 = models.StringField(choices=[['1', 'Tree'], ['2', 'Rock']], label='2. Based on given score table, if the other person chooses tree, what is the best option for you to choose?', widget=widgets.RadioSelect) q3 = models.StringField(choices=[['1', 'Always choose cooperative'], ['2', 'Choose the island with the highest number'], ['3', 'Think about your co-player selection and try to select the same island.']], label='3. What is the best strategy for island selection?', widget=widgets.RadioSelect) q4 = models.StringField(choices=[['1', 'Independent '], ['2', 'Cooperative'], ['3', 'Competitive']], label='4. On which island you and your co-player choices does not affect each other?', widget=widgets.RadioSelect) q5 = models.StringField(choices=[['1', 'Current trial'], ['2', 'Current trial of the same island'], ['3', 'Previous trial'],['4', 'Previous trial of the same island']], label='5. What does the dashed box indicate?', widget=widgets.RadioSelect) q6 = models.StringField(choices=[['1', 'You'], ['2', 'Your co-player']], label='6. Who has the orange color during the game? ', widget=widgets.RadioSelect) q7 = models.StringField(choices=[['1', '100% sure tree'], ['2', '100% sure rock'], ['3', 'between "not sure" and "100% sure" for tree'], ['4', 'between "not sure" and "100% sure" for rock ']], label='7. If you predict your co-player is going to choose tree but you are not sure, where is the best place to put the prediction slider?', widget=widgets.RadioSelect) # PAGES class question_page(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7'] @staticmethod def vars_for_template(player: Player): return dict(image_path1="display_image/q3.png", image_path2="display_image/q2.png") @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.q1 == '1' and player.q2 == '1' and player.q3 == '3' and player.q4 == '1' and player.q5 == '4' and player.q6 == '2' and player.q7 == '3' ): 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"] class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [question_page, FailedAttentionCheck]