Where is my error in is_displayed()?

86 views
Skip to first unread message

Elias Bouacida

unread,
Apr 13, 2021, 12:34:52 PM4/13/21
to oTree help & discussion
Dear all,

I am on the last version fo oTree (5.1.4) and is_displayed does not seem to work.
I have the following code:

class Constants:
    num_rounds=10

[...]

class Belief(Page):
  @staticmethod
  def is_diplayed(player: Player):
    print("Blah")
    return ((player.round_number % (Constants.num_rounds / 2)) == 1)

  form_model = 'player'
  form_fields = ['belief']

[...]
page_sequence = ["Belief"]

If I know my python and otree well, which I may not, this code should print "Blah" at each round, and the page Belief should show up only in round 1 and 6. In fact it always shows up and "Blah" never prints.
(The real condition for is_displayed is intended to be more complicated, but even this simple one does not work).

Please tell me what I do wrong.
Thanks!

Chris @ oTree

unread,
Apr 13, 2021, 1:04:27 PM4/13/21
to oTree help & discussion
there is a typo in the function name; is_diplayed vs is_displayed.

Elias Bouacida

unread,
Apr 13, 2021, 1:33:21 PM4/13/21
to oTree help & discussion
There was no quote for the page sequence in my code. That's a bad copy pasting.
Thanks for the typo, I feel stupid! That has been a too long day I guess.
Reply all
Reply to author
Forward
0 new messages