Skip to content
Permalink
Browse files

BF: Save data when calling loop.finished in nested loop

In a nested loop, with the outerloop isTrials is False, and the
inner loop isTrials is True, a participant ending their inner loop
on the first iteration, but has repeating inner loop n times based on number
of trials in the outerloop, will not have data saved. This is because
breaking the inner loop on the first iteration does not call nextExtry(),
and the outer loop where isTrials is False does not call nextEntry().
Calling at the end of the task will only write the last trial recorded.
This fix calls nextEntry in endLoopIteration() when currentLoop
 is true and orphan data exists.
  • Loading branch information...
dvbridges authored and peircej committed Jun 19, 2019
1 parent e1bca1b commit 8b7fda826cecc81b4c934b6c0ce711f005309216
Showing with 4 additions and 0 deletions.
  1. +4 −0 psychopy/experiment/components/settings/__init__.py
@@ -794,6 +794,10 @@ def writeEndCodeJS(self, buff):
" return function () {\n"
" // ------Check if user ended loop early------\n"
" if (currentLoop.finished) {\n"
" // Check for and save orphaned data\n"
" if (Object.keys(psychoJS.experiment._thisEntry).length > 0) {\n"
" psychoJS.experiment.nextEntry();\n"
" }\n"
" thisScheduler.stop();\n"
" } else if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {\n"
" psychoJS.experiment.nextEntry();\n"

0 comments on commit 8b7fda8

Please sign in to comment.
You can’t perform that action at this time.