Howdy, Stranger!

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

Supported by

[solved] Multiple response collection on one page

edited May 2013 in OpenSesame

Hi there,
I need help constructing a page within an experiment. What I would like to do is present an image (5 designs labelled a-e) and ask them to type in the correct answer. I also need them to type in how confident they are in their answer from 0-100% and then decided whether they want to include their answer in their overall score. Right now i have each part on a seperate page:

  • image= sketchpad, keyboardresponse, log
  • confidence rating= textinput, log
  • include answer= textdispaly, keyboard response, log

The issue is we want the image to remain on the screen while they type in their confidence and whether or not they want to include their score. We also want their confidence rating to show on the screen.

I hope this makes sense. Any tips would be greatly appreciated!!



  • edited 9:00AM

    Hi Sylvia,

    Do I understand correctly that you preferably want all those questions as part of the same display? So that you have, say, the 5 imags on the left side of the screen, all the input fields on the right, and a continue to next question button on the bottom?

    Right now, this is not possible without a lot of inline scripting. But what you could do is

    • a) Use your current approach, where the questions are presented sequentially. You could take a look at this post to see how you can combine a sketchpad item with a text input, so that you can keep the images on the screen during the participant's response.

    • b) Try the latest pre-release of OpenSesame 0.27. OpenSesame 0.27 will include forms, which provide the functionality that you need, more-or-less out of the box. You can find out more about forms here. Please note that 0.27 is not officially out yet, so you will need to evaluate for yourself whether it's stable enough for your purpose. You can find out more about the pre-releases here.

    Good luck and don't hesitate to ask questions!


  • edited 9:00AM

    Hi Sebastian,
    I have been trying to combine my sketchpad with my text_input but I don't quite understand the inline script that you put here

    My sketchpad has 5 images. I want the participant to be able to view these images while typing in their response in text_input, then pressing "enter" to go to the next page, which will be another question requiring text_input while viewing the same 5 images.

    What would I type in the editing script for the text_input to show my previous images (located on my sketchpad).

    Sorry I have no experience in programming :(

    Thank you,

  • edited September 2012

    Hi Sylvia,

    I thought about it for a bit, and I think it might be best to go with option B—the forms. I don't generally recommend using a development version of OpenSesame, but in this case using the new form functionality is so much easier than coding everything by hand. Also, the 0.27 pre-releases are reasonably stable by now, so it should be usable (although there still may be some bugs!).

    The following steps should get you started.

    • First obtain the latest pre-release (currently 0.27~pre5), as described here.
    • Start a new experiment and change the back-end to legacy (this probably not necessary, but just to be on the safe side, as xpyriment is still under development).
    • Use a form_base plug-in to ask your questions. This is very flexible and doesn't require any real programming.

    In your case, the following script should give you more-or-less what you need. See the documentation here to find out how to use and extend scripts of this type. Basically, you just drag a form_base plug-in into your trial sequence, click on the 'Edit script' button, and paste the script below. You can fully customize your forms, including multiple-choice questions, button-boxes, etc.

    set rows "1;1;1;1"
    set cols "1;1;1;1;1"
    widget 0 0 1 1 image path="0.png"
    widget 1 0 1 1 image path="1.png"
    widget 2 0 1 1 image path="2.png"
    widget 3 0 1 1 image path="3.png"
    widget 4 0 1 1 image path="4.png"
    widget 0 1 5 1 label text="Your question here"
    # var='response' means that the participant's response is stored in the variable 'response'
    widget 0 2 5 1 text_input focus="yes" return_accepts="yes" var="response"
    widget 0 3 5 1 button text="Next"

    The resulting form looks like this (the exact appearance depends on your experiment settings):


    The example script uses static values, but you can also use variables like so:

    widget 4 0 1 1 image path="[image_nr].png"

    Good luck and don't hesitate to post more questions. Also, if you end up using forms, I'd love to learn about your experiences, because it's a very new feature.


  • edited 9:00AM

    Hi Sebastiaan,
    Thanks for your help! My experiment is nearly done :)
    I have a few more issues that are not big deals but it would perfect my experiment.

    Using a form_base, I have a rating scale and a "next button". What do I write in the open sesame script so the person can't click the next button without answering the rating scale?

    Also, for text input I want the person to enter a number from 0-100. Is there a way to only allow numeric numbers to be written (no text ex: "13r") and up to three numbers, example they wouldn't be allowed to type "1000".

    I hope this makes sense.
    Your program is great :)


  • Hi Sylvia,

    Firstly, I would recommend to download the latest pre-release (pre11), because the form functionality was updated today (30-09-2012).

    With regard to your question, the forms do not contain built-in functionality for this yet (although it might be a useful addition for the future). Therefore, the best way to control whether your form is correctly filled in is to use a bit of Python inline code. This can be achieved as follows:

    • prepare your form_base but set Run if in the corresponding sequence to "never";
    • if desired, do the same for a displays containing a warning message about the incompleteness of the form;
    • append an inline_script item to the sequence. Make sure the inline script is placed after the prepared displays.

    With this inline_script, you can:

    • execute the prepared form_base;
    • check whether the response meets your criteria;
    • keep executing the form_base until the criteria are met;
    • if desired, display a warning message.

    In the example experiment below, two items are prepared:

    • a form_base, containing a form_text_input;
    • a warning message saying that the input should be a number between 0 and 100.

    The following inline code, which should be placed in the run tab of the inline_script item, gives the desired result (see comments for a more detailed explanation):


    The complete example experiment can be found here (simply download and "save as" with the extension ".opensesame").

    I hope this helps! Please let us know if you have any further questions, for example about how to adapt the example script to your specific situation.

    Best wishes,


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

  • edited 9:00AM

    Hi Lotje,
    Thank you so much for your feedback. The script you wrote works perfectly! The only trouble I am having now is logging the responses. I put a logger item after my form_base and want to collect their response (text input and rating scale responses). My form base is set to "run if never". I have tried to set the logger item as "run if never" and "run if always" but it still doesnt collect responses. I am not sure what to do to collect the responses.

    Thank you,

  • edited 9:00AM

    Hi Sylvia,

    Thanks for your post! It turns out that indeed response variables set in forms are not (always) detected automatically by the logger item. Sebastiaan fixed this for the next update! So one thing you could do is to download the latest pre-release.

    Alternatively, you could manually add your response variables to you logger item. This could be achieved as follows:

    • (If you don't know them) look up the missing variable names in the "edit script" tab of your form base.
    • Open the tab of your logger item and deselect "automatically detect and log all variables"
    • Click the "Add custom variable" button at the top right and simply add the additional variable names you want to log.

    Does this solve your problem? If not, please let us know!

    Best wishes,


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

  • edited 9:00AM

    Hi Lotje,
    Thank you for your quick response. That is how I added all my custom variables but in excel it says "none" under the variable. I wasn't sure if I set the order of the forms correctly or filled the "run if" incorrectly.
    I will try to new update and see if this fixes the problem.

    Thank you,

  • edited 9:00AM

    Hi there,
    I was wondering if the new updates will solve my ongoing problem.
    My experiment runs smoothly however the responses are not being collected in Excel.
    I have three part:
    1. Selecting the correct answer from a rating scale
    2. Typing in a number (e.g. 75) from 0-100 [There is no right answer because it is their personal rating of their confidence.]
    3. Selecting yes or no [There is no right answer.]

    I want to collect their response (#1) and show the correct response then tell me if it's correct or incorract (3 seperate columns).

    I want to collect their confidence rating (#2) and collect yes/no (#3).

    Right now Excel is telling me the correct answer and what question they are on.

    I have done custom variables so the responses should be recognized, but on excel the response is blank or says "none".

    Any tips?

    Thank you,

  • Hi Sylvia,

    Did you already obtain the latest pre-release (currently 0.27~pre26) as described here, to see whether this solves your problem?

    If updating did not help, you could perhaps upload your experiment here. Then we can have a closer look at what might be going on. It's difficult to figure out why the responses from your form are not logged without some additional information about your experiment. But I'm sure we can solve it if you provide us with some more details.

    Best wishes,


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

  • Hi Sylvia,

    Some variables in your log file have the value 'None' since you log them before the corresponding question is shown, and therefore before the participant gave a response. This is because you set the run-if statement of the form_base items to never, and only initiate a given form in a subsequent inline_script item. So, at least a logger item should be placed after the appropriate inline_script item. Does that make sense?

    Secondly, I would like to advice you to use a single logger item, because this will make the organisation of your final log file much more clear.

    In short, I think your problem will be solved when applying the following two suggestions:

    • Only use one logger item, in which you log all (relevant) variables of a given trial.
    • And place this logger at the end of your trial sequence.

    By the way, I noticed that column spans in your form_base items do not always correspond to how you defined the columns. For example, after defining three columns of equal width like so:

    set col "1;1;1"

    the maximum column span of a given widget is 3. In the most recent pre-release(s) this is effectively checked, and setting a widget with an invalid column span, such as

    widget 0 1 10 1 image path="CR.jpg"

    will give an error message.

    I hope this helps!

    Best wishes,


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

  • edited 9:00AM

    thank you Lotje!! My experiment if finally complete! I appreciate your team's help :)


  • Hi Sylvia,

    You're welcome! And good to know that your experiment is finished!

    Feel free to ask any more questions in the future!


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

  • edited September 2014

    Dear Lotje,

    I would like to use your script that checks if all inputs are correct & given before the participant can continue.

    The only difference is that I have an inline scripted form.
    I have added a sketchpad called "warning_message" before the inlinescripted form called "SRHI_ongezond_deel_1". Both are set to run if 'never' like you instruct.
    You can read the code below..

    The problem now is the warning message does not go away when you press a key and also that after filling in all ratingscales and pressing the next button,you still get stuck in the warning message...

    What did I do wrong?

    Thanks a lot..


    (I can also send my experiment if you like).

    #this is my code with yours in it:
    from libopensesame import widgets
    allowedList = range(1,8,1)
    form = widgets.form(self.experiment, cols=[3,2], rows=[1,1,1,1,1,1,1,1], spacing = 10)
    titel = widgets.label(form,  text='Ongezond snacken is iets...', center=False)
    vraag1 = widgets.label(form,  text='1. dat ik regelmatig doe', center=False)
    vraag2 = widgets.label(form,  text='2. dat ik automatisch doe', center=False)
    vraag3 = widgets.label(form,  text='3. dat ik doe zonder het me bewust te herinneren', center=False)
    vraag4 = widgets.label(form,  text='4. dat me een vreemd gevoel geeft als ik het niet doe', center=False)
    vraag5 = widgets.label(form,  text='5. dat ik doe zonder er bij na te denken', center=False)
    vraag6 = widgets.label(form,  text='6. dat moeite kost om niet te doen', center=False)
    instructie= widgets.label(form, text='1 = helemaal oneens, 7 = helemaal eens')
    ratingScale1 = widgets.rating_scale(form, var='ongezond_SRHI_item1',
        nodes=['1', '2', '3', '4', '5', '6', '7'])
    ratingScale2 = widgets.rating_scale(form, var='ongezond_SRHI_item2',
        nodes=['1', '2', '3', '4', '5', '6', '7'])
    ratingScale3 = widgets.rating_scale(form, var='ongezond_SRHI_item3',
        nodes=['1', '2', '3', '4', '5', '6', '7'])
    ratingScale4 = widgets.rating_scale(form, var='ongezond_SRHI_item4',
        nodes=['1', '2', '3', '4', '5', '6', '7'])
    ratingScale5 = widgets.rating_scale(form, var='ongezond_SRHI_item5',
        nodes=['1', '2', '3', '4', '5', '6', '7'])
    ratingScale6 = widgets.rating_scale(form, var='ongezond_SRHI_item6',
        nodes=['1', '2', '3', '4', '5', '6', '7'])
    nextButton = widgets.button(form, text='Verder')
    form.set_widget(titel, (0,0), colspan=1)
    form.set_widget(vraag1, (0,1))
    form.set_widget(vraag2, (0,2))
    form.set_widget(vraag3, (0,3))
    form.set_widget(vraag4, (0,4))
    form.set_widget(vraag5, (0,5))
    form.set_widget(vraag6, (0,6))
    form.set_widget(instructie, (1,0))
    form.set_widget(ratingScale1, (1,1))
    form.set_widget(ratingScale2, (1,2))
    form.set_widget(ratingScale3, (1,3))
    form.set_widget(ratingScale4, (1,4))
    form.set_widget(ratingScale5, (1,5))
    form.set_widget(ratingScale6, (1,6))    
    form.set_widget(nextButton, (0,7), colspan=2)
    while True:
            # Make a variable storing whether the form is completely filled
            # in on or not. The starting value is False. If one of the
            # 'checks' below is not met, its set to True:
            incomplete = False
            # Execute the prepared form_base:
            # Check whether the variable "response" is a number between 0 and 100,
            # that is, whether it is one of the allowed responses from the list
            # defined above:
            if not self.get("ongezond_SRHI_item1") or self.get("ongezond_SRHI_item2") or self.get("ongezond_SRHI_item3") or self.get("ongezond_SRHI_item4") or self.get("ongezond_SRHI_item5") or self.get("ongezond_SRHI_item6") in allowedList:
                    incomplete = True
            # If incomplete is still False, break out of this while loop
            # and continue with the experiment.
            if not incomplete:
            # If the form turns out to be incomplete, show a warning.
                    # Next, the form_base will be executed again.
                    # This continues as long as the form is incomplete.
  • edited 9:00AM

    Dear Lotje,

    the sketchpad is set to run if never.. the inline script is set to run if always..

  • edited May 2013

    Hi Natalie,

    The problem now is the warning message does not go away when you press a key

    I think your experiment ends up in an infinite loop because you put all the Python code in one and the same inline script.

    More specifically:

    • You first prepare and run the form (from the beginning of your script to form._exec())
    • And then (from while True: to the end of your code) you enter a while loop that does not rerun anything, so the criterion (incomplete = True) does not get a second chance to be met. As a consequence, the only thing your whileloop does, is continuously showing the warning_message.

    To solve this, I would suggest that you put the first part of your while loop in the Run phase tab of a separate inline_script item (e.g. 'create_form') and set the Run-if condition of this item to 'never'.

    Change the script in the other inline_script item (the initial one, that is set to run ;always') such that it does rerun the 'create_form' inline_script:

    while True:
        # Make a variable storing whether the form is completely filled
        # in on or not. The starting value is False. If one of the
        # 'checks' below is not met, its set to True:
        incomplete = False
        # Execute the prepared inline_script item:
        # (If you placed all the Python script in the Run phase tab, only
        # executing the run phase of your item is enough here)
        # Check whether your criteria are met:
        # The easiests way to do that here is to see whether none of your response 
        # variables are set to 'None'. 'None' indicates that no box was ticked, whereas
        # any other variable indicates that the question was not left unanswered.
        # That's all you need to know, right?
        if (self.get("ongezond_SRHI_item1") == "None" or self.get("ongezond_SRHI_item2") == "None" or \
            self.get("ongezond_SRHI_item3") == "None" or self.get("ongezond_SRHI_item4") == "None" or \
            self.get("ongezond_SRHI_item4") == "None" or self.get("ongezond_SRHI_item6") == "None"):
            incomplete = True
        # If incomplete is still False, break out of this while loop
        # and continue with the experiment.
        if not incomplete:
        # If the form turns out to be incomplete, show a warning.
            # Next, the form_base will be executed again.
            # This continues as long as the form is incomplete.

    and also that after filling in all ratingscales and pressing the next button,you still get stuck in the warning message...

    This has to do with the statement you used for checking whether your criteria are met. For you, the easiest way is just to check whether none of the response variables have the value 'None', because this automatically implies that all of the questions obtained a response (see the code and comments above).

    Also, note that you can't concatenate 'or' operations in the way you did.

    if not self.get('var1') or self.get('var2') in allowedList

    will not work as desired and should be

    if not self.get('var1') in allowedList or self.get('var2') in allowedList

    Does this make sense?

    I uploaded a working example experiment here (download, change the extension from .txt into .opensesame and open as normally):



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

  • edited 9:00AM

    Dear Lotje,
    It works perfect, thank you very much!

  • I have a similar question. I would like to present an image and ask participants click on all parts of the image that they think are relevant (e.g., click on everything that you think is evidence in this crime scene) and store the results. Would there be an easy way to do this? Thanks!

  • edited March 2017

    Hi Frouke,

    There might be other/ simpler ways, but maybe something like this?

    • Create a typical trial_sequence containing a sketchpad, a mouse_response and a logger item
    • Set the run-if statements of the mouse_response and the logger to never

    • Handle the execution of these two items in the Run_phase tab of an inline_script item:

    I attached an example script (please unzip first).

    The "drawback" of this method is that you will end up with multiple rows per trial (containing the coordinates of the respective mouseclicks).

    Is this okay for you?



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

  • Hi Lotje,

    I have a similar question -- but the solution didn't quite work for me. I am pragramming an operation span task, where participants are presented with a sequence of letters and math equations across multiple trials, and at the end of each sequence, they are asked to serially recall the letters they saw. I tried to create a form with buttons for each letter (a list of 12 consonants) but it only allows me to click on one button. I would need the user to be allowed to click on multiple buttons ( and see the letters they selected), and then store the result in an array.

    Thanks in advance!

    Kind regards,


  • I actually managed to use what you suggested as a basis to save what the user clicks on with a sketchpad item and inline script, but I would like to be able to display on the same screen the user's input, so if the user selects F, J, K, L, they would see that in a box below.

    I defined the locations for 12 letters in the setup script and made an empty list for the letters that were displayed and an empty array for the letters the user clicks on, and I would like the user to be able to see their selections on the sketchpad. I tried to create a string from the array and display that in the sketchpad, but it is not working. Would you have any suggestions?

    Eventually I will need to compare the the sequence of letters displayed to the letters the user selects.

    while True:

    if var.cursor_x > var.x_button and var.cursor_x < (var.x_button + var.w_button)\
        and var.cursor_y > var.y_button and var.cursor_y < (var.y_button + var.h_button):
        if var.cursor_x > var.Fx_button and var.cursor_x < (var.Fx_button + var.w_button)\
        and var.cursor_y > var.Fy_button and var.cursor_y < (var.Fy_button + var.h_button):
        if var.cursor_x > var.Hx_button and var.cursor_x < (var.Hx_button + var.w_button)\
        and var.cursor_y > var.Hy_button and var.cursor_y < (var.Hy_button + var.h_button):
        if var.cursor_x > var.Jx_button and var.cursor_x < (var.Jx_button + var.w_button)\
        and var.cursor_y > var.Jy_button and var.cursor_y < (var.Jy_button + var.h_button):

    ... and so on for another 9 letters....

    print userLettersList
    var.userLetters = ''.join(userLettersList)
    print var.userLetters
  • I would like to present many images as a list (30) and I want the participant to choose how many they want (so it is multiple choose) by clicking on the image that they think they enjoyed. And after choosing I want to show them all what they chose with tree questions about their selection (on likert type).  

    I had tried something so basically (in below) but in this case, this image list are presented not randomly and I couldn't manage the create the second part. Could you help me?

    Thank you

     var='response' means that the participant's response is stored in the variable 'response'

    # var='response' means that the participant's response is stored in the variable 'response'

    set timeout infinite

    set spacing 10

    set rows "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;1;1;1;1"

    set _theme gray

    widget 0 0 1 1 image path="0192.png"

    widget 1 0 1 1 image path="0004.png"

    widget 2 0 1 1 image path="0022.png"

    widget 3 0 1 1 image path="0566.png"

    widget 4 0 1 1 image path="0528.png"

    widget 5 0 1 1 image path="0189.png"

    widget 0 1 1 1 image path="0201.png"

    widget 1 1 1 1 image path="0032.png"

    widget 2 1 1 1 image path="0050.png"

    widget 3 1 1 1 image path="0065.png"

    widget 4 1 1 1 image path="0526.png"

    widget 5 1 1 1 image path="0502.png"

    idget 0 2 1 1 image path="0482.png"

    widget 1 2 1 1 image path="0234.png"

    widget 2 2 1 1 image path="0163.png"

    widget 3 2 1 1 image path="0162.png"

    widget 4 2 1 1 image path="0237.png"

    widget 5 2 1 1 image path="0069.png"

    widget 0 3 1 1 image path="0088.png"

    widget 1 3 1 1 image path="0465.png"

    widget 2 3 1 1 image path="0089.png"

    widget 3 3 1 1 image path="0447.png"

    widget 4 3 1 1 image path="0362.png"

    widget 5 3 1 1 image path="0104.png"

    widget 0 4 1 1 image path="0267.png"

    widget 1 4 1 1 image path="0299.png"

    widget 2 4 1 1 image path="0117.png"

    widget 3 4 1 1 image path="0332.png"

    widget 4 4 1 1 image path="0131.png"

    widget 5 4 1 1 image path="0361.png"

  • Hi,

    Do you want to present all images at the same time? Like a sketchpad with 30 small images on it? Or is it also alright if the images are presented sequentially?

    IN any case, what you want is to add each chosen image to a list. Once you have the list, you can randomize is and use it as source for the second phase (instead of a loop table).

    Let me know if you need more help.


    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 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