Millisecond Forums

Simple script using a list, and giving feedback.

https://forums.millisecond.com/Topic23932.aspx

By Nick Riches - 2/27/2018

Hi

I'm trying to create a Minimal Worked Example for an experiment which involves conditional branching to give feedback. Code is below. I can get the items to display, and I can record the keypresses, but the conditional branching doesn't work. The aim is to give 'correct' and 'incorrect' feedback according to a series of values specified in a lis (called 'answer'). The problem is that the conditional statements (in wordTrial) do not succeed in calling further trials to give the feedback. This is either a problem with the way items from the list are selected, or with the conditional statements themselves. It all looks perfectly okay to me.

Any feedback greatly welcomed

Nick


<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

<list answer>
/ items = ("y", "n")
/ selectionmode = sequence
</list>

<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.correctResponse]
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.incorrectResponse]
</trial>

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>

By Dave - 2/27/2018

Nick Riches - Tuesday, February 27, 2018
Hi

I'm trying to create a Minimal Worked Example for an experiment which involves conditional branching to give feedback. Code is below. I can get the items to display, and I can record the keypresses, but the conditional branching doesn't work. The aim is to give 'correct' and 'incorrect' feedback according to a series of values specified in a lis (called 'answer'). The problem is that the conditional statements (in wordTrial) do not succeed in calling further trials to give the feedback. This is either a problem with the way items from the list are selected, or with the conditional statements themselves. It all looks perfectly okay to me.

Any feedback greatly welcomed

Nick


<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

<list answer>
/ items = ("y", "n")
/ selectionmode = sequence
</list>

<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.correctResponse]
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.incorrectResponse]
</trial>

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>


You would set this up like this:

<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

//pair the answer items to the displayed word item
<list answer>
/ items = ("y", "n")
/ selectionmode = text.wordText.currentindex
</list>

//check if the response given is equal to the scancode of the answer item encoded in the answer list
<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ iscorrectresponse = [
    trial.wordTrial.response == computer.chartoscancode(list.answer.nextvalue);
]

/ branch = [if (trial.wordTrial.correct)trial.correctResponse]
/ branch = [if (trial.wordTrial.error)trial.incorrectResponse]
</trial>
// if correct, /branch to trial.correctresponse
// if incorrect, /branch to trial.incorrectresponse

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>
By Nick Riches - 2/27/2018

Dave - Tuesday, February 27, 2018
Nick Riches - Tuesday, February 27, 2018
Hi

I'm trying to create a Minimal Worked Example for an experiment which involves conditional branching to give feedback. Code is below. I can get the items to display, and I can record the keypresses, but the conditional branching doesn't work. The aim is to give 'correct' and 'incorrect' feedback according to a series of values specified in a lis (called 'answer'). The problem is that the conditional statements (in wordTrial) do not succeed in calling further trials to give the feedback. This is either a problem with the way items from the list are selected, or with the conditional statements themselves. It all looks perfectly okay to me.

Any feedback greatly welcomed

Nick


<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

<list answer>
/ items = ("y", "n")
/ selectionmode = sequence
</list>

<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.correctResponse]
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.incorrectResponse]
</trial>

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>


You would set this up like this:

<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

//pair the answer items to the displayed word item
<list answer>
/ items = ("y", "n")
/ selectionmode = text.wordText.currentindex
</list>

//check if the response given is equal to the scancode of the answer item encoded in the answer list
<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ iscorrectresponse = [
    trial.wordTrial.response == computer.chartoscancode(list.answer.nextvalue);
]

/ branch = [if (trial.wordTrial.correct)trial.correctResponse]
/ branch = [if (trial.wordTrial.error)trial.incorrectResponse]
</trial>
// if correct, /branch to trial.correctresponse
// if incorrect, /branch to trial.incorrectresponse

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>

Many thanks. That does the trick. I can see how the 'chartoscancode' method converts the list object to characters. What I'm not quite sure about is the 'nextvalue' parameter. The answer list is indexed to the current word item. So surely the current value should be correct?

Best wishes

Nick
By Dave - 2/28/2018

Nick Riches - Wednesday, February 28, 2018
Dave - Tuesday, February 27, 2018
Nick Riches - Tuesday, February 27, 2018
Hi

I'm trying to create a Minimal Worked Example for an experiment which involves conditional branching to give feedback. Code is below. I can get the items to display, and I can record the keypresses, but the conditional branching doesn't work. The aim is to give 'correct' and 'incorrect' feedback according to a series of values specified in a lis (called 'answer'). The problem is that the conditional statements (in wordTrial) do not succeed in calling further trials to give the feedback. This is either a problem with the way items from the list are selected, or with the conditional statements themselves. It all looks perfectly okay to me.

Any feedback greatly welcomed

Nick


<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

<list answer>
/ items = ("y", "n")
/ selectionmode = sequence
</list>

<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.correctResponse]
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.incorrectResponse]
</trial>

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>


You would set this up like this:

<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

//pair the answer items to the displayed word item
<list answer>
/ items = ("y", "n")
/ selectionmode = text.wordText.currentindex
</list>

//check if the response given is equal to the scancode of the answer item encoded in the answer list
<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ iscorrectresponse = [
    trial.wordTrial.response == computer.chartoscancode(list.answer.nextvalue);
]

/ branch = [if (trial.wordTrial.correct)trial.correctResponse]
/ branch = [if (trial.wordTrial.error)trial.incorrectResponse]
</trial>
// if correct, /branch to trial.correctresponse
// if incorrect, /branch to trial.incorrectresponse

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>

Many thanks. That does the trick. I can see how the 'chartoscancode' method converts the list object to characters. What I'm not quite sure about is the 'nextvalue' parameter. The answer list is indexed to the current word item. So surely the current value should be correct?

Best wishes

Nick

nextvalue is what actually causes a selection from the list. currentvalue wouldn't work because at this point no selection from the list has actually occurred before. But even if it were so, the list is configured to /selectionrate=trial by default, i.e. even repeated selections within the trial per nextvalue would always return the same, correct value.
By Nick Riches - 3/1/2018

Dave - Wednesday, February 28, 2018
Nick Riches - Wednesday, February 28, 2018
Dave - Tuesday, February 27, 2018
Nick Riches - Tuesday, February 27, 2018
Hi

I'm trying to create a Minimal Worked Example for an experiment which involves conditional branching to give feedback. Code is below. I can get the items to display, and I can record the keypresses, but the conditional branching doesn't work. The aim is to give 'correct' and 'incorrect' feedback according to a series of values specified in a lis (called 'answer'). The problem is that the conditional statements (in wordTrial) do not succeed in calling further trials to give the feedback. This is either a problem with the way items from the list are selected, or with the conditional statements themselves. It all looks perfectly okay to me.

Any feedback greatly welcomed

Nick


<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

<list answer>
/ items = ("y", "n")
/ selectionmode = sequence
</list>

<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.correctResponse]
/ branch = [if (trial.wordTrial.response == list.answer.currentvalue)trial.incorrectResponse]
</trial>

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>


You would set this up like this:

<text wordText>
/ items = ("dog", "cat")
/ select = sequence
</text>

<text questionText>
/ items = ("Is this a dog?", "Is this a lizard?")
/ vposition = 25%
/ select = text.wordText.currentindex
</text>

<text correctResponseText>
/ items = ("Correct!")
</text>

<text incorrectResponseText>
/ items = ("Incorrect!")
</text>

//pair the answer items to the displayed word item
<list answer>
/ items = ("y", "n")
/ selectionmode = text.wordText.currentindex
</list>

//check if the response given is equal to the scancode of the answer item encoded in the answer list
<trial wordTrial>
/ stimulusframes = [1 = wordText, questionText]
/ validresponse = ("y", "n")
/ iscorrectresponse = [
    trial.wordTrial.response == computer.chartoscancode(list.answer.nextvalue);
]

/ branch = [if (trial.wordTrial.correct)trial.correctResponse]
/ branch = [if (trial.wordTrial.error)trial.incorrectResponse]
</trial>
// if correct, /branch to trial.correctresponse
// if incorrect, /branch to trial.incorrectresponse

<trial correctResponse>
/ stimulusframes = [1 = correctResponseText]
/ timeout = 6000
</trial>

<trial incorrectResponse>
/ stimulusframes = [1 = incorrectResponseText]
/ timeout = 6000
</trial>

<block wordBlock>
/ trials = [1-2 = wordTrial]
</block>

<expt exptBlock>
/ blocks = [1 = wordBlock]
</expt>

Many thanks. That does the trick. I can see how the 'chartoscancode' method converts the list object to characters. What I'm not quite sure about is the 'nextvalue' parameter. The answer list is indexed to the current word item. So surely the current value should be correct?

Best wishes

Nick

nextvalue is what actually causes a selection from the list. currentvalue wouldn't work because at this point no selection from the list has actually occurred before. But even if it were so, the list is configured to /selectionrate=trial by default, i.e. even repeated selections within the trial per nextvalue would always return the same, correct value.

Many thanks for that.