In routine 2, filter only those questions from routine1 that were answered with "4"

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): 2020.2.4

In a screening phase I want to show participants several questions without answer.
In a study phase I want to show participants the questions from the screening phase again, but only those that were
specifically rated (e.g. 4 on a rating/slider component) together with the answer to that question.
I created a routine 1 where all questions are presented and rated, this works fine. However, I don´t know how to filter
a specific part of these questions (those answered with e.g. 4) and show them again in a second routine.
Can anybody help me with this problem?


I would use a Code component for this, you can iterate through the sliders in routine 1 and add all those where the response was 4 to a list, then you can show/hide sliders in routine 2 accordingly. I’m going to call your sliders in routine 1 slider1_x and in routine 2 slider2_x for simplicity, but you’ll need to replace these with the names you used.

Somewhere, add a Code component with this in the Begin Experiment tab:

keepSliders = []

In routine 1, add a Code component with this in the End Routine tab:

# Iterate through sliders and add them to a list if they are to be kept
for thisSlider in [slider1_1, slider1_2, slider1_3, ```etc```]:
    if thisSlider.value == 4:

In routine 2, add a Code component with this in the Begin Routine tab:

# Create a dict to match routine 1 sliders to routine 2 sliders
sliderMap = {
    slider2_1: slider1_1,
    slider2_2: slider1_2,
    slider2_3: slider1_3,
# Iterate through sliders and hide them if their counterpart is not in the list created earlier
for thisSlider in [slider2_1, slider2_2, slider2_3, ```etc```]:
    if sliderMap[thisSlider] in keepSliders:
        thisSlider.opacity = 1
        thisSlider.opacity = 0

Dear TParsons

Thank you so much for your prompt answer!
I think I did not express myself well.
In routine 1, a participant sees several questions. For each question, the participant indicates to what extend she /he knows the answer on a four point scale.
In routine 2, I want to show this participant only those questions she/he answered with 4 in routine 1 together with the correct answer to that question.

E.g. A participant screens 30 questions in routine 1 and indicates for 10 questions he/she does absolutely not know the answer (pressed “4” on the slider).
In routine 2, only these 10 questions are shown again together with the correct answer.

Hi There,

This is possible locally using an approach outlined in this thread here Using answers from the form component but note that currently this will not work if you want this online. This is because we still need to ensure the Forms component (in psychoJS) accepts the format we create ‘on the fly’ (in this case a list of dictionaries, where only the dictionaries previously recieving a specific answer are included).