[solved] Repeat Practice block if accuracy less than 80%
I have a simple Stroop experiment with 4 different blocks which are counterbalanced across participants. It all works great. The experiment starts with a practice block of 8 trials. This work fine. However, I would like to repeat the block if accuracy is less than 80%.
I have tried the following in an inline script after the feedback item (which is placed at the end of a Practice block sequence)
if var.acc < 80:
run Practice_Loop
else:
run EndofPractice
I am a recent convert to OpenSesame and am a bit lost. Any pointers would be appreciated.
Deiniol

Comments
Hi Denial,
Think you're almost there with your code. You can find a working example using the same principle here:
http://forum.cogsci.nl/index.php?p=/discussion/comment/7616#Comment_7616
Another option might be to put the practice block in a(nother) loop which you set to repeat something like 999 times for example. Then use a Break if like [acc] > 80 for that loop item. See also:
http://osdoc.cogsci.nl/usage/variables-and-conditional-statements/#using-conditional-if-statements
http://www.cogsci.nl/forum/index.php?p=/discussion/comment/4515#Comment_4515
Best,
Jarik
Now with correct name and clickable links:
Hi Deiniol,
Think you're almost there with your code. You can find a working example using the same principle here: http://forum.cogsci.nl/index.php?p=/discussion/comment/7616#Comment_7616
Another option might be to put the practice block in a(nother) loop which you set to repeat something like 999 times for example. Then use a Break if like [acc] > 80 for that loop item. See also:
http://osdoc.cogsci.nl/usage/variables-and-conditional-statements/#using-conditional-if-statements
http://www.cogsci.nl/forum/index.php?p=/discussion/comment/4515#Comment_4515
Best,
Jarik
Jarik,
Thank you for taking the time to reply.
I looked up the example you posted
http://forum.cogsci.nl/index.php?p=/discussion/comment/7616#Comment_7616
and have used the following script in an inline script that occurs after the practice block feedback (i.e. at the end of the practice block)
if var.acc < 80:
exp.items["PracticeLoop"].prepare()
exp.items["PracticeLoop"].run()
else
exp.items["EndofPractice"].prepare()
exp.items["EndofPractice"].run()
This works fine if accuracy is < 80%. Participants get feedback about their accuracy and instructed to re do the practice. The experiment then loops back to the beginning of the practice loop. However, when accuracy reaches 80% during the practice block then the experiment stops.
I thought an inline script is only implemented at a specific point in an experiment. However, it seems to implement it during the practice block.
Best wishes
Deiniol
I've fixed it! used the following script
if var.acc < 80:
exp.items["PracticeLoop"].prepare()
exp.items["PracticeLoop"].run()
if var.acc > 80:
exp.items["EndofPractice"].prepare()
exp.items["EndofPractice"].run()
Earlier problems were due to an error as I had the feedback item only running (in Run if)if acc < 80.
Problem solved. Thanks fro you help.
Deiniol
Hi Deiniol,
Good to read it's solved!
As far as I know an inline_script only runs when it's encountered in a sequence (assuming your not using parallel or coroutines plug-ins). Please see http://osdoc.cogsci.nl/usage/prepare-run/
Also note that using this method is kind of a hack, so now more then ever:
Always triple check whether your data has been correctly logged before running your experiment!
Best,
Jarik
Hello,
I've gone back to this and am having problems.
Here is my experiment sequence
Participants complete a practice blcok of trials.
CheckACC_practice inline script runs the following
If accuracy is greater than or equal to 90 then the baseline instructions item is prsented and the expreriemnt moves onto a baseline loop. All works as it should
If accuracy is less than 90 then the experiment replays the practice loop and keeps doing this if accuracy continues to be less than 90. All works as it should.
However, if a particpant has less than 90 accuarcy, the practice loop is re-run but if accuracy during the re-run is greater than or equal to 90 then the baseline instructions is presented but when this item is ended with a button push, the experiment generates the following error for line 3 of the script.
TypeError exception message: unsupported operand type(s) for +=: 'NoneType' and 'int'
Is there a way to use script to tell the experiment not to run the practice loop if var.acc is greater then or equal to 90?
many thanks
Deiniol
I think I've fixed it.
I have the CheckACC_practice inline script running using the runif in the practice sequence (run if [acc] < 90). the inline script only incudes the following code.
exp.items["practice_sequence"].prepare()
exp.items["practice_sequence"].run()
If accuracy is less than 90 then the CheckACC_practice inline script runs and the practcie sequence starts again. if accuracy is grater than 90 then the CheckACC_practice inline script doesn't run and the experiment moves on.