from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'controlquestions' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): paymentround = models.BooleanField(label='The profits of all 6 estimations are paid out.', choices=[[True, 'Correct'], [False, 'False']], widget=widgets.RadioSelectHorizontal) # answer: falsch paymentroundcount = models.IntegerField() controlcountry = models.BooleanField(choices=[[True, 'Correct'], [False, 'False']], label='The countries whose GDP per capita I have to estimate are determined randomly.', widget=widgets.RadioSelectHorizontal) # answer: richtig controlcountrycount = models.IntegerField() controlestimation = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='Only if I estimate the exact GDP per capita, I receive a profit.', widget=widgets.RadioSelectHorizontal) # answer: falsch controlestimationcount = models.IntegerField() controlmaxbip = models.IntegerField(label='Please enter the maximum value of the normalised GDP per capita in this study.') # answer: 100 controlmaxbipcount = models.IntegerField() controlbip = models.BooleanField( label='The Gross domestic product (GDP) per capita measures the total value of all goods and services produced in a country per capita.', choices=[[True, 'True'], [False, 'False']], # answer: true widget=widgets.RadioSelectHorizontal) controlbipcount = models.IntegerField() controlcount = models.IntegerField(initial=0, label='Number of questions answered correctly') correctanswers = models.IntegerField(label='Number of questions answered correctly') falseanswers = models.IntegerField(label='Number of questions answered incorrectly') # PAGES class instructions(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class question1(Page): form_model = 'player' form_fields = ['controlbip'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class question1_result(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 def before_next_page(player, timeout_happened): if player.controlbip == True: player.controlbipcount = 1 else: player.controlbipcount = 0 class question2(Page): form_model = 'player' form_fields = ['paymentround'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class question2_result(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 def before_next_page(player, timeout_happened): if player.paymentround == False: player.paymentroundcount = 1 else: player.paymentroundcount = 0 class question3(Page): form_model = 'player' form_fields = ['controlcountry'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class question3_result(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 def before_next_page(player, timeout_happened): if player.controlcountry == True: player.controlcountrycount = 1 else: player.controlcountrycount = 0 class question4(Page): form_model = 'player' form_fields = ['controlestimation'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class question4_result(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 def before_next_page(player, timeout_happened): if player.controlestimation == False: player.controlestimationcount = 1 else: player.controlestimationcount = 0 class question5(Page): form_model = 'player' form_fields = ['controlmaxbip'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class question5_result(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 def before_next_page(player, timeout_happened): if player.controlmaxbip == 100: player.controlmaxbipcount = 1 else: player.controlmaxbipcount = 0 player.controlcount = player.controlbipcount + player.paymentroundcount + player.controlcountrycount + player.controlestimationcount + player.controlmaxbipcount player.falseanswers = 5 - player.controlcount class failedquestions(Page): @staticmethod def is_displayed(player: Player): return player.round_number == 1 and player.falseanswers >= 2 class succeededquestions(Page): @staticmethod def is_displayed(player: Player): return player.round_number == 1 and player.falseanswers < 2 page_sequence = [instructions, question1, question1_result, question2, question2_result, question3, question3_result, question4, question4_result, question5, question5_result, failedquestions, succeededquestions]