Example questions¶
This notebook contains code for creating different types of questions in edsl
.
Multiple choice
Checkbox
Linear Scale
Yes / No
Budget
Free Text
List
Numerical
Administering questions
from edsl.questions import QuestionMultipleChoice, QuestionCheckBox, QuestionFreeText, QuestionList, QuestionBudget, QuestionNumerical, QuestionYesNo, QuestionLinearScale
Multiple Choice¶
A multiple choice question prompts the respondent to select a single option from a given set of options.
q_mc = QuestionMultipleChoice(
question_name = "q_mc",
question_text = "How often do you shop for clothes?",
question_options = [
"Rarely or never",
"Annually",
"Seasonally",
"Monthly",
"Daily"
]
)
Checkbox¶
A checkbox question prompts the respondent to select one or more of the given options, which are returned as a list.
q_cb = QuestionCheckBox(
question_name = "q_cb",
question_text = "Which of the following factors are important to you in making decisions about clothes shopping? Select all that apply.",
question_options = [
"Price",
"Quality",
"Brand Reputation",
"Style and Design",
"Fit and Comfort",
"Customer Reviews and Recommendations",
"Ethical and Sustainable Practices",
"Return Policy",
"Convenience",
"Other"
]
)
Linear Scale¶
A linear scale question prompts the respondent to choose from a set of numerical options.
q_ls = QuestionLinearScale(
question_name = "q_ls",
question_text = "On a scale of 0-10, how much do you typically enjoy clothes shopping? (0 = Not at all, 10 = Very much)",
question_options = [0,1,2,3,4,5,6,7,8,9,10]
)
Yes / No¶
A yes/no question requires the respondent to respond "yes" or "no". Response options are set by default and not modifiable. To include other options use a multiple choice question.
q_yn = QuestionYesNo(
question_name = "q_yn",
question_text = "Have you ever felt excluded or frustrated by the standard sizes of the fashion industry?",
)
Budget¶
A budget question prompts the respondent to allocation a specified sum among a set of options.
q_bg = QuestionBudget(
question_name = "q_bg",
question_text = "Estimate the percentage of your total time spent shopping for clothes in each of the following modes.",
question_options=[
"Online",
"Malls",
"Freestanding stores",
"Mail order catalogs",
"Other"
],
budget_sum = 100,
)
Free Text¶
A free text question prompts the respondent to provide a short unstructured response.
q_ft = QuestionFreeText(
question_name = "q_ft",
question_text = "What improvements would you like to see in clothing options for tall women?",
allow_nonresponse = False,
)
List¶
A list question prompts the respondent to provide a response in the form of a list. This can be a convenient way to reformat free text questions.
q_li = QuestionList(
question_name = "q_li",
question_text = "What improvements would you like to see in clothing options for tall women?"
)
Numerical¶
A numerical question prompts the respondent to provide a response that is a number.
q_nu = QuestionNumerical(
question_name = "q_nu",
question_text = "Estimate the amount of money that you spent on clothing in the past year (in $USD)."
)
result_mc = q_mc.run()
result_cb = q_cb.run()
result_ls = q_ls.run()
result_yn = q_yn.run()
result_bg = q_bg.run()
result_ft = q_ft.run()
result_li = q_li.run()
result_nu = q_nu.run()
WARNING: At least one question in the survey was not answered. Task `q_li` failed with `QuestionAnswerValidationError`:`Answer key 'answer' must be of type list; (got Longer inseams, more variety in sleeve lengths, extended sizing options) which is of type <class 'str'>.`.
We can select the fields to inspect (e.g., just the response):
result_mc.select("q_mc").print()
result_cb.select("q_cb").print()
result_ls.select("q_ls").print()
result_yn.select("q_yn").print()
result_bg.select("q_bg").print()
result_ft.select("q_ft").print()
result_li.select("q_li").print()
result_nu.select("q_nu").print()
┏━━━━━━━━━━━━┓ ┃ answer ┃ ┃ .q_mc ┃ ┡━━━━━━━━━━━━┩ │ Seasonally │ └────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ answer ┃ ┃ .q_cb ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ ['Quality', 'Style and Design', 'Fit and Comfort', 'Ethical and Sustainable Practices'] │ └─────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━┓ ┃ answer ┃ ┃ .q_ls ┃ ┡━━━━━━━━┩ │ 5 │ └────────┘
┏━━━━━━━━┓ ┃ answer ┃ ┃ .q_yn ┃ ┡━━━━━━━━┩ │ Yes │ └────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ answer ┃ ┃ .q_bg ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ [{'Online': 40}, {'Malls': 30}, {'Freestanding stores': 20}, {'Mail order catalogs': 5}, {'Other': 5}] │ └────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ answer ┃ ┃ .q_ft ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ As a tall woman myself, I would love to see more options for longer inseams in pants and jeans, as well as tops │ │ and dresses with longer torso lengths. It would also be great to have more variety in sleeve lengths and │ │ overall proportions to better fit taller frames. │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━┓ ┃ answer ┃ ┃ .q_li ┃ ┡━━━━━━━━┩ │ None │ └────────┘
┏━━━━━━━━┓ ┃ answer ┃ ┃ .q_nu ┃ ┡━━━━━━━━┩ │ 1500 │ └────────┘
We can add some pretty labels to our tables:
result_mc.select("q_mc").print(pretty_labels={"answer.q_mc":q_mc.question_text})
result_cb.select("q_cb").print(pretty_labels={"answer.q_cb":q_cb.question_text})
result_ls.select("q_ls").print(pretty_labels={"answer.q_ls":q_ls.question_text})
result_yn.select("q_yn").print(pretty_labels={"answer.q_yn":q_yn.question_text})
result_bg.select("q_bg").print(pretty_labels={"answer.q_bg":q_bg.question_text})
result_ft.select("q_ft").print(pretty_labels={"answer.q_ft":q_ft.question_text})
result_li.select("q_li").print(pretty_labels={"answer.q_li":q_li.question_text})
result_nu.select("q_nu").print(pretty_labels={"answer.q_nu":q_nu.question_text})
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ How often do you shop for clothes? ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ Seasonally │ └────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Which of the following factors are important to you in making decisions about clothes shopping? Select all that ┃ ┃ apply ┃ ┃ . ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ ['Quality', 'Style and Design', 'Fit and Comfort', 'Ethical and Sustainable Practices'] │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ On a scale of 0-10, how much do you typically enjoy clothes shopping? (0 = Not at all, 10 = Very much) ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ 5 │ └────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Have you ever felt excluded or frustrated by the standard sizes of the fashion industry? ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ Yes │ └──────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Estimate the percentage of your total time spent shopping for clothes in each of the following modes ┃ ┃ . ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ [{'Online': 40}, {'Malls': 30}, {'Freestanding stores': 20}, {'Mail order catalogs': 5}, {'Other': 5}] │ └────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ What improvements would you like to see in clothing options for tall women? ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ As a tall woman myself, I would love to see more options for longer inseams in pants and jeans, as well as tops │ │ and dresses with longer torso lengths. It would also be great to have more variety in sleeve lengths and │ │ overall proportions to better fit taller frames. │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ What improvements would you like to see in clothing options for tall women? ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ None │ └─────────────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Estimate the amount of money that you spent on clothing in the past year (in $USD) ┃ ┃ . ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ 1500 │ └────────────────────────────────────────────────────────────────────────────────────┘