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
This isn't so much a question, as a report of an issue and its solution. The problem is hard to diagnose, since it depends on using a jsPsych plugin in external code that is not used in the main task code.
TDLR: cognition.run only checks the main task code to decide which plugins to load. This means that any external code that uses a plugin not not used in the main task will fail to load. The solution is to add dummy comments into the main task mentioning any plugins used in the external code.
Here's a sample experiment:
var jsPsych = initJsPsych({
on_finish: function(){
jsPsych.data.displayData();
}
});
var timeline [];
timeline.push(external_trial);
jsPsych.run(timeline);
And here's an external javascript file (external.js)
var external_trial = {
type: jsPsychHtmlButtonResponse,
prompt: "Choose a button",
stimulus: "Is sentence a grammatical?",
choices: ["Great","Awful"],
};
Here's a link to the actual experiment that shows it doesn't run:
Uncaught ReferenceError: jsPsychHtmlButtonResponse is not defined
<anonymous> https://cdn.cognition.run/resources/e0rqtsfsj5/libraries/external.js?id=1681757095:3
[external.js:3:3](https://cdn.cognition.run/resources/e0rqtsfsj5/libraries/external.js?id=1681757095)
This means that the relevant plugin code doesn't exist because cognition.run didn't load it.
This is because of the way cognition.run loads plugins: (p.c. from @javidalpe )
For jspsych v7, Cognition looks for the string jsPsychSurveyHtmlForm. For v6, the survey plugin is only added if the string jspsych-survey-html-form plugin can be found in the task source code.
It turns out that that I can make the experiment run simply by adding the following comment to the main experiment code:
// jsPsychHtmlButtonResponse
Here's a link to a copy of the experiment, which is identical except for this commented line:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
This isn't so much a question, as a report of an issue and its solution. The problem is hard to diagnose, since it depends on using a jsPsych plugin in external code that is not used in the main task code.
TDLR: cognition.run only checks the main task code to decide which plugins to load. This means that any external code that uses a plugin not not used in the main task will fail to load. The solution is to add dummy comments into the main task mentioning any plugins used in the external code.
Here's a sample experiment:
And here's an external javascript file (
external.js
)Here's a link to the actual experiment that shows it doesn't run:
https://e0rqtsfsj5.cognition.run/
The error thrown is:
This means that the relevant plugin code doesn't exist because cognition.run didn't load it.
This is because of the way cognition.run loads plugins: (p.c. from @javidalpe )
It turns out that that I can make the experiment run simply by adding the following comment to the main experiment code:
// jsPsychHtmlButtonResponse
Here's a link to a copy of the experiment, which is identical except for this commented line:
https://lkcocoqqey.cognition.run/
This experiment works as expected.
Beta Was this translation helpful? Give feedback.
All reactions