Skip page

139 views
Skip to first unread message

Rivin Perinchery

unread,
Oct 26, 2021, 6:13:15 PM10/26/21
to oTree help & discussion
Hello all,

In between stages of an individual choice game (let's call it stage 1 and stage 2), I have a calculation page which is performing calculations (function) based on input in stage 1 which will affect stage 2. Players don't need to see this. Currently, I have coded it like this with success 

class SwitchWait(Page):     
        form_model = 'player'     
        @staticmethod     
        def before_next_page(player, timeout_happened):         
              Monty2(player)

When I do this, players manually have to click continue on the SwitchWait page to move forward. I wanted to hide this page since they do not need to see it. When I try to use a display condition, the page does not display but the function also is not calculated 

class SwitchWait(Page):     
        form_model = 'player'     
        @staticmethod     
        def is_displayed(player):        
                return 1 < 0     
        @staticmethod     
        def before_next_page(player, timeout_happened):         
                Monty2(player)

Is there a way to bypass the page (for subjects) but still have the function executed? 

Thank you for your consideration

Chris Crabbe

unread,
Oct 26, 2021, 7:54:45 PM10/26/21
to Rivin Perinchery, oTree help & discussion
Hi Rivin -

If a page isnt shown because it's is_displayed returns False, then it's vars_for_template and before_next_page functions aren't executed.

Could you do this calculation in the before_next_page function of the previous page?  

If it needs the decisions of the whole group, then you can make SwitchWait a WaitPage and run the calculation inside it's after_all_players_arrive function.

Thanks,
--Chris

--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/ae9dedc2-94e6-4a05-8e5a-646a553e31a5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages