Correct response


Author
Message
EvaM
EvaM
New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)
Group: Forum Members
Posts: 3, Visits: 39
Hi,

This is probably a stupid question, but I'm completely new to coding and cannot seem to figure it out.

I'm trying to get the correct response to be dependent on the location of a probe, which randomly appears on the left (25% hposition) or the right (75% hposition). If the probe appears on the left, I want "N" to be the correct response; and if the probe appears on the right, the "M" key.

I'm using the following code to randomize the probe location:

<list practiceproberandomizer>
/ items = (25%, 75%)
/ selectionrate = always
</list>


And my latest attempt for the correct response, which I've adjusted from a different script:

/ iscorrectresponse = [
    return ((list.practiceproberandomizer.nextvalue == 25% && parameters.responsekey_left) ||
            (list.practiceproberandomizer.nextvalue == 75% && parameters.responsekey_right));
    ]


The script runs, but the feedback appears to be random so this isn't working. Most of my other attempts have resulted in the script not running and an error saying Missing '[', for instance with these attempts:

/ iscorrectresponse = (parameters.responsekey_left if list.practiceproberandomizer.nextvalue == 25% else parameters.responsekey_right)
/ iscorrectresponse = (parameters.responsekey_left if [list.practiceproberandomizer.nextvalue == 25%] else parameters.responsekey_right)
/ iscorrectresponse = if (list.practiceproberandomizer.nextvalue == 25%; parameters.responsekey_left) else if (list.practiceproberandomizer.nextvalue == 75%; parameters.responsekey_right)

I hope someone can help me with this, thanks in advance!!

Best,
Eva

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
EvaM - 3/30/2022
Hi,

This is probably a stupid question, but I'm completely new to coding and cannot seem to figure it out.

I'm trying to get the correct response to be dependent on the location of a probe, which randomly appears on the left (25% hposition) or the right (75% hposition). If the probe appears on the left, I want "N" to be the correct response; and if the probe appears on the right, the "M" key.

I'm using the following code to randomize the probe location:

<list practiceproberandomizer>
/ items = (25%, 75%)
/ selectionrate = always
</list>


And my latest attempt for the correct response, which I've adjusted from a different script:

/ iscorrectresponse = [
    return ((list.practiceproberandomizer.nextvalue == 25% && parameters.responsekey_left) ||
            (list.practiceproberandomizer.nextvalue == 75% && parameters.responsekey_right));
    ]


The script runs, but the feedback appears to be random so this isn't working. Most of my other attempts have resulted in the script not running and an error saying Missing '[', for instance with these attempts:

/ iscorrectresponse = (parameters.responsekey_left if list.practiceproberandomizer.nextvalue == 25% else parameters.responsekey_right)
/ iscorrectresponse = (parameters.responsekey_left if [list.practiceproberandomizer.nextvalue == 25%] else parameters.responsekey_right)
/ iscorrectresponse = if (list.practiceproberandomizer.nextvalue == 25%; parameters.responsekey_left) else if (list.practiceproberandomizer.nextvalue == 75%; parameters.responsekey_right)

I hope someone can help me with this, thanks in advance!!

Best,
Eva

I would do something like this:

<parameters>
/ responsekey_left = "N"
/ responsekey_right = "M"
</parameters>

<values>
/ probex = 0%
/ correctkey = " "
</values>

<list practiceproberandomizer>
/ items = (25%, 75%)
/ selectionrate = always
</list>

<text probe>
/ items = ("P")
/ hposition = values.probex
</text>

<text c>
/ items = ("CORRECT")
/ txcolor = green
</text>

<text e>
/ items = ("ERROR")
/ txcolor = red
</text>

<block myblock>
/ trials = [1-10 = mytrial]
</block>

<trial mytrial>
/ ontrialbegin = [
    values.probex = list.practiceproberandomizer.nextvalue;
    if (values.probex == 25%) {
        values.correctkey = parameters.responsekey_left;
    } else if (values.probex == 75%) {
        values.correctkey = parameters.responsekey_right;
    }
]
/ stimulusframes = [1=probe]
/ validresponse = (parameters.responsekey_left, parameters.responsekey_right)
/ correctresponse = (values.correctkey)
/ correctmessage = true(c, 500)
/ errormessage = true(e, 500)
</trial>



Edited 2 Years Ago by Dave
EvaM
EvaM
New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)New Member (25 reputation)
Group: Forum Members
Posts: 3, Visits: 39
Dave - 3/30/2022
EvaM - 3/30/2022
Hi,

This is probably a stupid question, but I'm completely new to coding and cannot seem to figure it out.

I'm trying to get the correct response to be dependent on the location of a probe, which randomly appears on the left (25% hposition) or the right (75% hposition). If the probe appears on the left, I want "N" to be the correct response; and if the probe appears on the right, the "M" key.

I'm using the following code to randomize the probe location:

<list practiceproberandomizer>
/ items = (25%, 75%)
/ selectionrate = always
</list>


And my latest attempt for the correct response, which I've adjusted from a different script:

/ iscorrectresponse = [
    return ((list.practiceproberandomizer.nextvalue == 25% && parameters.responsekey_left) ||
            (list.practiceproberandomizer.nextvalue == 75% && parameters.responsekey_right));
    ]


The script runs, but the feedback appears to be random so this isn't working. Most of my other attempts have resulted in the script not running and an error saying Missing '[', for instance with these attempts:

/ iscorrectresponse = (parameters.responsekey_left if list.practiceproberandomizer.nextvalue == 25% else parameters.responsekey_right)
/ iscorrectresponse = (parameters.responsekey_left if [list.practiceproberandomizer.nextvalue == 25%] else parameters.responsekey_right)
/ iscorrectresponse = if (list.practiceproberandomizer.nextvalue == 25%; parameters.responsekey_left) else if (list.practiceproberandomizer.nextvalue == 75%; parameters.responsekey_right)

I hope someone can help me with this, thanks in advance!!

Best,
Eva

I would do something like this:

<parameters>
/ responsekey_left = "N"
/ responsekey_right = "M"
</parameters>

<values>
/ probex = 0%
/ correctkey = " "
</values>

<list practiceproberandomizer>
/ items = (25%, 75%)
/ selectionrate = always
</list>

<text probe>
/ items = ("P")
/ hposition = values.probex
</text>

<text c>
/ items = ("CORRECT")
/ txcolor = green
</text>

<text e>
/ items = ("ERROR")
/ txcolor = red
</text>

<block myblock>
/ trials = [1-10 = mytrial]
</block>

<trial mytrial>
/ ontrialbegin = [
    values.probex = list.practiceproberandomizer.nextvalue;
    if (values.probex == 25%) {
        values.correctkey = parameters.responsekey_left;
    } else if (values.probex == 75%) {
        values.correctkey = parameters.responsekey_right;
    }
]
/ stimulusframes = [1=probe]
/ validresponse = (parameters.responsekey_left, parameters.responsekey_right)
/ correctresponse = (values.correctkey)
/ correctmessage = true(c, 500)
/ errormessage = true(e, 500)
</trial>



This worked, thank you so much
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search