psychopy.org | Reference | Downloads | Github

Feedback on participant response

Hello!

I’m using builder and inputting custom code into a routine. I have an experiment in which a participant types in an answer, and then that answer is compared to a conditions excel file. They then get feedback via a counter, that adds one point if they are correct, and no points if they are incorrect. It works with my desktop version, but I’m not sure how to translate it into JS to work on Pavlovia. The automatic translate feature is not working. Any help would be appreciated. Here is my code:

*Begin experiment*

Points= 0 

*Begin routine*
*PCR.keys is the input from the previous routine, corrAns is the column name of the correct answer in my conditions file*

if PCR.keys == corrAns:
    Points += 1

I’m not sure what I’ve done wrong.

Thanks!

Do you mean you get a syntax error on the JS side?

Does it work offline?

Sorry for being unclear.

I actually don’t get any syntax error, but the code isn’t doing what it should online.That is my psychopy code. It works perfectly offline. I used the auto translate PsychoPy to JS feature in the custom code component of builder, but when I run the experiment online, everything runs, but the counter doesn’t update. It just stays at zero, despite me inputting correct answers. I’m unsure of what the issue with the JS code is. Here it is.

*Begin experiment*
Points = 0;

*Begin Routine*
if ((PCR.keys === corrAns)) {
    Points += 1;
}

Try

if corrAns in PCR.keys:

which should work better if the issue is that corrAns is a string and PCR.keys is a list.

Also try

print('Does ',PCR.keys,' equal ',corrAns)

just before your if statement to see if you can stop the issue in the browser console.

So PCR.keys isn’t a list. It’s just the answer that is given each trial. Basically in each trial the participant types in an answer, and then should get feedback on if the answer is correct or incorrect. This would happen by a point being added if their typed in answer for that specific trial matches the conditions file. so the type in part is a routine, the feedback is a routine, and its connected through a loop that has the conditions file in it.

The program is running but the counter for the feedback still isn’t running, even with the suggestions. I’m really stuck and not sure why. If it helps I could post my online experiment so you can see what I mean.

If you asked PsychoPy to store the correct response, an alternative approach could be this:

if ((PCR.corr === 1)) {
    Points += 1;
}

Jan