Пример #1
0
             {
                 'text': 'Do you consider the experiment easy to understand and follow?',
                 'field': models.PositiveIntegerField(widget=widgets.RadioSelect,
                     choices=[
                         [1, '1. Very easy'],
                         [2, '2. Easy'],
                         [3, '3. Moderate'],
                         [4, '4. Difficult'],
                         [5, '5. Very difficult']
                     ]),
             }),
            ('experiment_comments',
             {  # field name (which will also end up in your "Player" class and hence in your output data)
                 'text': 'Any comments about the experiment? (What you like/dislike about the experiment? Which part is hard to follow? How can we improve)',
                 'field': models.TextField(blank=True),
             }),
            ('email',
             {  # field name (which will also end up in your "Player" class and hence in your output data)
                 'text': 'You can leave your email address below if you want to be informed when future experiments become available',
                 'field': models.StringField(blank=True),
             }),
        ]
    },
)

# now dynamically create the Player class from the survey definitions
# we can also pass additional (non-survey) fields via `other_fields`
Player = create_player_model_for_survey('end_questions.models',
                                        SURVEY_DEFINITIONS,
                                        other_fields={})
Пример #2
0
                {  # field name (which will also end up in your "Player" class and hence in your output data)
                    'text': 'Wie alt sind Sie?',  # survey question
                    'field': models.PositiveIntegerField(
                        min=16, max=100
                    ),  # the same as in normal oTree model field definitions
                }),
            ('q1_b', {
                'text': 'Ihr Geschlecht:',
                'field': models.CharField(choices=GENDER_CHOICES),
            }),
        ]
    },
    {
        'page_title':
        'Survey Questions - Page 2',
        'survey_fields': [
            ('q2_a', {
                'text': 'Are you a student?',
                'field': models.CharField(choices=YESNO_CHOICES),
            }),
            ('q2_b', {
                'text': 'If so, in which field of study?',
                'field': models.CharField(blank=True),
            }),
        ]
    },
)

# now dynamically create the Player class from the survey definitions
Player = create_player_model_for_survey('survey.models', SURVEY_DEFINITIONS)
Пример #3
0
                                  form_help_final='<p>&nbsp;</p>',
                                  form_name='likert_table'
            ),
            {   # if you use a likert table *and* other questions on the same page, you have to wrap the other questions
                # in a extra "sub-form", i.e. an extra dict with "fields" list
                'form_name': 'other_questions',  # optional, can be used for CSS styling
                'fields': [
                    ('q_monthly_income', {
                        'text': "What's your monthly income?",
                        'field': models.CurrencyField(min=0)
                    }),
                    ('q_num_siblings', {
                        'text': "How many siblings do you have?",
                        'field': models.IntegerField(min=0, max=20),
                    }),
                    ('q_comment', {
                        'text': "Please give us feedback on the experiment:",
                        'field': models.LongStringField(max_length=500)
                    }),
                ]
            }
        ]
    },
}

# now dynamically create the Player class from the survey definitions
# we can also pass additional (non-survey) fields via `other_fields`
Player = create_player_model_for_survey('otreeutils_example2.models', SURVEY_DEFINITIONS, other_fields={
    'treatment': models.IntegerField()
})
Пример #4
0
                ('depression_movement',
                 'Moving or speaking so slowly that other people could have noticed. Or the opposite being so fidgety '
                 'or restless that you have been moving around a lot more than usual'),
                ('depression_dead', 'Thoughts that you would be better off dead, or of hurting yourself'),
            ],
                                  form_help_initial='<p>Over the last 2 weeks, how often have you been bothered by '
                                                    'the following problems?.</p>',
                                  table_repeat_header_each_n_rows=10,
                                  table_rows_equal_height=False
                                  )
        ]
    },
    {
        # HSRC general p4b (shown conditionally based on is_displayed() in pages.py)
        'page_title': 'Health Questionnaire (continued)',
        'survey_fields': [
            ('depression_difficulty', {
                'text': 'Considering the problems you indicated on the previous page, how difficult have these '
                        'problems made it for you to do your work, take care of things at home, or get along with '
                        'other people?',
                'field': models.CharField(blank=True, choices=ANXIETY_DEPRESSION_DIFFICULTY_CHOICES),
            }),
        ]
    },

    # ... more pages
)


Player = create_player_model_for_survey('hsrc_survey_task.models', SURVEY_DEFINITIONS)
Пример #5
0
                    models.PositiveIntegerField(min=0, max=10),
                })]
            },
        ]
    },
    {
        'page_title':
        'Survey Questions - Page 4 - Likert scale table',
        'survey_fields': [
            # create a table of Likert scale choices
            # we use the same 5-point scale a before and specify four rows for the table,
            # each with a tuple (field name, label)
            generate_likert_table(
                likert_5_labels,
                [
                    ('q_pizza_tasty', 'Tasty'),
                    ('q_pizza_spicy', 'Spicy'),
                    ('q_pizza_cold', 'Too cold'),
                    ('q_pizza_satiable', 'Satiable'),
                ],
                form_help_initial=
                '<p>How was your latest Pizza?</p>',  # HTML to be placed on top of form
                form_help_final=
                '<p>Thank you!</p>'  # HTML to be placed below form
            )
        ]
    })

# now dynamically create the Player class from the survey definitions
Player = create_player_model_for_survey('otreeutils_example2.models',
                                        SURVEY_DEFINITIONS)
Пример #6
0
            {
                # you need to provide a dict then. you can add more keys to the dict which are then available in the template
                'form_name':
                'first_form',  # optional, can be used for CSS styling
                'fields': [
                    (
                        'crt_e1',
                        {
                            # 'text': 'A notebook and a pencil cost DKK 110 in total. The notebook costs DKK 100 more than the pencil. How much does the pencil cost in DKK?',
                            'text':
                            'How many of the 3 questions do you think you solved correct?',
                            'field': models.IntegerField(min=0, max=3),
                        }),
                    ('crt_e2', {
                        'text':
                        'Out of 100 other randomly selected participants, how many do you thik solve more questions correctly than you?',
                        'field': models.IntegerField(min=0, max=100),
                    }),
                ]
            },
        ]
    },
)

# now dynamically create the Player class from the survey definitions
# we can also pass additional (non-survey) fields via `other_fields`
Player = create_player_model_for_survey(
    'crt.models',
    SURVEY_DEFINITIONS,
    other_fields={'num_correct_anwers': models.IntegerField()})