Coding using expInfo

Hello
I want to apply a small piece of code to check the expInfo for the session number, and if it is 3 then the participant can see the whole debrief message. I’m slowly learning coding, and I know from one of @Becca videos that you can use participant id to remind participants on the debrief page so it is building on that idea.

I am thinking that it must be something on the lines of

msg = ’ ’

if expInfo[‘session’] == ‘3’:
. msg = “full debrief goes here”

then something for if it is not 3

The experiment info in the compiled file is
expInfo = {‘participant’: ‘’, ‘session’: [‘1’, ‘2’, ‘3’]}

I have tried a few things and I have searched the forum.
Best wishes
Glen

Well, I think I’ve done that ok for that part now (I kept getting a syntax error in the js window)

#creating a message variable
msg = ’ ’
#specifying the message to be shown
if expInfo[‘session’] == ‘3’:
msg = “This is the final task in the experiment. Thankyou for taking part in this task. This study, in which participants are asked to cblah blah blah”

Next thing is to code it so the screen previous terminates if the session is 1 or 2, but i am assuming I can simply do that with continueRoutine

Stream of my consciousness here, but if ther eise anything better I can do please let me know.

glen

Hi Glen,

Your code looks perfect to me, I think this might be ab issue with your computer settings somehow using “curly” quotations instead of non curly - below if your same code but with the quotations replaced - does that work if you copy and paste it in?

#creating a message variable
msg = ' '
#specifying the message to be shown
if expInfo['session'] == '3':
    msg = 'This is the final task in the experiment. Thankyou for taking part in this task. This study, in which participants are asked to cblah blah blah'

It does. I have also got it to do the other thing I want too. I’m rather pleased with myself.

I wouldn’t have got even close without your video though. I’m incorporating that into a template for my students.

Thanks for the video tutorials, I love them.

Glen

You are so very welcome!

Becca

1 Like