Howdy, Stranger!

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

Supported by

[solved] Reversing rating scales and logging variables

edited April 2016 in OpenSesame

Hi everyone ! First of all, i'd like to apologize for my english as I am french native.
I've just begun learning how to use open sesame and I have two questions I hope you can answer :

  • I wonder how to reverse the value of a rating scale ? If the subject clicks on node n°1 in a rating scale consisting of 5 nodes, I want the variable correspondant being equal to 4 instead of 0. It would be useful for coding reversed items.

  • My second question concerns the logger and variables. I am using scales in my experiment and i've separated each question in a form_base item. When open sesame logs the results, i want it to save each response individually, without calculating a mean for my scale. As a consequence, my only resort was to use a different variable name for each question, which totally separates questions which originate from the same scale.
    So here's my question : Is it possible to store numerous values in the same variable without them being cumulated or averaged ?

I've uploaded two pictures to illustrate my second question.
image
image

I hope i was precise enough, I would be very glad if you could bypass my english and find the time to answer at least one of my questions.

Have a good day !

Comments

  • edited April 2016

    Hi Olivier,

    Welcome to the forum!

    I wonder how to reverse the value of a rating scale ?

    As far as i know this is not possible using the rating_scale widgets since it is hardcoded into the plug-in. But there are a number of ways to work around that.

    So here's my question : Is it possible to store numerous values in the same variable without them being cumulated or averaged ?

    Yes, that is possible by defining the variable as a list but you'll need to add some scripting.

    Looking over the pictures you added, it might be a better idea to create different loop for you different scales and initialize the forms that contain the questions in an inline_script and loop over the questions sequential.

    Let's combine both questions: add a loop item into your satisfaction sequence and add two variables, let's say 'scale_question' and 'recode'. The first variable contains all the questions, while the second variable only contains 'yes' or 'no', depending on whether the question needs recoding.

    In this new loop add a sequence that contains an inline_script and your logger. In this script add something like the following:

    # Create your rating scale widget:
    
    # Import the modules
    from libopensesame import widgets
    
    # Name your form and, the default is just fine
    form = widgets.form(exp)
    
    # Name the label, which is the question from you scale
    # note that the text is the variable you defined in the new loop item
    label = widgets.label(form, text=var.scale_question)
    
    # Create the nodes and define the resonse variable, for example 'var1'
    rating_scale = widgets.rating_scale(form, nodes=['0', '1',
            '2','3','4'], var='var1')
    
    # Add a button to continue
    button = widgets.button(form, text='Continue')
    
    # Position the widgets
    form.set_widget(label, (0,0))
    form.set_widget(rating_scale, (1,0))
    form.set_widget(button, (1,1))
    
    # execute the form
    form._exec()
    
    # Here the script checks if the question should be reversed
    
    if var.recode == 'yes':
        if var.var1 == 0:
            var.var1 = 4
        elif var.var1 == 1:
            var.var1 = 3
            # etc. etc.
    
    # Append the latest trial value to your list of values
    var.reponse_list.append(var.var1)
    

    And as a final step, add another inline_script at the start of your questionnaires_sequence in which you create an empty list: var.response_list = []

    If you now run your experiment you'll end up with a logfile that contains a variable with every individual answer in one column and a variable (your list) that contains all responses combined.

    Let me know if this is what you had in mind and if it works!

    Cheers,
    Laurent

  • edited 12:06AM

    Hi Laurent !
    Thank you for your response, which is really complete !
    Your solution for reversing the rating scales works like a charm, and i've tried using the scripts as you intended for my second question.
    At first i got great results, and as long as i was using only one loop, everything turned out great. The screenshot shows the expected result :image

    But when I tried using it on all my scales, my log file contained values I didn't enter. I think it's due to the fact that all my scales don't have the same amount of questions.

    I had to learn to use inline_script and a bit of python_language, but still didn't succeed.
    I finished by understanding what was the role of response_list and that i didn't need it : I want my questions in their respective scales, not in a general variable.

    Your script was still useful and I will use it, I just have to figure out my last problem.

    I doubt you can help me with so little cue about what is actually the problem i'm facing, but i'm still posting a screenshot, in case the solution is obvious.

    Have a good day !
    image

  • edited 12:06AM

    Hi Olivier,

    Good that you got the first part working!

    I'm not sure about the remaining issue though:

    I want my questions in their respective scales, not in a general variable.

    What exactly do you mean with 'scales' here? Is it the value in the likert-scale? Or a subset of questions in your questionnaire?

    I'm assuming you mean the latter of the two. In that case, would it suffice to add additional variables to the questionnaire loops (e.g. satisfaction, CSB etc.) indicating the scale the questions belong to? For example, based on the first picture, you add a variable Difficulte to your satisfaction loop and assign the values to the corresponding questions: 'm', 'f' or 'd'. Add the Difficulte variable to the logger and you should end up with the example you provided.

    Futhermore, and i should've thought of this earlier my apologies, you can replace the whole if else statements for recoding the answer with something simpler:

    # Python starts counting at 0, so add 1 to obtain the correct Likert-scale value first
    var.var1 = var.var1 + 1
    
    # Print to check
    print "Old value is %d" % var.var1
    
    # Check if the answer needs recoding and reverse the value
    if var.recode == 'yes':
        var.var1 = 8 - var.var1
    
    # Print again to check  
    print "New value is %d" % var.var1
    

    Let me know if this gets you any further!

  • edited 12:06AM

    Hi Laurent,
    Thanks again for your response. Concerning the recode statement, your last version if effectively much simpler, even though I managed to get what i wanted with the first writing.
    On the subject of my variables, I think you understood what i wanted to get, and as I asked the help of my professor, we eventually ended up with the exact result i was trying to reach.
    To do so, we made only one loop containing all our variables : [recode], [scale_question], [domain] to precise the scale the question is coming from and [changement_label] which decides which label the rating scale should have at its sides. Like in so :
    image

    In the trial sequence following, we put all our inline_scripts which would be running only when their domain corresponded. As seen here :
    image

    By creating a single variable [reponses_items] containing all our responses, we had the [response_list] you were suggering, but the items were labelled by their [domain] and [scale_question] in the resulting file. It shows like this in the logger :
    image

    And I ended with a file looking like that :
    image

    Anyway, I couldn't have done it without your help and my professor, so thank you again.
    I feel like I could do it again, and that's as important as having this final result.
    Have a good day !

  • edited 12:06AM

    Hi Olivier,

    Glad to hear it all works now. After seeing the last file i understand what the problem was. Good luck with your study!

Sign In or Register to comment.