Millisecond Forums

Ending a session once a participants gives a wrong answer

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

By s.limmer - 5/25/2022

Hey,
I have the following problem. Within my experiment, I want to exclude people that are suffering from colorblindness. Therefore, I want to terminate the session by redirecting them to a page stating they did not meet the inclusion criteria. I tried to use the stop function, but now Inquisit quits immediately when entering the color check. It now quits even before I enter any digit. I think something is wrong with my condition, but I cannot figure out what exactly it is. Any help would be really appreciated :)

<picture colorblidness>
<picture colorblidness>
/items = ("colorblidness_check.png")
/ position = (50%, 50%)
/ size = (75%, 75%)
</picture>

<openended colorCheck>
/ stimulustimes = [0 = colorblidness; 3000 = text.colorQ; 50=colorQ1]
/ validresponse = (anyresponse)
/ correctresponse = (74)
/ beginresponsetime = 5000
/ stop = [
    openended.colorCheck.responsetext != 74
]
</openended>


<text colorQ>
/ items = ("Please fill in the presented two-digit number:")
/ position = (50%, 40%)
</text>

<text colorQ1>
/ items = ("Here we want to check whether you can see the correct number.
Please look at the picture carefully.")
/ position = (45%, 10%)
</text>

<block testtrialcolor>
/trials = [1= openended.colorCheck]
/preinstructions = (page.welcome, page.consent)
</block>

By Dave - 5/25/2022

s.limmer - 5/25/2022
Hey,
I have the following problem. Within my experiment, I want to exclude people that are suffering from colorblindness. Therefore, I want to terminate the session by redirecting them to a page stating they did not meet the inclusion criteria. I tried to use the stop function, but now Inquisit quits immediately when entering the color check. It now quits even before I enter any digit. I think something is wrong with my condition, but I cannot figure out what exactly it is. Any help would be really appreciated :)

<picture colorblidness>
<picture colorblidness>
/items = ("colorblidness_check.png")
/ position = (50%, 50%)
/ size = (75%, 75%)
</picture>

<openended colorCheck>
/ stimulustimes = [0 = colorblidness; 3000 = text.colorQ; 50=colorQ1]
/ validresponse = (anyresponse)
/ correctresponse = (74)
/ beginresponsetime = 5000
/ stop = [
    openended.colorCheck.responsetext != 74
]
</openended>


<text colorQ>
/ items = ("Please fill in the presented two-digit number:")
/ position = (50%, 40%)
</text>

