how to properly load stimulus into Cognition.run? #1637
-
Hi all! 🙂 My jsPsych experiment runs without an issue on its own, but I can't make it run on Cognition.run. I think it has to do with the stimulus file ("stims.js"). So here's what I am doing: I upload the stims.js file using the window which is on the left side of Cognition.run. Then, I'm unclear what I should do the next. In jsPsych, you can do <script src = "path to stim file">. But how do you do that with Cognition.run? Does Cognition automatically recognize the variable "stims" that's defined in the stim.js file? (It seems not). So far, I tried the following line in the code: but this doesn't work (please see the first screenshot). When I go into the console, it says the following: If I just define the variable "stims" within the code (i.e., uncomment lines 16-19), then the problem goes away and the experiment starts running on Cognition.run. So what might be the problem? The stims.js file has the following content in it: var stims = [ Thank you for your help in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @sonhkim, yes if you upload your stims.js file in cognition.run then the var stims = "stims.js"; Because that will overwrite the I'd that doesn't fix it then I'm not sure what else could be causing the error. Maybe double-check that there aren't any errors in your stims.js file. And you can check that you have access to it in the main code by adding |
Beta Was this translation helpful? Give feedback.
Hi @sonhkim, yes if you upload your stims.js file in cognition.run then the
stims
variable that's defined in that file should be available. You shouldn't have to do anything else. Can you try removing this line:Because that will overwrite the
stims
variable that's defined in your file.I'd that doesn't fix it then I'm not sure what else could be causing the error. Maybe double-check that there aren't any errors in your stims.js file. And you can check that you have access to it in the main code by adding
console.log(stims)
somewhere. Then if you preview the study with the developer tools open, you should see the stims array in the console.