Hi, I am running into a few issues when trying to adapt this solution for use across modules (I suspect this might be due to my lack of js knowledge rather than anything specific to pavlovia…)
-
I assume that I need to create a single PyschoJS object for the entire experiment by calling const psychoJS = new PsychoJS
in the first scene/module (here, js/scenes/platformerSceneA.js
). Within the scene, this object is updated on after trial using a function that calls to psychoJS.experiment.addData(key, value)
.
-
So, when the next module (scene/stage of the experiment) starts (here, js/scenes/platformerSceneB.js
), what I want to do is continue adding to the same psychoJS object as before.
I think I have achieved this by using export/import across modules, i.e.:
in platformerSceneA.js:
export const psychoJS = new PsychoJS({ debug: true })
in platformerSceneB.js:
import { psychoJS } from "./platformerSceneA.js"
This seems to work, up until the end of the task (last module, js/scenes/taskEndScene.js
, when I am getting a fatal javascript error if I either try to log the psychoJS object to the console (to check that everything is getting stored), or call psychoJS.experiment.save();
(see below):
FATAL unknown | {} [log4javascript.min.js:1:40074](https://cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.9/log4javascript.min.js)
append https://cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.9/log4javascript.min.js:1
doAppend https://cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.9/log4javascript.min.js:1
callAppenders https://cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.9/log4javascript.min.js:1
log https://cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.9/log4javascript.min.js:1
fatal https://cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.9/log4javascript.min.js:1
dialog https://run.pavlovia.org/agnes.norbury/study-game-1/lib/core-2020.2.js:1151
onerror https://run.pavlovia.org/agnes.norbury/study-game-1/lib/core-2020.2.js:1823
I am also not generating any csv datafiles on gitlab.
I am wondering if either I am doing something wrong in with import/export above, or if I am missing something simple in my script to communicate with the core library to say that I’m ending my experiment? (I am also getting a couple of uncaught type errors, TypeError: this._setRequiredKeys is undefined
[at the start of the experiment, I think related to downloading resources, and assume I can ignore], and Uncaught TypeError: dialogElement is null
[which I think might relate to the fatal error at the end, may something to do with not setting psychoJS.Status correctly]).
I don’t know if this makes a difference, but I am currently testing in pilot mode (so as not to consume credits), might this be adding an extra layer of complication?
Sorry for the very long message, I will keep trying to look into this this afternoon but any help would be much appreciated.
Best
Agnes