Howdy, Stranger!

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

Supported by

Opensesame/Next button

edited September 2016 in OpenSesame

Hi all!

I'm new to opensesame and 1) I want to create a questionnaire with a "next" button for the open-ended questions. I understand that there is an option to include the "next" button for the multiple-choice questions but how do I include it for the open-ended questions as well?

2) How do I ensure that the participants can only click the "next" button when there is an input?

PS. I barely have any knowledge on python language.
I really hope I could get some help here!!!! Thanks in advance!! It's really urgent!

Maz

Comments

  • edited September 2016

    Hi Maz,

    Have you considered creating a custom-form? You can find rather detailed instructions how to make them here. Let us know if you need more help with them.

    Best,

    Eduard

    Buy Me A Coffee

  • Hi Eduard!!

    Thanks! The site helped to resolve the first problem (which is to include a next button in open-ended questions). Appreciate it so much!! Is there any opensesame script to either allow the participant to click the 'next' button only when there is an input or some kind of warning message to prompt the participants to enter their responses if they haven't after clicking the 'next' button?

    Maz

  • Hi Jarik! Thanks for the reply! Yes, I'm using OpenSesame 3. I copy pasted your script but I could still click next/advance to the next page. So for example my open-ended question with the next button looks like this:

    set timeout infinite
    set spacing 10
    set rows "1;4;1"
    set only_render no
    set margins "100;50;100;50"
    set form_var response
    set form_title Title
    set form_question "bla bla bla?"
    set cols 1
    set _theme gray
    widget 0 0 1 1 label text="[form_title]"
    widget 0 1 1 1 label center=no text="[form_question]"
    widget 0 1 1 1 text_input focus=no return_accepts=no stub="" var="[form_var]"
    widget 0 2 1 1 button text=Next var=response_variable

    But I could still click the next button without typing in my response.

  • Yes, you should modify things a little :) In the attached example note the inline script lines:

        if self.get('response') == '':
    

    So the output variable of the form_base item has to be response

        items['new_form_base'].prepare()
        items['new_form_base'].run()
    

    So the title of the form_base item has to be new_form_base

  • Hi Jarik! Should this script be in sequence item? or can it be in the form item?

    Also, I'll have 20-30+ questions, some MCQ/Rating/open-ended questions.

  • Hi Jarik! Should this script be in sequence item? or can it be in the form item?

    Also, I'll have 20-30+ questions, some MCQ/Rating/open-ended questions.

  • Hi Maz,

    A working example is attached to my previous post. There's a little bit of code in the inline_script item (which is in the sequence item after the form). Ones you understand the working example it shouldn't be too hard for you to apply the same principle on the other 20-30+ questions.

    Best,
    Jarik

  • Hi Jarik!!

    Thank you for all the help and being so patient :'). I kinda almost get the concept! It did throw me an error though for the inline script item.

    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 73, in prepare
    self.var.get(u'_run', _eval=False))
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 147, in _compile
    return compile(script, u'', u'exec')
    File "", line 2
    define inline_script new_inline_script
    ^
    SyntaxError: invalid syntax

  • The experiment did not finish normally for the following reason:

    Failed to compile inline script
    Details

    code: define inline_script new_inline_script
    item-stack: experiment[prepare].new_sequence[prepare].new_inline_script[prepare]
    exception type: SyntaxError
    exception message: invalid syntax (, line 2)
    item: new_inline_script
    time: Sun Sep 25 11:26:13 2016
    phase: run
    line: 1

  • Can you upload the experiment or post the code from the inline script that is causing the error? I can't find the problem in the error message(s) you provide.

  • Hi Jarik!

    Ok so I tried using your code. I have a form text input item and in it, there's this:
    set timeout infinite
    set spacing 10
    set rows "1;4;1"
    set only_render no
    set margins "100;50;100;50"
    set form_var response
    set form_title Title
    set form_question "bla bla bla?"
    set cols 1
    set _theme gray
    widget 0 0 1 1 label text="[form_title]"
    widget 0 1 1 1 label center=no text="[form_question]"
    widget 0 1 1 1 text_input focus=no return_accepts=no stub="" var="[form_var]"
    widget 0 2 1 1 button text=Next var=response_variable

    Then I included a sequence item after the form text input item and in the sequence item, I used your code provided above:
    set timeout infinite
    set spacing 10
    set rows "1;4;1"
    set only_render no
    set margins "100;50;100;50"
    set form_var response
    set form_title Title
    set form_question "bla bla bla?"
    set flush_keyboard yes
    set description "Runs a number of items in sequence"
    set cols 1
    set _theme gray
    run new_form_text_input always
    run new_inline_script always

    I also included the inline script item in the sequence item and in the run phase (your code as well!):
    define inline_script new_inline_script
    set description "Executes Python code"
    _run
    ###############################################################################
    # Check if text is entered when clicking next; otherwise rerun rating_scale
    ###############################################################################
    while True:
    # If the response has the value 'None' or 'yes':
    if self.get('response') == '':
    # Rerun the item (after preparing it):
    items['new_form_text_input'].prepare()
    items['new_form_text_input'].run()

        # Else, the experiment advances normally.
        else:
            break
    __end__
    set _prepare ""
    

    After I tried to run the program, it throws me an error as described above. My apologies for all the trouble, I'm really new to this program and coding entirely!!!

  • You are putting "form code" like set form_question "bla bla bla?" in a sequence item. This won't work.

    Note that for some items you will have to use code like for an inline_script item or a form_base item. But for some items like the sequence or the sketchpad item, you can suffice with the graphical user interface. Maybe you will get some more grip on the OpenSesame program by doing/viewing some tutorials:

    Then I included a sequence item after the form text input item and in the sequence item, I used your code provided above:

    Note that you normally put things (items like an inline_script item) in and not after a sequence item. You can peek in the osexp file I uploaded here (right click on file and choose Save as...) or in any of the example templates that come with OpenSesame.

    Best,
    Jarik

  • Thanks Jarik!! It worked perfectly!
    I tried with other type of questions but where did I go wrong this time? I can still click next when I have no user input.
    This was my code in the form base item:

    set timeout infinite
    set spacing 10
    set rows "1;1;1;1;1"
    set only_render no
    set margins "50;50;50;50"
    set form_var response2
    set cols "1;1"
    set _theme gray
    widget 0 0 2 1 label text="Indicate how much you agree with the following statements"
    widget 0 1 1 1 label center=no text="I think that ex-probationers should work with the community in the future"
    widget 1 1 1 1 rating_scale nodes="Agree;Don't know;Disagree" var="[form_var]"
    widget 0 4 2 1 button text=Next

    and in the inline script:

    #

    Check if text is entered when clicking next; otherwise rerun rating_scale

    #

    while True:
    # If the response has the value 'None':
    if self.get('response2') == '':
    # Rerun the item (after preparing it):
    items['new_form_base'].prepare()
    items['new_form_base'].run()

    # Else, the experiment advances normally.
    else:
        break
    

    I also included a logger item at the end and when I opened the excel sheet it says "None" under the column of "response2" if I don't select an option and continued with the next button.

  • I tried with other type of questions but where did I go wrong this time? I can still click next when I have no user input.

    Technically you can always click the next button, but the inline script that follows will rerun the form until an answer is given.


    I also included a logger item at the end and when I opened the excel sheet it says "None" under the column of "response2" if I don't select an option and continued with the next button.

    This is correct behavior right? "response2" is "None" when you don't select an option and continued with the next button.


    The only thing I can think of that might be the problem is that you use:

    items['new_form_base'].prepare()

    items['new_form_base'].run()
    Is the form called new_form_base?


    Note you can make your posts much more readable by using some tips reported here:

  • edited September 2016

    Hi Jarik,

    Yup, the form is called new_form_base (for now). The thing is, I do need to collect the responses, in that case, agree would be scored as 0, don't know as 1 and disagree as 2. I don't want my participants to be clicking "next" without inputting anything because then I would have missing information. Is there any way I can allow the form to rerun again until they select an option like how it worked for the open-ended question?

    Also, my open-ended question is new_form_text_input because I need to collect their exact responses that they typed out. The open-ended question ran again (when there is no input) and worked perfectly with your code!

  • OK I see now the test you want to use is:
    if var.response2 == None:


    Note you test for == None instead of == ''for the rating_scale widget in the new_form_base. The output from the logger item kind of indicated this in your previous post ;)

    Also note I changed self.get('response2') to var.response2. This is better/easier and new in OpenSesame 3 see:

    Best,
    Jarik

  • edited September 2016

    That worked perfect!! Thank you so much. I also tried on simple multiple choice questions where the options are "Yes", "No", "Maybe". When there is no input, the output was registered as a "no" in the response column. When there is an input, the output appears as one of the 3 options avail. I tried to do something similar in the inline script where I test for:
    if var.response3 == no: (or if var.response3 == None:) but that doesn't work hmm. Ultimately, I have the same goal. I need the form to rerun until an option is selected.

  • Can you try if var.response3 == 'no': or maybe if var.response3 == 'No':

  • var.response3 == 'no' works! Thank you so much Jarik!!! I appreciate it a lot!

  • Hello everybody,

    I'm new in opensesame and I'm a noob ;D.

    How do I ensure that the participants can only click the "next" button when there is an input?

    This was my code:


    set timeout infinite

    set spacing 10

    set rows "1;1;1;1;1;1;1;1;1"

    set only_render no

    set margins "50;50;50;50"

    set description "A generic form plug-in"

    set cols "1;1"

    set _theme gray


    widget 0 0 2 1 label text="<b><span style='font-size:28px;'>Wie attraktiv sind folgende Merkmale in einer Beziehung?</span></b>"

    widget 0 0 2 2 label text="<span style='font-size:18px;'>1:unattraktiv, 2:eher unattraktiv, 3:ausgeglichen, 4:attraktiv, 5:sehr attraktiv</span>"

    widget 0 2 1 1 label center=no text=zärtlich

    widget 1 2 1 1 rating_scale nodes="-2;-1;0;1;2" var=question1

    widget 0 3 1 1 label center=no text=Ehrgeiz

    widget 1 3 1 1 rating_scale nodes="1;2;3;4;5" var=question2

    widget 0 4 1 1 label center=no text=strenge

    widget 1 4 1 1 rating_scale nodes="1;2;3;4;5" var=question3

    widget 0 5 1 1 label center=no text=überlegen

    widget 1 5 1 1 rating_scale nodes="1;2;3;4;5" var=question4

    widget 0 6 1 1 label center=no text=risikofreudig

    widget 1 6 1 1 rating_scale nodes="1;2;3;4;5" var=question5

    widget 0 7 1 1 label center=no text=kreativ

    widget 1 7 1 1 rating_scale nodes="1;2;3;4;5" var=question6

    widget 0 8 2 1 button text=Next



    thank you!

    pacobenko

  • Hi @pacobenko ,


    Did you already have a look at this post?


    Perhaps that helps. If not, feel free to get back to us.


    Cheers,


    Lotje

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

  • edited December 2020

    PS: the most simple way to advance to the next trial only when all questions are answered, is to place an inline_script item after your form_base item and place the following code in its Run phase tab:


    # Make a list of all the response values:
    responseList = [var.question1, var.question2, var.question3]
    
    if None in responseList:
    
    	# Rerun the item:
    	items.execute(u'form_base')
    


    Perhaps that helps.


    Cheers,


    Lotje

    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