Variable where feedback should be based on is not working

Hello,

I am trying to give my participants feedback after giving a response on the slider tool. The correct answer is supposed to be a random number between 1 and 10. If the random threshold is hit, participants should win the lottery and if the select a number below it, they should lose.

Somehow PsychoPy seems not be able to find the variable I want to use. If I complete a test experiment the variable is called “slider_lottery.response_raw” but when I put this in the code it gives me the error “AttributeError: ‘Slider’ object has no attribute ‘response_raw’”.

How can I fix this problem?


I am very new to PsychPy and Phyton, to begin with, but I remember a post on here saying that names are extremely important, so firstly, Does your slider component have the same name as the Excel sheet component you show? if so, I suggest maybe changing it; why do you need that column anwyay? since randint will generate a random number between 1-10. Second, if I understand correctly, you are saying you want it to say Gwonnen when correct and Verloren when incorrect and you want the ‘correct answer’ to be a random number between 1-10? If so, I think you need to separate out the random number assigned to the slider as being correct and the feedback that the participant is getting. Hopefully, this makes sense. Sorry that I couldn’t be of more help. I will try and link that post I talked about here. :slight_smile:

Hello

despite the fact that there is a column in your data-file called “slider_lottery.response_raw”, you get the chosen rating with

slider_lottery.getRating()

So, something along the following untested lines should work

if slider_lottery.getRating >= randint(1,10):
    fbMsg = "Gewonnen"
else:
   fbMsg = "Verloren"

Best wishes Jens

2 Likes

find one here. this is the one I was talking about, but was struggling to find the actual one.

Dear JensBoelte,

thank you very much for your reply! It´s actually (almost) working now.

After running a few trials PsychoPy crashes and is giving me the following error:

Type Error: ‘>=’ not supported between instances of ‘NoneType’ and ‘int’

What does that mean?

Hello

that means that the routine ended before a rating has been given. I assume that the rating-component does not end the routine? See checkbox Force end of Routine

So either tick that box or change the code-component to

if not slider_lottery.getRating():
    fbMsg = "kein Rating"
elif slider_lottery.getRating >= randint(1,10):
    fbMsg = "Gewonnen"
else:
   fbMsg = "Verloren"

Best wishes Jens

2 Likes

Dear JensBoelte,

The experiment does not allow the rating component to end the routine, I need a seperate space bar activity to do so. Even though if I set a starting point on the slider, the experiment crashes if the slider is not moved before pressing space bar.

Your recommendation to use the code like that unfortunately does not work for my purpose. If I do it like you suggested, the Message would always be “kein Rating” even if the slider was put to zero, where it is always supposed to show “Verloren”.

It works (almost) with the following Code:

from random import randint

Annahme: slider_lottery ist ein Objekt mit der Methode getRating()

rating = slider_lottery.getRating()

if rating == 0:
fbMsg = “Verloren”
elif rating >= randint(1, 10):
fbMsg = “Gewonnen”
else:
fbMsg = “Verloren”

The issue is the fact, that even if I set a starting point on the slider, PsychoPy does not seem to save any response as long as the slider is not being moved before pressing space bar. So my only solution would be to not set a starting point on the slider? Can I make PsychoPy “accept” the rating even if the starting point is used by participants in any way?

Hello

Why don’t you simply change the message?

if not slider_lottery.getRating():
    fbMsg = "Verloren"
elif slider_lottery.getRating >= randint(1,10):
    fbMsg = "Gewonnen"
else:
   fbMsg = "Verloren"

Well, a starting point is not a rating :wink: But the starting point is optional. According to the slider’s help page, it is not possible to set a rating. There is no setRating() equivalent to getRating().

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