oTree Forum >

Inputs on tables with variable number of rows per player

#1 by AndreL (edited )

Hi, I need/want to automate the following routine, and I wonder if there is any easier way than cumbersome JS to hide/show or extremely lengthy row-by-row coding. I want to create several questions that cycle over a list of milestones, and then ask their likelihood at different ages in the future based on players' current age.

Consider 'milestone'=['be married', 'have bought a house', 'be earning more than your parents at this same age', 'have earned a terminal degree in your field', 'have lived in another country for at least one year']

1: From t='player.participant.age', generate a list player.elicitation_points=(t+5, t+10, t+15 ... ) until t+i>=65

2: Create several HTML tables where a top question "how likely is it that at age (player.elicitation_points) you will (milestone[k])" will be asked and answered on a Likert-like scale... I am aware of how to create several fields and a scale on columns as discussed in https://otree.readthedocs.io/en/latest/forms.html#example-radio-buttons-arranged-like-a-slider , but that does not seem to work with respect to the number of lines if the len(player.elicitation_points) varies per player.
   So each table must have a question on top (for every instance of 'milestone'), and then the variable number of rows will be 'player.elicitation_points', which depend on player.participant.age.

3 (bonus, if not too difficult): have an accordion-like table where subjects can click and collapse each one, while seeing just the question, instead of having to put each question (instance of milestone) in a separate page or having a simple gigantic one-page sequence of tables.

Many thanks for any suggestions,

Write a reply

Set forum username