oTree Forum >

Help on Likert Scale

#1 by april30

Hi,

So I am trying to make likert scale in my survey.And I followed codes here https://otree.readthedocs.io/en/latest/forms.html#example-radio-buttons-in-tables-and-other-custom-layouts 

def make_field(label):
    return models.IntegerField(
        choices=[
                [1,'Strongly agree'],
                [2, 'agree'],
                [3, 'agree a little'],
                [4, 'neutral'],
                [5, 'disagree a little'],
                [6, 'Disagree'],
                [7, 'Strongly Disagree'],
        ],
        label=label,
        widget=widgets.RadioSelect,
    )


class Player(BasePlayer):
    peq1 = make_field('label question 1  ')
    
 and then include the following part in the html. But I keep getting the message " TypeError: 'IntegerField' object is not iterable" Anyone know what's going on?
 
 <table class="table">
    {{ for field in form }}
        <tr>
            <th>{{ field.label }}</th>
            {{ for choice in field }}
                <td>{{ choice }}</td>
            {{ endfor }}
        </tr>
    {{ endfor }}
</table>

Write a reply

Set forum username