Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Multiple choice form to inline script

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

  • edited November 2020

    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:

    • Level 1
    • Level 2
    • Other

    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.


  • edited November 2020

    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 an inline_script item to determine whether or not to run the additional question. You could put something like the following in its Run tab:


    var.run_additional_question = "no"
    
    if "Other" in var.educ:
        var.run_additional_question = "yes"
    


    Make sure to:

    • Use the square-bracket method for the Run-if statement in the tab of your trial_sequence:
    [run_additional_question] = "yes"
    
    • Put the Python code in the Run phase and place the inline_script item after the first question but before the additional question

    I attached an example experiment.


    Hope this helps!


    Cheers,


    Lotje


    Did you like my answer? Feel free to Buy Me A Coffee :)

  • 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 Buy Me A Coffee :)

  • edited April 1

    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_choice item, 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:

    print(var.educ)
    


    Or is this exactly what you did?


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • 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 Buy Me A Coffee :)

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games