psychopy.org | Reference | Downloads | Github

Conditional Loop Works in PsychoPy but not on Pavlovia

URL of experiment: https://pavlovia.org/run/maisonallen/trial-1/html/

Description of the problem:
Hi!
I am trying to create a conditional looping procedure that works online. I was able to make it work in PsychoPy with the addition of a routine with a code component, but it does not work via Pavlovia. I am unsure what I should do and have tried modifying the code with no success. I want the outer loop (set to 999 nReps) to terminate if the participant answers every question correct. This is what I have so far:

Routine_1_C
Begin experiment:
score = 0

End routine:
if key_resp_6.corr:
····score = score + 1

End_Routine
End routine:
if score > 0.99:
····break

I do not have much coding experience so I appreciate any help.


Hi @maisonallen, if you have Python code in a code component, you will have to translate the Python code to JavaScript manually. To translate the code, open your code component dialog and select the code type as “Both”, so you can see Python and JavaScript panels on the left and right, respectively. Now you can see the Python code in the left panel, and you can type in the equivalent JavaScript in the right panel. JS is not so different from Python, so translating the code will not be too challenging. E.g., some JS

// If statement
if (key_resp_6.corr === 1) {
    score = score + 1;
}

Perfect, thank you very much @dvbridges !