Millisecond Forums

error sound and quit button

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

By Johanne - 2/21/2017

Hello, 

I have two questions concerning a script I'm writing with Inquisit 3. 
1) I would like a  errorfeedback when the participant makes a mistake. 
I tried to program this, however it does not seem to work. 

<item errorsound>
/1 = "errorsound.wav"
</item>

<sound errorfeedbacksound>
/items = errorsound
</sound>

<trial testA>
/ ontrialbegin = [if (trial.testA.correct == false) sound.errorfeedbacksound]
/ stimulusframes = [1=correctAnswer, one, two, three, four, five, six, seven, eight, nine, ten,
   eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, numbers, quitbuttona]
/ validresponse = (correctAnswer, one, two, three, four, five, six, seven, eight, nine, ten,
  eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, quitbuttona)
/ correctresponse = (correctAnswer)
/ correctmessage = true(correctMark, 0)
/ errormessage = true(errorMark, 0)
</trial>

2) Furthermore, I would like a quit button during every task (when the participant clicks on the button the task stops).
I was wondering if it is also possible to have this in a openended trial. 

<openended testC>
/ stimulusframes = [1 = testC, stoppen]
/ iscorrectresponse = [
values.response = toupper(openended.testC.response);
values.response = replaceall(values.response, " ", "");
values.correctAnswer = getitem(item.testC_correctAnswers,text.testC.currentitemnumber);
values.response == values.correctAnswer;
]
/ validresponse = (quitbuttonc, anyresponse, correctAnswer)
/ ontrialend = [
insert(item.testAccuracy_easy,openended.testC.correct, 1);
if (openended.testC.correct) {
insert(item.testlatencies_easy,openended.testC.latency, 1);
} ;
if (openended.testC.response != "") {
values.countAttempted = values.countAttempted + 1;
}]
/ontrialend = [if (trial.testC.response == "quitbuttonc")
{values.quittimec = block.testC.elapsedtime;
values.quitc = 1;}]
/ buttonlabel = "volgende"
/ timeout = 20000
/ errormessage = true(errorfeedback, 500)
/ correctmessage = true(correctfeedback,500)
/ ontrialend = [values.testCCorrect = trial.testC.numCorrect]
</openended>

<block testC>
/ stop = [values.quitc == 1]
/ trials = [1-25 = testC]
/ timeout = 1200000
</block>


Thanks in advance!
Johanne
By Dave - 2/21/2017

Johanne - Tuesday, February 21, 2017
Hello, 

I have two questions concerning a script I'm writing with Inquisit 3. 
1) I would like a  errorfeedback when the participant makes a mistake. 
I tried to program this, however it does not seem to work. 

<item errorsound>
/1 = "errorsound.wav"
</item>

<sound errorfeedbacksound>
/items = errorsound
</sound>

<trial testA>
/ ontrialbegin = [if (trial.testA.correct == false) sound.errorfeedbacksound]
/ stimulusframes = [1=correctAnswer, one, two, three, four, five, six, seven, eight, nine, ten,
   eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, numbers, quitbuttona]
/ validresponse = (correctAnswer, one, two, three, four, five, six, seven, eight, nine, ten,
  eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, quitbuttona)
/ correctresponse = (correctAnswer)
/ correctmessage = true(correctMark, 0)
/ errormessage = true(errorMark, 0)
</trial>

2) Furthermore, I would like a quit button during every task (when the participant clicks on the button the task stops).
I was wondering if it is also possible to have this in a openended trial. 

