-
Hi, This works (it stops the trial and ends the timeline after 6 seconds) but my issue is that the ‘postTrial’ screen (which is the next item in the timeline that shows a screen for 4 seconds, with no response required) is cleared by a keypress, which shouldn’t happen (my postTrial variable 'response_ends_trial: false' and I also set 'choices: jsPsych.NO_KEYS'). I am not sure why this is happening - it works fine if the trial ends because of a win, but not a timeout (i.e. if finishTrial() is run). If I run it without finishTrial() (i.e. just endCurrentTimeline()), the postTrial screen also works as it should do, but this is not a viable solution because it allows the current trial to be completed (even if time has elapsed). Similarly, if I put finishTrial() before endCurrentTimeline() in the code, it allows one more move after time has elapsed. I think this is a similar issue to this post that is unanswered. I have also tried to add a marker when the time has elapsed (end_test_timer_flag) to then allow no keys for 'choices' for the task, but this doesn't work. Any insights into why finishTrial() is effecting the following timeline item would be much appreciated!! As a secondary issue, I am finding finishTrial() to sometimes cause trials in the next block to skip, so the grid movement goes two squares at a time. I have not found a systematic explanation as to when or why this happens. Here are the key snippets of code (full code below)
And here is the full file. Note that I am using version 6 because this task will be added onto an experiment that we already have custom plugins for using version 6.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @j-fielder, When you call |
Beta Was this translation helpful? Give feedback.
Hi @j-fielder,
When you call
jsPsych.finishTrial()
outside the context of the plugin then it's possible that some of the events that the plugin sets up are still active. For example, if the plugin sets up an event to listen for a keyboard press and then end the trial, that event has to be cleared. In the plugin code we typically do this by ensuring that when the plugin ends there are no lingering events, andjsPsych.pluginAPI.cancelAllKeyboardResponses()
(docs) is one way that can be done. It's probably safe to call this method right before you call.finishTrial()
, though it's not a use case that we have tested extensively.