Rating scale with reverse scoring

Hello,

My colleague and I want to create a program on psychopy in which we enter an anxiety questionnaire. However, some of the items in this questionnaire need to be coded reversly (1= 4 , 2 = 3 , 3 = 2, 4 = 1).

Although we have succeeded in creating the loop to integrate the rating scale, we are unable to program the reverse coding of the items concerned.

Could someone please tell me the cause of the problem, please?

To do so we insert a Routine in the loop (just after the trial) and entered in the custom “code” :

ratingScale=visual.RatingScale(win)
if Scoring=='normal':
    revscore=ratingScale.getRating()
    thisExp.addOtherData("revscore", revscore)
elif Scoring=='reverse':
    revscore=(5 - (ratingScale.getRating()))
    thisExp.addOtherData("revscore", revscore)

Thanks in advance

So what went wrong? Did the revscore column show up in your output data? Did you get an error message?

With this line, you’re creating a new ratingScale if I’m not mistaken.
But what you probably want is not a new ratingScale object but the existing object which you used to record the rating.

Are you using the Builder interface or the Coder interface? If you’re using the coder interface, which Tab did you use in the Code Component window?