<openended testC>
/ stimulusframes = [1 = testC, stoppen]
/ iscorrectresponse = [
values.response = toupper(openended.testC.response);
values.response = replaceall(values.response, " ", "");
values.correctAnswer = getitem(item.testC_correctAnswers,text.testC.currentitemnumber);
values.response == values.correctAnswer;
]
/ validresponse = (quitbuttonc, anyresponse, correctAnswer)
/ ontrialend = [
insert(item.testAccuracy_easy,openended.testC.correct, 1);
if (openended.testC.correct) {
insert(item.testlatencies_easy,openended.testC.latency, 1);
} ;
if (openended.testC.response != "") {
values.countAttempted = values.countAttempted + 1;
}]
/ontrialend = [if (trial.testC.response == "quitbuttonc")
{values.quittimec = block.testC.elapsedtime;
values.quitc = 1;}]
/ buttonlabel = "volgende"
/ timeout = 20000
/ errormessage = true(errorfeedback, 500)
/ correctmessage = true(correctfeedback,500)
/ ontrialend = [values.testCCorrect = trial.testC.numCorrect]
</openended>

<block testC>
/ stop = [values.quitc == 1]
/ trials = [1-25 = testC]
/ timeout = 1200000
</block>


Thanks in advance!
Johanne

/ errormessage = true(errorMark, 0)

needs to read

/ errormessage = true(errorfeedbacksound, 500)

Also, a <trial> may only have a single /errormessage and a single /correctmessage attribute, not mulltiple. You may, however, define multiple /responsemessage attributes.

> 2) Furthermore, I would like a quit button during every task (when the participant clicks on the button the task stops).
> I was wondering if it is also possible to have this in a openended trial.

No.
By Johanne - 2/28/2017

Hi Dave, thanks a lot for the last answer!
I have some follow up questions.

Is it possible to have and an error message and sound at the same time with the responsemessage  feature?

Furthermore, I was wondering if you can programme in the openended trial that when the participants press the ESC button the expt (so not the script) quits. If I understand correctly the scancode for the ESC-key is 1. However, now the expt ends when you press 1 and the ‘nextbutton’.
See part of the script below.

Thanks in advance!
Johanne


<openended testC>
/ stimulusframes = [1 = testC, stoppen]
/ iscorrectresponse = [
     values.response = toupper(openended.testC.response);
     values.response = replaceall(values.response, " ", "");
     values.correctAnswer = getitem(item.testC_correctAnswers,text.testC.currentitemnumber);
     values.response == values.correctAnswer;
]
/ validresponse = (anyresponse, correctAnswer)
/ validresponse = (scancode)

/ ontrialend = [
     insert(item.testAccuracy_easy,openended.testC.correct, 1);
     if (openended.testC.correct) {
          insert(item.testlatencies_easy,openended.testC.latency, 1);
     } ;

     if (openended.testC.response != "") {
          values.countAttempted = values.countAttempted + 1;
     }]
/ontrialend = [if (trial.testC.response == 1)
                        {values.quittimec = block.testC.elapsedtime;
                             values.quitc = 1;}]

/ buttonlabel = "volgende"
/ timeout = 20000
/ errormessage = true(errorfeedback, 500)
/ correctmessage = true(correctfeedback,500)
/ ontrialend = [values.testCCorrect = trial.testC.numCorrect]
</openended>
By Dave - 2/28/2017

Johanne - Tuesday, February 28, 2017
Hi Dave, thanks a lot for the last answer!
I have some follow up questions.

Is it possible to have and an error message and sound at the same time with the responsemessage  feature?

Furthermore, I was wondering if you can programme in the openended trial that when the participants press the ESC button the expt (so not the script) quits. If I understand correctly the scancode for the ESC-key is 1. However, now the expt ends when you press 1 and the ‘nextbutton’.
See part of the script below.

Thanks in advance!
Johanne


<openended testC>
/ stimulusframes = [1 = testC, stoppen]
/ iscorrectresponse = [
     values.response = toupper(openended.testC.response);
     values.response = replaceall(values.response, " ", "");
     values.correctAnswer = getitem(item.testC_correctAnswers,text.testC.currentitemnumber);
     values.response == values.correctAnswer;
]
/ validresponse = (anyresponse, correctAnswer)
/ validresponse = (scancode)

