Issue with online feedback code: conditions file column not pushing to PsychoJS

OS : MacOS Catalina
PsychoPy version : 2020.2.10
**Standard Standalone?: yes
URL of experiment: New_Cinema_Expe [PsychoPy]

What are you trying to achieve?:

I am designing an experiment where participants are shown video clips and have to click a mouse whenever they spot a continuity edit. I’ve marked these moments by adding a polygon of 1 second duration (starting slightly before and finishing slightly after the continuity edit). This enables me to see if participants have clicked around the moment of interest (polygon) or simply on the movie clip at a different moment. As part of the training for the experiment, I am including feedback within a trial loop as shown below. In the loop, participants view 12 short movie clips (of a few seconds long) in which there are either
a. no continuity edit (correct response is to not click) or
b. continuity edits (correct response is to click on the polygon).

The feedback code uses the output column ‘respTrain.clicked_name’ and the column ‘corrAns’ from my conditions file as shown below.

Screen Shot 2021-01-12 at 11.02.38 AM

Screen Shot 2021-01-12 at 11.10.56 AM

In ‘Begin Experiment’, I’ve put

msg=["Correct!", "Incorrect!"]

In ‘Begin Routine’ I’ve put

if respTrain.clicked_name==corrAns:
    msg = "Correct!"
    msgcolor='green'    
else:
        msg = "Incorrect!"
        msgcolor='red'

Description of the problem:

The feedback (as shown above) works correctly offline but doesn’t work when pushed to Pavlovia. There is no error message and everything seems to run fine except that the feedback is always ‘Incorrect!’ and when I look at the Output .csv file, the corrAns column is empty, so nothing from corrAns is being printed out.

What did you try to make it work?:

I understand the issue has to do with my two variable columns (corrAns and respTrain.clicked_name) not having the same format in PsychoPy and PsychoJS, which means they do not match.

Following a suggestion from another thread (https://discourse.psychopy.org/t/correct-answer-not-registered-in-online-experiment/13453/2) I first tried converting the ‘respTrain.clicked_name’ column to a string with the code

if respTrain.clicked_name.toString()==corrAns:
    msg = "Correct!"
    msgcolor='green' 

and changing the ‘corrAns’ variable in my excel file from [“polygonTrain”, “trainClips”] to polygonTrain, trainClips as that is how it should come out after converting to a string. This successfully printed the corrAns column in the output file but did not match the mouse column, so the feedback still wasn’t correct.

I then tried using the ‘split function’ to convert the corrAns variable into two strings using ‘,’ ‘;’ and ‘_’ in my conditions file (e.g. polygonTrain_trainClips instead of [“polygonTrain”, “trainClips”]) and adding a split function in the code in Begin Routine which printed corrAns successfully in the output file but still does not match the format of respTrain.clicked_name so the feedback still only appears as ‘Incorrect!’.

I would very much appreciate any pointers on how to proceed if anyone has run into the same problem. I must add that I am new to both coding and PsychoPy so am sure that there is a lot I am not understanding.

Many thanks in advance for any help!
Best,
Alice

You can’t compare two lists. Instead you need to compare elements of lists. For example, if respTrain.clicked_name in corrAns

hi! Thank you very much for looking into this and for your suggestion!

I have tried using “if respTrain.clicked_name in corrAns” but receive the following error message: Screen Shot 2021-01-12 at 1.47.28 PM

  • i’ve tried different formats for my corrAns column as it clearly isn’t being printed but the error persists. Should I have converted the lists to another format first?

Thank you!

Can you just have a flag in the Excel and then set corrAns in code based on it?

Alternatively, perhaps you should have the objects in two columns and compare the clicked name with each of those columns.

Part of the issue might be that your code has to cope with when there are no correct answers. You could have a dummy list for that situation such as [‘xxx’]

Thanks for the tips! the first idea ended up working great - I gave up on having corrAns but did set a flag to set the appropriate feedback in code which was perfect.

(for anyone following here is what I used with flagFeed being my flag (1 or 0))

if ((flagFeed === 0)) {
    if ((respTrain.clicked_name.length === 0)) {
        msg = "Correct!";
        msgcolor = "green";
    } else {
        msg = "Incorrect!";
        msgcolor = "red";
    }
}
if ((flagFeed === 1)) {
    if ((respTrain.clicked_name.length === 0)) {
        msg = "Incorrect!";
        msgcolor = "red";
    } else {
        if ((respTrain.clicked_name[0] === corrAns)) {
            msg = "Correct!";
            msgcolor = "green";
        } else {
            msg = "Incorrect!";
            msgcolor = "red";
        }
    }
}
psychoJS.experiment.addData("msg", msg);