Hi zai,
having trials.finished = false and single quotes for one string and double quotes for another shouldn’t be causing any issues.
However, the loop you printed below wouldn’t run. if statement two is true comm >= 6 then statement 1 would also be true comm >= 4.
So first your conditions aren’t right. you should maybe instead do something like, if comm < 6 and else if comm >= 6.
Question1: does your code does what you want it do to offline?
Question2: where do you define ‘comm’? During your trials, you need to define a correct answer in some way. It might be better to use a trial file with correct answers, and then if key_resp.corr == 1 to say ‘comm = comm + 1’ for example.
I would recommend for you to start a new experiment, and just try to only get the practice loop working, offline and online. You could just use this approach:
for the outer ‘practice_rounds’ loop:
- looptype = sequential
- untick ‘Is trials’
- nReps = 3
- everything else left blank, it should say ‘no parameters set’
then for your inner loop:
- I have looptype as random (think you should be able to use other types, but maybe use this to start)
- ‘Is trials’ is ticked
- nReps = 1
- conditions = a .csv file with your conditions and corrAns (which you need to break the loop, if you want to base this on correct answers). It should say you have x conditions with x parameters.
This is what my loop looks like (it’s big so the beginning is cut off):
So in the last box inside the inner pracLoop (called Ptrials_feedback), I have a code segment where I keep track of correct answers from the trials. In this code segment, in the ‘begin experiment’ part, for both the Python and the JS code I have PCorrs = 0
Then in the ‘begin Routine’ code segment I have:
for Python:
if key_resp.corr == 1:
feedbackCol = [0,1,0]
PCorrs = PCorrs + 1
For JS:
if (key_resp.corr == 1) {
PCorrs = PCorrs + 1;
}
Then in the outer loop, the single green box titled ‘BreakPLoop’ I display some text to say whether they will need to repeat the practice or not, and a code segment to break the outer loop. In this code segment, for ‘Begin experiment’, for both Python and JS code I have: ‘PLoopTally = 0’
Then in the ‘begin routine’ part I have:
For Python:
if PLoopTally >= 3:
Practice_rounds.finished = True
msg = “Well done!”
elif PCorrs >= 6:
Practice_rounds.finished = True
msg = “Well done!”
else:
PLoopTally = PLoopTally + 1
PCorrs = 0
msg = “Let’s try that one more time!”
So this will quit the loop automatically if the outer loop has been repeated more than 3 times, or it will quit the loop immediately if at least 6 correct answers were given during the practice trials. the text after ‘msg’ is just what I display with this screen for 2 seconds.
For JS I have:
if (PLoopTally >= 3) {
msg = “Well done!”;
trials.finished = true;
} else if (PCorrs >= 6) {
msg = “Well done!”;
trials.finished = true;
} else {
trials.finished = false;
PLoopTally = PLoopTally + 1;
PCorrs = 0;
msg = “Let’s try that one more time!”;
}