/ ontrialend = [
     insert(item.testAccuracy_easy,openended.testC.correct, 1);
     if (openended.testC.correct) {
          insert(item.testlatencies_easy,openended.testC.latency, 1);
     } ;

     if (openended.testC.response != "") {
          values.countAttempted = values.countAttempted + 1;
     }]
/ontrialend = [if (trial.testC.response == 1)
                        {values.quittimec = block.testC.elapsedtime;
                             values.quitc = 1;}]

/ buttonlabel = "volgende"
/ timeout = 20000
/ errormessage = true(errorfeedback, 500)
/ correctmessage = true(correctfeedback,500)
/ ontrialend = [values.testCCorrect = trial.testC.numCorrect]
</openended>

> Is it possible to have and an error message and sound at the same time with the responsemessage  feature?

Yes.

> I was wondering if you can programme in the openended trial that when the participants press the ESC button the expt (so not the script).

No. The only thing you can do is have the participants type some special word (e.g. "quit") into the openended's textbox and then /stop based on that.

<expt>
/ stop = [openended.testc.response == "quit"]
...
</expt>
By Johanne - 3/5/2017

Hi dave, 
Thanks again for the answer, that really helps a lot. 

I however cannot figure out how to use / responsemessage to play an errorsound and errormessage.
This part of the script is in the first comment.

Furthermore, I came across another problem. 
I have 3 blocks that branch and thus repeat after each other. 
I want them to stop after 20 minutes. 
This is tried to program this with the timeout function, however this does not work. 
Then I tried to branch the experiment after 20 minutes.
The elapsed time of the experiment does not seem to be correct in my output.
It shows an amount of time that is way to long.
Do you know a solution to this problem?
This part of the script is bellow.

Thanks in advance. 
Johanne

<expt bversion>
/ subjects = (1 of 1)
/ skip = [values.experimentswitch==1]
/ skip = [values.experimentswitch==3]
/ onexptbegin = [if (!values.showdeckinfo) text.deck.textcolor = white]
/ blocks = [1 = color]
/ preinstructions = (welcome, page1)
/ postinstructions = (endb)
/ onexptend = [values.completed = 1]
/ branch = [if (expt.bversion.elapsedtime < 1200000) expt.cversion]
</expt>

<block color>
/ stop = [values.quitb == 1]
/ onblockbegin = [values.correctstreak = 0; values.errorsum_block = 0]
/ onblockbegin = [values.PerseverativeResponse = 0]
/ onblockbegin = [values.colorblockcount = values.colorblockcount + 1]
/ onblockbegin = [values.category = 1]

/ trials = [1 = selectcard]

/ skip = [values.colorblockcount >= values.cstotalblocks]
/ stop = [expressions.toomanytrials]
/ stop = [values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0]

/ onblockend = [if (values.colorblockcount == 1) values.trialscompletefirstcategory = values.colortrialcount]
/ onblockend = [if (values.correctstreak == values.correctstreakthreshold )
values.completedcategories = values.completedcategories + 1]

/ onblockend = [if (values.colorblockcount == 1) values.percenterror_C1 = 100 * (values.errorsum_block/trial.selectcard.count)
else values.percenterror_C2 = 100*(values.errorsum_block/trial.selectcard.count)]
/ branch = [if (values.colorblockcount > values.cstotalblocks) ]
/ branch = [if (expressions.toomanytrials) ]
/ branch = [if (values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0)
{values.OldRuleWindow = 1; values.RuleChange = 1; block.form}]
/ timeout = max(1200000 - block.color.elapsedtime - block.form.elapsedtime - block.number.elapsedtime, 1)
</block>

<block form>
/ stop = [values.quitb == 1]
/ onblockbegin = [values.correctstreak = 0; values.errorsum_block = 0]
/ onblockbegin = [values.PerseverativeResponse = 0]
/ onblockbegin = [values.formblockcount = values.formblockcount + 1]
/ onblockbegin = [values.category = 2]

