Here’s my solution:
In Builder, insert routine with text stimulus where you want your feedback to be presented (just as you would normally do, but do NOT add a code component to the routine). Add a variable (e.g. $feedback_message) as text to the text component and ‘set every repeat’.
When you’ve exported the experiment, open the index.html file in a text editor.
Search (cmd + F) for your variable (feedback_message). You should get to a line saying
// update component parameters for each repeat
Note that if you forgot to ‘set every repeat’, you would have to add the
line yourself. You would also have to jump to the section where your feedback routine is initialized and change text to:
text : ‘default text’
- Just above this line, add your code (what you would write in your code component), e.g.:
number_correct = key_upper_left.corr + key_upper_right.corr;
feedback_message = number_correct + ’ of 4 numbers correct’;