Howdy, Stranger!

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

Supported by

[solved] how to set my output to 1,2,3

edited August 2014 in OpenSesame

Hello all,

I am trying to make a simple questionnaire.

-each question has two options, for example: A. Cat or B. Dog

  • when i "logger" the response, the output is exactly that: "A. Cat"

--> i would like for the out put to be 0's and 1's

how do i set it up so that the output is a 0 for when answered A, and a 1 for when the participant answers B ?

please help

thank you :)

Comments

  • edited 12:50PM

    Hi,

    What you could do is create a new variable, let's call it recoded_response, that basically the maps the original response ('A. Cat') to a recoded value (0). A simple script like the one below should do the trick. This should be in the run-phase of an inline_script that directly follows the form. See the code comments for an explanation.

    Cheers!
    Sebastiaan

    # A dictionary with the original responses as keys, and the recoded
    # responses as values.
    response_codes = {
        'A. Cat' : 0,
        'B. Dog' : 1
        }
    # Get the original response, assuming that `response` is indicated as
    # response variable in your form.
    original_response = self.get('response')
    # Give an informative message if the original response is not listed
    # in the response codes. This is a sanity check in case we make a
    # typo etc.
    if original_response not in response_codes:
        raise Exception('Don\'t know how to recode %s' % original_response_)
    # Set a new variable, called `recoded_response` with the recoded
    # response.
    exp.set('recoded_response', response_codes[original_response])
    
  • edited 12:50PM

    phenomenal ! Thank you Seb...

    one more question: how can i centre the Form_multiple_choice plug in?
    i would like the radio button options to be presented in the middle(centre) of the screen vs. Left

    thanks

  • edited 12:50PM

    Hi,

    The form_multiple_choice plug-in does not allow you to center the radio buttons. However, if you want more flexibility, you can always create your own custom form using the form_base plug-in. That's not too difficult and is described here:

    Cheers!
    Sebastiaan

  • edited August 2014

    Seb! this application is amazing! i feel like a computer programmer ! so smart! lol

    one more question seeing as youre soo amazingly helpful!

    how do i do a dynamic display?
    simple design of a bar which increases as the number of key presses increases.

    let me know.
    thanks

  • edited 12:50PM

    Hi,

    If you want to implement these kinds of dynamic stimuli, you'll have to use Python scripting. You will find various discussions on this forum, showing sliders, etc. For example here:

    This shows the general idea, and should help you get started, but obviously it's not exactly what you need. So what I would is first walk through a Python tutorial to get a basic understanding of Python, and then try to implement your growing bar, possibly based on code snippets here on the forum.

    If you get stuck, feel free to ask. But make sure to provide enough detail so that it's clear what exactly you want to achieve, what you've done so far, and why it doesn't work as you'd like.

    Cheers!
    Sebastiaan

  • edited 12:50PM

    thx

  • edited 12:50PM

    Marking this as solved. For potential questions on the dynamic display, please open a dedicated thread (so that it can be found more easily for reference later on).

Sign In or Register to comment.