/ trials = [1 = selectcard]

/ skip = [values.formblockcount >= values.cstotalblocks]
/ stop = [expressions.toomanytrials]
/ stop = [values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0]

/ onblockend = [if (values.correctstreak == values.correctstreakthreshold )
values.completedcategories = values.completedcategories + 1]

/ onblockend = [if (values.formblockcount == 1) values.percenterror_F1 = 100 * (values.errorsum_block/trial.selectcard.count)
else values.percenterror_F2 = 100*(values.errorsum_block/trial.selectcard.count)]

/ branch = [if (values.formblockcount > values.cstotalblocks)]
/ branch = [if (expressions.toomanytrials)]
/ branch = [if (values.correctstreak > 0 && mod(values, values.correctstreakthreshold)==0)
{values.OldRuleWindow = 1; values.RuleChange = 1; block.number}]
/ timeout = max(1200000 - block.color.elapsedtime - block.form.elapsedtime - block.number.elapsedtime, 1)
</block>


<block number>
/ stop = [values.quitb == 1]
/ onblockbegin = [values.correctstreak = 0; values.errorsum_block = 0]
/ onblockbegin = [values.PerseverativeResponse= 0]
/ onblockbegin = [values.numberblockcount = values.numberblockcount + 1]
/ onblockbegin = [values.category = 3]

/ trials = [1 = selectcard]

/ skip = [values.numberblockcount >= values.cstotalblocks]
/ stop = [expressions.toomanytrials]
/ stop = [values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0]

/ onblockend = [if (values.correctstreak == values.correctstreakthreshold )
values.completedcategories = values.completedcategories + 1]

/ onblockend = [if (values.numberblockcount == 1) values.percenterror_N1 = 100 * (values.errorsum_block/trial.selectcard.count)
else values.percenterror_N2 = 100*(values.errorsum_block/trial.selectcard.count)]

/ branch = [if (values.numberblockcount > values.cstotalblocks)]
/ branch = [if (expressions.toomanytrials)]
/ branch = [if (values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold) ==0)
{values.OldRuleWindow = 1; values.RuleChange = 1; block.color}]
/ timeout = max(1200000 - block.color.elapsedtime - block.form.elapsedtime - block.number.elapsedtime, 1)
</block>
By Dave - 3/6/2017

Johanne - Monday, March 6, 2017
Hi dave, 
Thanks again for the answer, that really helps a lot. 

I however cannot figure out how to use / responsemessage to play an errorsound and errormessage.
This part of the script is in the first comment.

Furthermore, I came across another problem. 
I have 3 blocks that branch and thus repeat after each other. 
I want them to stop after 20 minutes. 
This is tried to program this with the timeout function, however this does not work. 
Then I tried to branch the experiment after 20 minutes.
The elapsed time of the experiment does not seem to be correct in my output.
It shows an amount of time that is way to long.
Do you know a solution to this problem?
This part of the script is bellow.

Thanks in advance. 
Johanne

<expt bversion>
/ subjects = (1 of 1)
/ skip = [values.experimentswitch==1]
/ skip = [values.experimentswitch==3]
/ onexptbegin = [if (!values.showdeckinfo) text.deck.textcolor = white]
/ blocks = [1 = color]
/ preinstructions = (welcome, page1)
/ postinstructions = (endb)
/ onexptend = [values.completed = 1]
/ branch = [if (expt.bversion.elapsedtime < 1200000) expt.cversion]
</expt>

<block color>
/ stop = [values.quitb == 1]
/ onblockbegin = [values.correctstreak = 0; values.errorsum_block = 0]
/ onblockbegin = [values.PerseverativeResponse = 0]
/ onblockbegin = [values.colorblockcount = values.colorblockcount + 1]
/ onblockbegin = [values.category = 1]

/ trials = [1 = selectcard]

/ skip = [values.colorblockcount >= values.cstotalblocks]
/ stop = [expressions.toomanytrials]
/ stop = [values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0]

/ onblockend = [if (values.colorblockcount == 1) values.trialscompletefirstcategory = values.colortrialcount]
/ onblockend = [if (values.correctstreak == values.correctstreakthreshold )
values.completedcategories = values.completedcategories + 1]

/ onblockend = [if (values.colorblockcount == 1) values.percenterror_C1 = 100 * (values.errorsum_block/trial.selectcard.count)
else values.percenterror_C2 = 100*(values.errorsum_block/trial.selectcard.count)]
/ branch = [if (values.colorblockcount > values.cstotalblocks) ]
/ branch = [if (expressions.toomanytrials) ]
/ branch = [if (values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0)
{values.OldRuleWindow = 1; values.RuleChange = 1; block.form}]
/ timeout = max(1200000 - block.color.elapsedtime - block.form.elapsedtime - block.number.elapsedtime, 1)
</block>

<block form>
/ stop = [values.quitb == 1]
/ onblockbegin = [values.correctstreak = 0; values.errorsum_block = 0]
/ onblockbegin = [values.PerseverativeResponse = 0]
/ onblockbegin = [values.formblockcount = values.formblockcount + 1]
/ onblockbegin = [values.category = 2]

/ trials = [1 = selectcard]

/ skip = [values.formblockcount >= values.cstotalblocks]
/ stop = [expressions.toomanytrials]
/ stop = [values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0]

/ onblockend = [if (values.correctstreak == values.correctstreakthreshold )
values.completedcategories = values.completedcategories + 1]

/ onblockend = [if (values.formblockcount == 1) values.percenterror_F1 = 100 * (values.errorsum_block/trial.selectcard.count)
else values.percenterror_F2 = 100*(values.errorsum_block/trial.selectcard.count)]

/ branch = [if (values.formblockcount > values.cstotalblocks)]
/ branch = [if (expressions.toomanytrials)]
/ branch = [if (values.correctstreak > 0 && mod(values, values.correctstreakthreshold)==0)
{values.OldRuleWindow = 1; values.RuleChange = 1; block.number}]
/ timeout = max(1200000 - block.color.elapsedtime - block.form.elapsedtime - block.number.elapsedtime, 1)
</block>


<block number>
/ stop = [values.quitb == 1]
/ onblockbegin = [values.correctstreak = 0; values.errorsum_block = 0]
/ onblockbegin = [values.PerseverativeResponse= 0]
/ onblockbegin = [values.numberblockcount = values.numberblockcount + 1]
/ onblockbegin = [values.category = 3]

/ trials = [1 = selectcard]

/ skip = [values.numberblockcount >= values.cstotalblocks]
/ stop = [expressions.toomanytrials]
/ stop = [values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold)==0]

/ onblockend = [if (values.correctstreak == values.correctstreakthreshold )
values.completedcategories = values.completedcategories + 1]

/ onblockend = [if (values.numberblockcount == 1) values.percenterror_N1 = 100 * (values.errorsum_block/trial.selectcard.count)
else values.percenterror_N2 = 100*(values.errorsum_block/trial.selectcard.count)]

/ branch = [if (values.numberblockcount > values.cstotalblocks)]
/ branch = [if (expressions.toomanytrials)]
/ branch = [if (values.correctstreak > 0 && mod(values.correctstreak, values.correctstreakthreshold) ==0)
{values.OldRuleWindow = 1; values.RuleChange = 1; block.color}]
/ timeout = max(1200000 - block.color.elapsedtime - block.form.elapsedtime - block.number.elapsedtime, 1)
</block>

> I however cannot figure out how to use / responsemessage to play an errorsound and errormessage.

You need to define a /responsemessage attribute for every response that is *not* a correct response.

To terminate the procedure after 20 minutes, try defining /stop attributes at the <expt> level, i.e. something like

<expt>
/ stop = [script.elapsedtime >= 1200000]
...
</expt>