Action (pressing a button) linked to a specific block


Author
Message
NinaBergner
NinaBergner
Associate Member (144 reputation)Associate Member (144 reputation)Associate Member (144 reputation)Associate Member (144 reputation)Associate Member (144 reputation)Associate Member (144 reputation)Associate Member (144 reputation)Associate Member (144 reputation)Associate Member (144 reputation)
Group: Forum Members
Posts: 10, Visits: 53
Hi Dave!

I have difficulties linking a button press to a specific block. If participants click on 'YES', they should be directed to block2 (the one that comes after the block Buttonpress); and if they click on 'NO' that they should be directed to block3 (the block that comes after block2). How do I achieve this? 


<text Yes>
/items = ("Yes")
/position = (75%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/ vjustify = center
</text>

<text No>
/items = ("No")
/position = (25%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/vjustify = center
</text>

<trial Buttonpress>
/inputdevice = mouse
/stimulusframes = [1 = Buttonpress, Yes, No]
/validresponse = (Yes, No)
?
</trial>


<block Buttonpress>
/trials = [1 = Buttonpress]
</block>

Thank you in advance,

Nina
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
NinaBergner - 12/3/2020
Hi Dave!

I have difficulties linking a button press to a specific block. If participants click on 'YES', they should be directed to block2 (the one that comes after the block Buttonpress); and if they click on 'NO' that they should be directed to block3 (the block that comes after block2). How do I achieve this? 


<text Yes>
/items = ("Yes")
/position = (75%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/ vjustify = center
</text>

<text No>
/items = ("No")
/position = (25%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/vjustify = center
</text>

<trial Buttonpress>
/inputdevice = mouse
/stimulusframes = [1 = Buttonpress, Yes, No]
/validresponse = (Yes, No)
?
</trial>


<block Buttonpress>
/trials = [1 = Buttonpress]
</block>

Thank you in advance,

Nina

You need to eiher /branch from <block Buttonpress> to the appropriate follow-on block based on the trial's response or alternatively define appropriate /skip commands in block2 and block3.



Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
Dave - 12/3/2020
NinaBergner - 12/3/2020
Hi Dave!

I have difficulties linking a button press to a specific block. If participants click on 'YES', they should be directed to block2 (the one that comes after the block Buttonpress); and if they click on 'NO' that they should be directed to block3 (the block that comes after block2). How do I achieve this? 


<text Yes>
/items = ("Yes")
/position = (75%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/ vjustify = center
</text>

<text No>
/items = ("No")
/position = (25%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/vjustify = center
</text>

<trial Buttonpress>
/inputdevice = mouse
/stimulusframes = [1 = Buttonpress, Yes, No]
/validresponse = (Yes, No)
?
</trial>


<block Buttonpress>
/trials = [1 = Buttonpress]
</block>

Thank you in advance,

Nina

You need to eiher /branch from <block Buttonpress> to the appropriate follow-on block based on the trial's response or alternatively define appropriate /skip commands in block2 and block3.



The /branch variant:

<text Yes>
/items = ("Yes")
/position = (75%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/ vjustify = center
</text>

<text No>
/items = ("No")
/position = (25%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/vjustify = center
</text>

<trial Buttonpress>
/inputdevice = mouse
/stimulusframes = [1 = Yes, No]
/validresponse = (Yes, No)
/ inputdevice = mouse
</trial>


<block Buttonpress>
/trials = [1 = Buttonpress]
/ branch = [
    if (trial.Buttonpress.response == "Yes"){
        block.block2;
    } else if (trial.Buttonpress.response == "No") {
        block.block3;
    }
]
</block>

<block block2>
/ trials = [1=mytrial]
</block>

<block block3>
/ trials = [1=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 2000
</trial>

<text mytext>
/ items = ("This is <%script.currentblock%>")
</text>

<expt>
/ blocks = [1=Buttonpress]
</expt>


The /skip variant:

<text Yes>
/items = ("Yes")
/position = (75%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/ vjustify = center
</text>

<text No>
/items = ("No")
/position = (25%, 93%)
/ fontstyle = ("TimesNewRoman", 1.75%, false, false, false, false, 5, 1)
/ txcolor = (white)
/txbgcolor = (black)
/size = (15%, 10%)
/vjustify = center
</text>

<trial Buttonpress>
/inputdevice = mouse
/stimulusframes = [1 = Yes, No]
/validresponse = (Yes, No)
/ inputdevice = mouse
</trial>


<block Buttonpress>
/trials = [1 = Buttonpress]
</block>

<block block2>
/ skip = [
    trial.Buttonpress.response == "No"
]
/ trials = [1=mytrial]
</block>

<block block3>
/ trials = [1=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 2000
</trial>

<text mytext>
/ items = ("This is <%script.currentblock%>")
</text>

<expt>
/ blocks = [1=Buttonpress; 2 = block2; 3 = block3]
</expt>


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search