oTree Forum >

is_displayed() not working with live_method?

#1 by eizkenmac (edited )

Hi everyone,
I encounted a problem when I was tinkering with is_displayed() in the live_bargaining example code(https://s3.amazonaws.com/otreehub/browsable_source/1e38462b-46c7-4ca1-bca5-536462f90131/sequential/index.html). I tried to add is_displayed() to the negotiation page, but I don't know why it doesn't work. I first made two separated pages that only display to player with id_in_group ==1 or 2, and those two pages work as intended; I then tried to add is_displayed so that only players with id_in_group == 1 can see the negotiation page, but somehow both player can see it; I then tried to set the return of is_displayed to false, but the page still appeared. I even deleted the is_finished(initial = False) variable in the group class and the function with it, but the page still appeared, even with return False.
Is it just a problem with live pages, or did I do anything wrong?

======== __init.py__ Code snippets  (in addition to the live_bargaining code example linked above) =======
# First try with return player.id_in_group == 1 : this didn't work
class Player1(Page):
    @staticmethod
    def is_displayed(player: Player):
        return player.id_in_group == 1
    
class Player2(Page):
    @staticmethod
    def is_displayed(player: Player):
        return player.id_in_group == 2
 
class Bargain(Page):
    @staticmethod
    def is_displayed(player: Player):
        return player.id_in_group == 1
        
# Second try with return False : also didn't work
class Bargain(Page):
    @staticmethod
    def is_displayed(player: Player):
        return False

#2 by eizkenmac

nvm I found that it's because there is a is_displayed() function at the very bottom of the original code, no worries!

Write a reply

Set forum username