You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by SHogenboom May 23, 2023
I’m having issues getting a custom plugin to work/integrate within my jsPsych experiment. It’s most likely an issue with scoping / modules - which I don’t quite understand. I therefore have a hard time figuring out why I cannot get the template to work - irrespective of it’s contents.
I’m using a setup of npm and Parcel (bundler) to serve and test the code. I’m doing this to ultimately bundle and optimize all .js files so they can be integrated in online survey software Limesurvey. The files consist of:
experiment.html (entrypoint)
<!DOCTYPE html>
<html>
<head>
<title>The Word Association Task</title>
<script type="module" src="js/experiment.js"></script>
</head>
<body></body>
</html>
experiment.js (main flow)
// npm install jspsych
import { initJsPsych } from "jspsych"; // general functionality
import "jspsych/css/jspsych.css"; // jspsych styling (e.g., center on screen)
// custom plugin
import { jsPsychWordAssociationGame } from "./jsPsychWordAssociationGame.js";
// INITIALIZE
// Create the jsPsych instance with general functionality
const jsPsych = initJsPsych({
on_finish: function () {
// DEBUG: show the collected data in json format upon experiment completion
jsPsych.data.displayData("json");
},
});
// Start experiment with an empty timeline (i.e., procedure)
const timeline = [];
timeline.push({
type: jsPsychWordAssociationGame,
stimulus: "test",
});
jsPsych.run(timeline);
jsPsychWordAssociationGame.js (custom plugin; used the .js template available on jspsych-contrib)
I first had an issue with the variable jsPsychWordAssociationGame not being found, which is why I added the export. I then had an issue with the jsPsychModule not being found, for which I added the import. I’m now stuck on an error where I do not understand why it occurs: "TypeError: undefined is not an object (evaluating 'jspsych.ParameterType’)”. I added defaults to all input parameters to prevent this, but it has not solved the issue.
Would love any pointers on how to get a custom plugin to work in my Parcel / npm development setup. At some point in time I got the plugin to work when I used CDN urls rather than npm, but couldn’t tell you what I did then.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Discussed in #3046
Originally posted by SHogenboom May 23, 2023
I’m having issues getting a custom plugin to work/integrate within my jsPsych experiment. It’s most likely an issue with scoping / modules - which I don’t quite understand. I therefore have a hard time figuring out why I cannot get the template to work - irrespective of it’s contents.
I’m using a setup of
npm
andParcel
(bundler) to serve and test the code. I’m doing this to ultimately bundle and optimize all.js
files so they can be integrated in online survey software Limesurvey. The files consist of:experiment.html
(entrypoint)experiment.js
(main flow)jsPsychWordAssociationGame.js
(custom plugin; used the.js
template available on jspsych-contrib)I first had an issue with the variable
jsPsychWordAssociationGame
not being found, which is why I added the export. I then had an issue with thejsPsychModule
not being found, for which I added the import. I’m now stuck on an error where I do not understand why it occurs: "TypeError: undefined is not an object (evaluating 'jspsych.ParameterType’)”. I added defaults to all input parameters to prevent this, but it has not solved the issue.Would love any pointers on how to get a custom plugin to work in my Parcel / npm development setup. At some point in time I got the plugin to work when I used CDN urls rather than npm, but couldn’t tell you what I did then.
Thanks in advance!
The text was updated successfully, but these errors were encountered: