我想知道是否有可能有一个多项选择的问题在奥特里。类似于单选按钮,但这让你可以选择不止一件东西。我想的是:
问题:以下陈述清单包含三个正确的陈述和三个错误的陈述。请选择三个正确的语句:
发布于 2019-05-19 07:30:44
为此,您可以使用otree_models.models.MultipleChoiceFormField
,如下所示:
在models.py
中
from otree.api import BasePlayer
from otree_tools.models import fields as tool_models
class Player(BasePlayer):
correct_statements = tool_models.MultipleChoiceModelField(label="Please select the three correct statements",
min_choices=3, max_choices=3)
在pages.py
中
from ._bultin import Page
class ExamplePage(Page):
form_model = "player"
form_fields = ["correct_statements"]
def correct_statements_choices(self):
"""Return the list of statements to choose from."""
return ["Statement 1", "Statement 2", "Statement 3",
"Statement 4", "Statement 5", "Statement 6"]
在ExamplePage.html
中,只需包含表单字段:
{% extends "global/Page.html" %}
{% load otree %}
{% block content %}
The following list of statements contains three correct statements and three false statements.
{% formfield player.correct_statements %}
{% next_button %}
{% endblock %}
https://stackoverflow.com/questions/51420112
复制相似问题