Howdy, Stranger!

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

Supported by

Using multiple choice forms with a picture

Hi,

I am trying to prepare and experiment where I am going to show a picture and ask questions. I need to have in the same page a picture and multiple choice question. I could not find how to do that.

Thanks

Ergun

Comments

  • FabFab
    edited October 2024

    Hi @Ergun,

    There would be multiple ways of achieving this. IU'm assuming you're looking for a solution in open Sesame and not OSWeb (since you posted this message in this forum).

    Here are a coupe of ways to do it:

    Method 1

    Usiing an inine_script object (Python) to draw a new canvas, display the picture and the question, then show the canvas. You then use the keyboard object to take a response.

    The Canvas can be drawn like using code like this in its "PREPARE" phase:

    # START_PREPARE_PHASE
    my_canvas = Canvas() # Create a Canvas object
    my_canvas['image'] = Image(pool['d23.png'], x=0, y=-150) # Add image to canvas. Adjust x, y for positioning
    my_canvas.text('What name would you give this creature?', x=0, y=100) # Add question to the canvas
    my_canvas.text('1. Zorglub', x=0, y=150) # Add options to the canvas
    my_canvas.text('2. Bixby', x=0, y=180)
    my_canvas.text('3. Leno', x=0, y=210)
    # END_PREPARE_PHASE:
    

    and like this in its "RUN" phase:

    # START_RUN_PHASE
    my_canvas.show() # Show the Canvas with the image and text
    # END_RUN_PHASE
    

    You can limit the accepted key strokes for the keyboard object to avoid that a response is taken if the participant presses anything else than the 1, 2 or 3 keys (in my example).


    Method 2

    Method 2 uses the form_base object (see documentation: https://osdoc.cogsci.nl/4.0/manual/forms/custom/).


    It consists in displaying the form that you designed in the way you want information to be displayed. For example:

    # Display the image (occupying a larger row)
    # Display the question
    # Add the multiple-choice buttons
    set timeout infinite
    set spacing 10
    set rows "2;1;1;1;1"
    set only_render no
    set margins "50;50;50;50"
    set description Example
    set cols 1
    set _theme gray
    widget 0 0 1 1 image path="d93.png"
    widget 0 1 1 1 label text="What do you think this creature's hobby is?"
    widget 0 2 1 1 button text=Painting var=button_painting
    widget 0 3 1 1 button text=Jogging var=button_jogging
    widget 0 4 1 1 button text=Yoga var=button_yoga
    

    In this example, I'm using buttons for the possible response options, and since Open Sesame only registers whether a button is pressed as a "yes" or "no", we then need an inline_script object (Python) to process the response and strore it in a variable (in this example, in the "response" variable).

    if button_painting == 'yes':
    response = 'Painting'
    elif button_jogging == 'yes':
    response = 'Jogging'
    elif button_yoga == 'yes':
    response = 'Yoga'
    else:
    selected_hobby = 'No selection'
    


    Note that for both methods, you must make sure that the images are stored in the pool.

    Also note that I here set the questions, image and response options litterally. If you were to run many trials, you'd want to store this information in variables of the loop and then modify the methods above to inject the variable names where appropriate using the { }.

    I attach a working example of both methods.


    Note that other methods are possible (e.g., you could program the whole thing directly in Python if you wished to). If you were planning to run your experiment in a browser, you'd have to rely on javascript-based solutions.

    Best,

    Fabrice.

    Buy Me A Coffee

Sign In or Register to comment.