#1 by Jnut
Hello, I am using otree Studio and my goal is to desing an experiment where players play for 2 minutes and they have to add random numbers. Afterwards they get paid based on the number of correctly solved cases. My plan was to add code into a button that is executed on click. After the click, the page should be refreshed and a new task calculated. I can imagine a way where I add hundreds of pages with the tasks one after another, but that does not seem efficient. So, is there a way to add a button that refreshes the page and executes code that generates a new task Best, Julian
#2 by BonnEconLab (edited )
You could use rounds for that. Set C.NUM_ROUNDS to a number that is larger than the number of correct answers that your participants can realistically come up with. Your 2-minute timeout then has to span multiple pages. This can be implemented as described on https://otree.readthedocs.io/en/latest/timeouts.html#timeouts-that-span-multiple-pages. The “math_task” app included in the replication package https://doi.org/10.5281/zenodo.5091975 does exactly that.
#3 by gr0ssmann
I would use a live page for that. You can store JSON-encoded data in a player's StringField, or use an ExtraModel for that. Upon clicking a button, a new challenge can be created. Here is an old example from my oTree course where I used a live page to build a truly in(de)finitely repeated prisoner's dilemma: https://gitlab.com/gr0ssmann/otree_course/-/tree/2021/infpd-v02-live?ref_type=heads Here is another example from a real-effort task: https://gitlab.com/gr0ssmann/otree_course/-/tree/2023/conjoint-v02-ret?ref_type=heads