Manual edits to JS code (continueRoutine = false) not reflecting in Pavlovia experiment

URL of experiment: Rachel Moy / selfaffirm · GitLab

Description of the problem: I built my reaction time based experiment in Psychopy builder, but had to add the following manual code in the Python script to only move onto the next prompt upon user’s correct keyboard input (as users have to click either “p” or “q” on the keyboard each time):

if key_resp.corr:
continueRoutine = False

However I learned that when my experiment is pushed online through Pavlovia, my manual Python code isn’t reflected. I’ve tried editing the JS code in Psychopy coder, and manually in Pavlovia, but I can’t seem to make it work.
I’m not sure if if’s either:

  1. as a JS newbie I did not code it correctly hence it’s not responding, or
  2. What’s the best way to incorporate a manual code tweak in Pavlovia (in Psychopy or in Pavlovia directly) or
  3. I also read online that the “continueRoutine” command in Python may not work in JS but I’m not sure how to replace/change it so that it will work for Pavlovia.

The JS code I attempted to add in Psychopy coder and Pavlovia:
if (key_resp.corr): {
continueRoutine = False
}

Any advice would be tremendously appreciated!

Do not use coder if you want to run your experiment online. Add code components to Builder.

Thanks wakecarter.

Then I guess my question is do you have any advice how to add this 1 component to Builder.
Currently in Builder my allowed keys for keyboard input is “p” and “q”, but essentially for each prompt only either p or q is the correct answer and I want the experiment to only move onto the next prompt when user clicks the correct input. But with Builder, it will move onto the next with either p or q, and I can’t figure out where to tell it to only end the routine upon correct response.

Which is why I manually added the 2 rows below to my code.
Is there any way I can reflect this in Builder?

            if key_resp.corr:
                continueRoutine = False

Thank you!

  • Go to the “custom” component panel.
  • Click the “Code” icon.
  • Put the code in the “each frame” tab.
  • If “auto → JS” is selected, Builder will attempt to automatically translate your Python code to Javascript. If that doesn’t work, instead select “Both”, where you can manually edit the Javascript, independently of the Python code (but for a simple example like this, the automatic translation should do OK).

Thank you so much! This worked for me after clearing up a few noob mistakes. Thank you :slight_smile: