oTree Forum >

is_displayed with player.field_maybe_none

#1 by Trontatuma (edited )

Might there be something special about field_maybe_none here? I really cannot understand why it gives "No more pages left" after the first page.

I am defining it like and see in Python that it prints the 1, but then it does not print the "show" statement meaning that it does not evaluate the condition as true. I also using "is" instead of "==" but that does not change anything. I also tried giving the choices in Q1 Boolean but it also does not help.

class Q1(Page):
    form_model = 'player'
    form_fields = ['Q1']

class Q2A(Page):
    form_model = 'player'
    form_fields = ['Q2A']
    
    @staticmethod
    def is_displayed(player: Player):
        print(player.field_maybe_none('Q1'))
        if player.field_maybe_none('Q1') == 1:
            print('Show Q2A')
            return True


class Q2B(Page):
    form_model = 'player'
    form_fields = ['Q2B']

    @staticmethod
    def is_displayed(player: Player):
        print(player.field_maybe_none('Q1'))
        if player.field_maybe_none('Q1') == 0:
            print('Show Q2B')
            return True

#2 by Trontatuma

Ah, because it was a string..

Write a reply

Set forum username