psychopy.org | Reference | Downloads | Github

Manipulation check with code component checking silder ratings

Hi there,

I have a manipulation check in my experiment. This check is based on five ratings m1, m2, m3, m4, m5 using the slider component. The correct responses are m1=4, m2=2, m3=3, m4=4, m5=1.

After participants have made their ratings a code component checks the ratings. If correct the routine will end, if not correct a msg will be shown that the participants have to re-evaluate their ratings.

What I did so far:

Begin of experiment
msg=''

Each frame:


if 'escape' in keys: 
    core.quit()

if 'space' in keys:
    completed_ratings = 0
    for slider in [m1, m2, m3, m4, m5]:
        if slider.getRating() is not None:
            completed_ratings = completed_ratings + 1

    if completed_ratings == 5 and m1.response == 4 and m2.response == 2 and m3.response == 3 and m4.response == 4 and m5.response == 1:
        continueRoutine = False
else:
    msg="Wrong! Please check your answers"

(credits to this thread as well: HERE)

The ratings in the csv-file are stored in columns called m1.response and so on. But the sessions ends and returns the following error:

if completed_ratings == 5 and m1.response == 4 and m2.response == 2 and m3.response == 3 and m4.response == 4 and m5.response == 1:
AttributeError: 'Slider' object has no attribute 'response'

I think the function you want is .getRating(), not an attribute called .response:

https://www.psychopy.org/api/visual/slider.html#psychopy.visual.Slider.getRating

1 Like

Hi Michael,

you are right! :slight_smile:
I adjusted it as follows:

keys = event.getKeys()

if 'space' in keys and m1.getRating() and m2.getRating() and m3.getRating() and m4.getRating() and m5.getRating() and m6.getRating() is not None:
    rating1 = int(m1.getRating())
    rating2 = int(m2.getRating())
    rating3 = int(m3.getRating())
    rating4 = int(m4.getRating())
    rating5 = int(m5.getRating())
    if rating1 == 4 and rating2 == 2 and rating3 == 3 and rating4 == 4 and rating5 == 1:
        continueRoutine = False