<text colorQ1>
/ items = ("Here we want to check whether you can see the correct number.
Please look at the picture carefully.")
/ position = (45%, 10%)
</text>

<block testtrialcolor>
/trials = [1= openended.colorCheck]
/preinstructions = (page.welcome, page.consent)
</block>


Well, you're stopping the openended before it can do anything, the /stop condition simply does not belong there. Also, you're not actually stopping the experiment, just the openended, so this cannot possibly do what you want it to do. Instead you'll want to do something like this:

<picture colorblidness>
/items = ("colorblidness_check.png")
/ position = (50%, 50%)
/ size = (75%, 75%)
</picture>

<openended colorCheck>
/ stimulustimes = [0 = colorblidness; 3000 = text.colorQ; 50=colorQ1]
/ validresponse = (anyresponse)
/ correctresponse = (74)
/ beginresponsetime = 5000
/ branch = [
    if (openended.colorCheck.response != 74) {
        return trial.exclude;
    }
]
</openended>

<trial exclude>
/ ontrialend = [
    script.abort(true);
]
/ stimulusframes = [1=exclusionmessage]
/ validresponse = (0)
/ trialduration = 5000
</trial>

<text exclusionmessage>
/ items = ("Unfortunately you do not meet the inclusion criteria for this study. ~nThe program will exit automatically in five seconds.")
/ size = (60%, 30%)
</text>

<text colorQ>
/ items = ("Please fill in the presented two-digit number:")
/ position = (50%, 40%)
</text>

<text colorQ1>
/ items = ("Here we want to check whether you can see the correct number.
Please look at the picture carefully.")
/ position = (45%, 10%)
</text>

<block testtrialcolor>
/trials = [1= openended.colorCheck]
/ preinstructions = (page.welcome, page.consent)
</block>

By s.limmer - 5/25/2022

Hey Dave,
thank you so much! This works perfectly :). 
By chenxyu - 4/22/2023

Hi Dave, 
Is there a way to screen out people after a certain number of failed attempts? In my case, I ask people to search for a target among a matrix of pictures. They are instructed to click on the target if it is present, or the 'target absent' button if it is absent. Currently, they have unlimited attempts: if their answer is wrong, an error message will pop up and they will restart the trial. This will repeat until they select the target. However, is it possible to set the limit to 2 attempts, so the program will terminate after their second failed attempts? Any advice would help! Thanks in advance!

<item tiger>
/1="tiger.jpeg"
</item>

<picture tiger>
/items=tiger
/ size = (320,180)
/position=(30%,25%)
</picture>

<item santa_claus>
/1="santa-claus.jpeg"
</item>

<picture santa_claus>
/ items = santa_claus
/ size = (320,180)
/position=(50%,25%)
</picture>

<item picachu>
/1="picachu.jpeg"
</item>

<picture picachu>
/items=picachu
/ size = (320,180)
/position=(70%,25%)
</picture>

<item snake>
/1="snake.jpeg"
</item>

<picture snake>
/items=snake
/ size = (320,180)
/position=(30%,50%)
</picture>

<item spiderman>
/1="spiderman.jpeg"
</item>

<picture spiderman>
/items=spiderman
/ size = (320,180)
/position=(50%,50%)
</picture>

<item captain_american>
/1="captain american.jpeg"
</item>

<picture captain_american>
/items=captain_american
/ size = (320,180)
/position=(70%,50%)
</picture>

<item duck>
/1="duck.jpeg"
</item>

<picture duck>
/items=duck
/ size = (320,180)
/position=(30%,75%)
</picture>

<item allegator>
/1="allegator.jpeg"
</item>

<picture allegator>
/items=allegator
/ size = (320,180)
/position=(50%,75%)
</picture>

<item waldo>
/1="waldo.jpeg"
</item>

<picture waldo>
/items=waldo
/ size = (320,180)
/position=(70%,75%)
</picture>

<text practice_error_message>
/ items = ("If the duck is present, you should click on the image instead of 'Target Absent'")
/color=red
/ fontstyle = ("Arial", 2.5%, true, false, false, false, 5, 0)
/position=(50%,40%)
/ txbgcolor = black
</text>


<trial Practice_4>
/ stimulusframes = [1=picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button]
/ validresponse = (picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button)
/ correctresponse = (duck)
/ inputdevice = mouse
/ errormessage = true(practice_error_message,5000)
/ branch = [if (trial.Practice_4.error) {trial.Practice_4}]
</trial>
By Dave - 4/24/2023

chenxyu - 4/22/2023
Hi Dave, 
Is there a way to screen out people after a certain number of failed attempts? In my case, I ask people to search for a target among a matrix of pictures. They are instructed to click on the target if it is present, or the 'target absent' button if it is absent. Currently, they have unlimited attempts: if their answer is wrong, an error message will pop up and they will restart the trial. This will repeat until they select the target. However, is it possible to set the limit to 2 attempts, so the program will terminate after their second failed attempts? Any advice would help! Thanks in advance!

<item tiger>
/1="tiger.jpeg"
</item>

<picture tiger>
/items=tiger
/ size = (320,180)
/position=(30%,25%)
</picture>

<item santa_claus>
/1="santa-claus.jpeg"
</item>

<picture santa_claus>
/ items = santa_claus
/ size = (320,180)
/position=(50%,25%)
</picture>

<item picachu>
/1="picachu.jpeg"
</item>

<picture picachu>
/items=picachu
/ size = (320,180)
/position=(70%,25%)
</picture>

<item snake>
/1="snake.jpeg"
</item>

<picture snake>
/items=snake
/ size = (320,180)
/position=(30%,50%)
</picture>

<item spiderman>
/1="spiderman.jpeg"
</item>

<picture spiderman>
/items=spiderman
/ size = (320,180)
/position=(50%,50%)
</picture>

<item captain_american>
/1="captain american.jpeg"
</item>

<picture captain_american>
/items=captain_american
/ size = (320,180)
/position=(70%,50%)
</picture>

<item duck>
/1="duck.jpeg"
</item>

<picture duck>
/items=duck
/ size = (320,180)
/position=(30%,75%)
</picture>

<item allegator>
/1="allegator.jpeg"
</item>

<picture allegator>
/items=allegator
/ size = (320,180)
/position=(50%,75%)
</picture>

<item waldo>
/1="waldo.jpeg"
</item>

<picture waldo>
/items=waldo
/ size = (320,180)
/position=(70%,75%)
</picture>

<text practice_error_message>
/ items = ("If the duck is present, you should click on the image instead of 'Target Absent'")
/color=red
/ fontstyle = ("Arial", 2.5%, true, false, false, false, 5, 0)
/position=(50%,40%)
/ txbgcolor = black
</text>


<trial Practice_4>
/ stimulusframes = [1=picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button]
/ validresponse = (picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button)
/ correctresponse = (duck)
/ inputdevice = mouse
/ errormessage = true(practice_error_message,5000)
/ branch = [if (trial.Practice_4.error) {trial.Practice_4}]
</trial>

Sure, that's easily done.

<values>
/ errorcount = 0
</values>

<trial Practice_4>
/ ontrialend = [
    if (trial.Practice_4.error) {
        values.errorcount += 1;
    };
    if (values.errorcount >= 2) {
        script.abort(true);
    }
]
/ stimulusframes = [1=picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button]
/ validresponse = (picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button)
/ correctresponse = (duck)
/ inputdevice = mouse
/ errormessage = true(practice_error_message,5000)
/ branch = [if (trial.Practice_4.error) {trial.Practice_4}]
</trial>

<block example>
/ trials = [1=Practice_4]
</block>
By chenxyu - 4/24/2023

Hi Dave,
Thank you for your answer! What if I want to display a message before the script is terminated? Does the script.abort function allow a customized message?
By Dave - 4/24/2023

chenxyu - 4/24/2023
Hi Dave,
Thank you for your answer! What if I want to display a message before the script is terminated? Does the script.abort function allow a customized message?

Then you need to first /branch to a trial that displays said message and only call script.abort() at the end of that trial.

<values>
/ errorcount = 0
</values>

<trial Practice_4>
/ ontrialend = [
    if (trial.Practice_4.error) {
        values.errorcount += 1;
    };
]
/ stimulusframes = [1=picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button]
/ validresponse = (picachu,waldo,allegator,duck,captain_american,spiderman,snake,tiger,santa_claus,target_absent_button)
/ correctresponse = (duck)
/ inputdevice = mouse
/ errormessage = true(practice_error_message,5000)
/ branch = [
    if (trial.Practice_4.error && values.errorcount < 2) {
        return trial.Practice_4;
    } else if (trial.Practice_4.error && values.errorcount >= 2) {
        return trial.endmessage;
    };
]
</trial>

<trial endmessage>
/ ontrialend = [
    script.abort(true);
]
/ stimulusframes = [1=endtxt]
/ validresponse = (0)
/ trialduration = 2000
</trial>

<text endtxt>
/ items = ("Thank you for your participation.")
</text>

<block example>
/ trials = [1=Practice_4]
</block>