Data entry issue when moving experiment to Pavlovia

URL of experiment: WW_1_adults [PsychoPy]

In my experiment, participants are shown 32 experimental trials where they choose between two images. After the first 16 trials, they are asked a simple question to make sure they are paying attention. In this attention trial, they are asked to click one of two answers. They then complete the other 16 trials.

I am running into an issue where if the participant clicks the location of the two attention trial answers during the experimental trials, the experiment records the response in the final csv file. I would just like the response to be recorded during the actual attention trial, and not during the experimental trials. I had this issue when I ran it locally through PsychoPy, but I moved the code used to score the attention trial (see below) to “Each Frame” from “End Routine”, which fixed the problem. Now that I have synced the project to Pavlovia, it doesn’t work anymore.

Below is code used to score the attention trial:

#In Begin Routine
document.body.style.cursor='auto';
if testingLoop.thisTrialN != 15:
    continueRoutine=False

#In Each Frame
if elephant.contains(clickchoice4):
    thisExp.addData ('acRT', t)
    thisExp.addData('acclicked', "elephant")
    score = 1
    thisExp.addData('acscore', score)
elif wolf.contains(clickchoice4):
    thisExp.addData ('acRT', t)
    thisExp.addData('acclicked', "wolf")
    score = 0
    thisExp.addData('acscore', score)

Hi,

If I understand you correctly then you only want this scoring to happen on Trial 15 and End Routine code is activated when continureRoutine = False so you “hid” the code into Each Frame?

My suggestion would be to put it back in End Routine but include the Trial number test, i.e.

#In Begin Routine
document.body.style.cursor='auto';
if testingLoop.thisTrialN != 15:
    continueRoutine=False

#In End Routine
if testingLoop.thisTrialN == 15:
    if elephant.contains(clickchoice4):
        thisExp.addData ('acRT', t)
        thisExp.addData('acclicked', "elephant")
        score = 1
        thisExp.addData('acscore', score)
    elif wolf.contains(clickchoice4):
        thisExp.addData ('acRT', t)
        thisExp.addData('acclicked', "wolf")
        score = 0
        thisExp.addData('acscore', score)

This worked, thank you so much!