oTree Forum >

How can I generate numbered fields by importing questions from list/.CSV?

#1 by Future

Hello, I'm a new beginner with Otree. 
What I want to do is to generate numbered fields Q1,Q2,Q3,etc., and under the "class Player(BasePlayer):"
Q1 = make_field(Q[0]),
Q2 = make_field(Q[1]),
Q3 = make_field(Q[2]),
where "Q" is a list containing all the questions needed and "make_field" is a function.
I need 60 of that Q?, and all of them should in one page. Is there any method to simplify the process? I have tried 
Q = [make_field(C.Q[i] for i in range(len(C.Q)))] or something like "Q%d"%i, but both failed. Besides, maybe "ExtraModel" can solve the problem but I don't know how to use it to fit this situation.

Thank you very much!

def make_field(label):
    return models.IntegerField(

Write a reply

Set forum username