Browse source code
Chris @ oTree
Recipes for common tasks in oTree
'Are you sure?' popup based on the user's input
Audio alert (speak some text to get the participant's attention, after a wait page)
Back button for multiple instructions pages
Basic single-player game (BMI calculator)
Of course oTree has a readymade chat widget described here: https://otree.readthedocs.io/en/late...
Chat with experimenter, using Papercups
Comprehension test. If the user fails too many times, they exit.
Simple version of comprehension test
Configurable players per group. See here: https://otree.readthedocs.io/en/latest/treatments.html#...
Count button clicks
Using CSS to style timer and chat box.
custom_export: 1 row for each group
Detect and block mobile browsers
Dropout detection (if user does not submit page in time)
Dropout detection for multiplayer game (end the game)
Experimenter input during the experiment, e.g. entering the result of a random draw. If you want...
Randomize multiple factors in a balanced way
group_by_arrival_time: fall back to a smaller group if not enough people show up
group_by_arrival_time timeout (continue with solo task)
Preserve same groups as a previous app that used group_by_arrival time.
group by arrival time, but in each round assign to a new partner.
Conventionally, group-level treatments are assigned in creating_session: for g in subsession.get...
Similar to the basic gbat_treatments app, except: - Treatments are balanced rather than indepen...
Using getattr() and setattr() to access numbered fields, e.g. player.num1, player.num2, ..., pla...
Reads groups from a CSV file. Inside this app, you will find a groups6.csv, which defines the gro...
Images in radio button choices
Live volunteer's dilemma (first player to click moves everyone forward).
Longitudinal study (2-part study taking place across days/weeks) Another way to do longitudinal ...
Minimum time on a page
How to translate an app to multiple languages (e.g. English and German). There are 2 ways to def...
Timeout spanning multiple pages
Question that lets you select multiple options (multi-select, multiple choice / multiple answer)
Question that lets you select multiple options (multi-select, multiple choice / multiple answer) ...
Showing other players' decisions from previous rounds
""" class C(BaseConstants): NAME_IN_URL = 'pay_random_app2' PLAYERS_PER_GROUP = None ...
App where we choose the app to be paid
Select a random round for payment
Sliders and checkboxes that don't get wiped out on form reload. Also works for text/number inputs...
All you need is a participant field called 'progress' then keep adding 1 to it.
Read quiz questions from a CSV (complex version). See also the 'simple' version. It would be much...
Read quiz questions from a CSV (simple version). See also the 'complex' version of this app.
Menu with an 'other' option that lets you type in a valueInput manually
Quiz with explanation. Re-display the previous page's form as read-only, with answers/explanation.
Radio buttons in various layouts, looping over radio choices
Table where each row has a left/right choice, like the strategy method. This app enforces a singl...
Random number of rounds for multiplayer (random stopping rule)
For each participant, randomize the order of tasks A, B, and C. Task B has 2 pages, which are alw...
Ranking your top N choices from a list of options.
"Widget to rank/reorder items". See http://sortablejs.github.io/Sortable/ for more examples.
Sequential game (asymmetric)
Sequential / cascade game (symmetric)
An image that changes when you move a slider. If your image is a some kind of chart, it's better ...
Slider with live updating label
Supergames consisting of multiple rounds each
Timer: replacing the default timer with your own
Reading treatment parameters from a CSV spreadsheet
Wait only for specific people
Timeout on a WaitPage (exit the experiment)
Note: To open an *.otreezip file, enter:
otree unzip BLAH.otreezip