How to randomize feedback or create conditional feedback

Hello,

I am trying to create conditional feedback for my experiment, I usually use the builder so writing the code for this has been a little bit more complicated than I hoped.
The goal is for on some trials, the participant sees “correct” or “incorrect” based on how they responded. I have this working properly. But, I also need it on some trials (randomly) to not say anything at all, no feedback. I’m not sure in python or JS how to make this work. Initially, I was thinking I could add a column in the excel sheet with the stimuli labeling them as feedback or no_feedback, and then in the code put create
if $ExcelColumnName = feedback and resp1.corr:
response_fdb = ‘Correct’
elif $ExcelColumnName = feedback and ???: {not sure how I would make this resp1 incorrect}
response_fdb = ‘Incorrect’

Then if the excel column doesn’t say feedback, nothing would be displayed.
This direction would obviously not give me the randomized feedback like I’d prefer, but at least it would be pseudo-randomized.
However this has not worked out for me and it doesn’t run, or nothing shows on the screen at all. Any suggestions would be extremely helpful and appreciated!

I think your proposed solution should work modifing your code like this:

if $ExcelColumnName = feedback:
    if resp1.corr:
        response_fdb = ‘Correct’
    else:
        response_fdb = ‘Incorrect’
else:
    #don't show anything (can be achieved in different ways)    

I am not an expert on in-code randomization, but I think you can generate a random variable for each routine (e.g. from 0 to 1) and if the random number is in a certain range of value you can skip the routine with the same method.

1 Like

Hello,

if  $ExcelColumnName == feedback:

use a double = for logical comparisons.

If you want to do this during the run of the experiment, try the following: Insert a code-component as the first component in your routine. In the Begin Experiment tab of your feedback-routine

showFeed = 99
msg = " "

Begin Routine tab

showFeed = randint(0,2)


if showFeed:
    if key_resp.corr:
        msg = "correct"
    else:
        msg = "wrong"
else:
    continueRoutine = False

Notice that the approach using Excel allows you to determine the amount of shown and not-shown feedback messages. This is not the case with the code-approach.

Best wishes Jens

Hello,

Thanks so much for the response. I tried the code you proposed and it is giving me an error at the first line and will not run. By using $ExcelColumnName, does the code recognize this as being an excel column? The excel file is in the loop, does it need to be somewhere in the code as well?

If you change $ExcelColumnName to the specific column name you used in your excel file it should work

Hello,

what is the error message?

As @tandy wrote $ExcelColumnName should be replace with column name used in the Excel-file. It is sufficient that the Excel-file is in the “loop”.

Best wishes Jens