Break if statement not working
Hello,
I want the loop to break if the participant gets more than three correct. I have put this in the break if field and nothing happens. Any ideas? Thanks so much!!
=len(responses.correct) >= 3 and None not in responses.correct[:3] and 0 not in responses.correct[:3]
Comments
Hi Mollie,
having complex if statements in the run if of break if field is quite tricky. It is very easy to mess things up and debugging takes a lot of time. I recommend you use an inline_script and following syntax:
Also you need to make sure that before you enter the block loop, you set the break if field back to
never. To do so, pasteitems['block_loop'].var.break_if = u'never'in aninline_scriptin thesequence before theblock_loop`.Hope this helps,
Eduard
Hey Eduard!
Thank you so much for your response. I am still having trouble making it work. It runs but it does not break the loop after three correct answers. I'm not super sure what I am not doing properly. I have attached the experiment and I would greatly appreciate any help. Thank you so much again.
best,
Mollie
Hi Mollie,
the problem is that you compute the correct response after the current response has been added to the response history. Add this line
responses[0].correct = var.correctto line 5 in yourcorrect_response_2_1_1_1inline_script and it should work.Best,
Eduard
It works!! Thank you so so much!!