Multiple choice form to inline script
in OpenSesame
Hi!
I'd like to use to create a multiple choice form with in-line script. How can I "translate" this option to inline script?
set allow_multiple "yes"
Thanks!
Comments
I'd like to provide a bit more context to my question.
The question in the survey is:
What educational titles do you have?
And hypothetical answer options are:
Respondents can select multiple educational levels. The problem is, once they select "Other" I want them to also fill in what other educational level they may have.
To do so, I should use in-line script for the multiple choice form.
If I use inline script, I don't know how to script a multiple choice question (the issue is this line: set allow_multiple "yes")...
If I use multiple choice preset form, I don't know how to set the condition in "Run if" for the form corresponding to filling in "other" because it is a multiple choice form. So, if a person ONLY selects "other", then it is easy to fill in the "run if" command ([educ]='Other' works fine). But, if a person specifies both "Level 1" and "Other" then it becomes more complicated, as there are multiple combinations of possibly selected answers...
So, I think the "easiest" way to do this, is to use an inline script. But I am still left with the question of how to "make" a multiple choice question in an inline script...
Any ideas are much appreciated.
I attach a small experiment to illustrate my challenge.
Hi Paula,
Thanks for the additional info!
I think it's easiest to use a
Run-if statement. Because, as you said, participants could check multiple boxes, you could add a bit of Python code in aninline_scriptitem to determine whether or not to run the additional question. You could put something like the following in itsRuntab:var.run_additional_question = "no" if "Other" in var.educ: var.run_additional_question = "yes"Make sure to:
I attached an example experiment.
Hope this helps!
Cheers,
Lotje
Did you like my answer? Feel free to

Thank you very much, Lotje!
This is a very good solution to my problem.
Best,
Paula
Great to hear @Paula
Did you like my answer? Feel free to

Hi! I have an additional question :) What if I also want to add a form validator (forced response) to this question?
I know I need to add this code to an inline script:
while True: incomplete = False items.execute("form_multiple_choice") if None in [var.educ]: incomplete = True if not incomplete: break else: items.execute("warning_message")However, I am having trouble in the following line, as it seems OS simply ignores it and the warning message is never displayed:
if None in [var.educ]:It seems to be working by changing " None " to " u'no' " in this way:
if u'no' in [var.educ]:
Hi @Paula ,
If you don't make a choice after a
form_multiple_choiceitem, the response variable is indeed set to "no". Well done for finding this out! :)In the future, printing variables to the console could be helpful:
Or is this exactly what you did?
Cheers,
Lotje
Did you like my answer? Feel free to

Thank you for the tip on print(var)!
I figured it out because the OS documentation mentions that for some forms (ratingscales vs checkboxes), the default is 'None' and for others it is 'no'. I tried both to see which one works, taking a low-tech approach :-) The documentation is quite complete and that helps a lot!
Good job, @Paula !
Did you like my answer? Feel free to
