Feedback with checkboxes

Hi all,

I have a loop with 4 checkboxes in each frame and I want to give the participants direct feedback on which checkboxes they clicked. I know how to do this with text but I want to show the clicked checkboxes again. In principle, I need to retrieve the given answers and simply show or retrieve the clicked checkboxes in the feedback to simply change the color of the clicked ones. I hope I have not formulated it too awkwardly. Does anyone have an idea how I can do this best?

What type of component are you using for the checkboxes? I’m not sure about setting the default values in a form component, but it would be simple enough to create checkboxes using image components.

Hey @wakecarter,

for the checkboxes, I use the “polygon” four times. I wrote a code to mark them black if clicked and back to white if clicked again. That works perfect. See Screenshot 1:

You can see that I want in the next step of the routine to give feedback. But not only text like: “u clicked box…” I want to show the boxes again and make these boxes colored again which were clicked. So I need a little bit of code. Here is what I have:


The last line (14) is good to give Feedback with text. Hope you’ll have a solution.

Your box stimuli still exist in memory, and will retain their latest state (e.g. colour) until it is explicitly changed.

So you could simply do something like this in the “begin routine” tab of the next routine:

# re-display the checkboxes from the previous routine:
for box in [box_p1_1, box_p1_2, box_p1_3, box_p1_4]:
    box.autoDraw = True

@Michael

Thank you very much. That looks easier than I thought, and it works perfectly. But is it possible to show only these boxes that clicked?

Another question I have is the log. I log the clicked boxes like this:

thisExp.addData(‘outcome’, clicked)

and in my CSV file, it looks like this in one column:

[box1, box3]

I would like to have for every box a separate column, and if a box were clicked 1 and if not clicked 0. Is there a simple solution, or should I code for every box a separate integer?

# re-display the checkboxes from the previous routine:
for box in [box_p1_1, box_p1_2, box_p1_3, box_p1_4]:
    if box.color == 'black':
        box.autoDraw = True
# record whether each box was clicked (i.e. its colour is black):
for box in [box_p1_1, box_p1_2, box_p1_3, box_p1_4]:
    thisExp.addData(box.name, int(box.color == 'black'))

@Michael

wow, so easy. I thought too complicated. Thank u very much for your quick response. But something is not working with the re-display function. If I put the if box.color ==“black”: in the code nothing is shown anymore. And in the log I can see now the separate coloums but all are 0. So it looks like that booth problems have something to do with the "box.color == “black”.

Important information: You have to “deactivate” the autoDraw function at the end of the Routine tab. Otherwise, you’ll see the forms in the next Routine.

Check to see what is going on:

# re-display the checkboxes from the previous routine:
for box in [box_p1_1, box_p1_2, box_p1_3, box_p1_4]:

    # temporary debugging code (delete when no longer needed):
    print(f'Box: {box.name} Colour: {box.color}.')

    if box.color == 'black':
        box.autoDraw = True

@Michael

hmm…I can’t see anything. Only in the psydat file I can see that something is going wrong. Let me send you a test experiment including your code.

temp.psyexp (21.6 KB)