I have a feedback loop to show participants if their response was correct and their response time (in seconds). The experiment will be run online, not locally. Everything works great when I run the experiment PsychoPy, but it is not working with Pavlovia.
The code component is currently set at Auto → JS. I have the following code in the Py section on the left:
if resp.corr:#stored on last run routine
msg="Correct! Response time = "+str(round(resp.rt, ndigits=2))
else:
msg="Oops! That was wrong."
– which PsychoPy auto-translated to JS, showing up on the right of the code component:
if (resp.corr) {
msg = ("Correct! Response time = " + Math.round(resp.rt).toString());
} else {
msg = "Oops! That was wrong.";
}
What I already tried:
When I run the experiment locally on PsychoPy it works fine. However, when I sync it with Pavlovia and then run the experiment online, the rounding does not work. I already tried changing the Code Type on the component to JS only and used the following codes, which did not work:
if (resp.corr) {
msg = ("Correct! Response time = " + Math.round(resp.rt).toString(3));
} else {
msg = "Oops! That was wrong.";
if (resp.corr) {
msg = ("Correct! Response time = " + Math.round(resp.rt).toFixed(3));
} else {
msg = "Oops! That was wrong.";
}
Attaching a screenshot of what the code component window looks like in Builder. The codes not shown in the screenshot below are copied and pasted above.